MCPcopy
hub / github.com/saltstack/salt / _roster_append

Method _roster_append

salt/utils/mmap_cache.py:508–532  ·  view source on GitHub ↗

Append one slot index to the roster file. Uses a persistent open write fd to avoid per-call open/close overhead. Records the byte offset of the new entry in ``_roster_slot_offsets`` so that ``_roster_remove`` can tombstone it in O(1) without re-reading.

(self, slot)

Source from the content-addressed store, hash-verified

506 return self._roster_wfd
507
508 def _roster_append(self, slot):
509 """
510 Append one slot index to the roster file.
511
512 Uses a persistent open write fd to avoid per-call open/close overhead.
513 Records the byte offset of the new entry in ``_roster_slot_offsets``
514 so that ``_roster_remove`` can tombstone it in O(1) without re-reading.
515 """
516 wfd = self._roster_wfd_open()
517 if wfd is None:
518 return
519 try:
520 byte_offset = wfd.seek(0, 2) # seek to end to get current size
521 wfd.write(struct.pack(_ROSTER_ENTRY_FMT, slot))
522 wfd.flush()
523 _fsync_fd_maybe(wfd.fileno())
524 self._roster_slot_offsets[slot] = byte_offset
525 except OSError as exc:
526 log.error("Error appending to roster %s: %s", self.roster_path, exc)
527 try:
528 wfd.close()
529 except OSError:
530 pass
531 self._roster_wfd = None
532 self._roster_invalidate()
533
534 def _roster_remove(self, slot):
535 """

Callers 1

putMethod · 0.95

Calls 9

_roster_wfd_openMethod · 0.95
_roster_invalidateMethod · 0.95
_fsync_fd_maybeFunction · 0.85
writeMethod · 0.45
packMethod · 0.45
flushMethod · 0.45
filenoMethod · 0.45
errorMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected