rlm_linelog & locking
It appears rlm_linelog doesn't lock the file before writing to it. Should it? Won't lines get interspersed at high logging rates if not?
Phil Mayers wrote:
It appears rlm_linelog doesn't lock the file before writing to it. Should it? Won't lines get interspersed at high logging rates if not?
IIRC, using O_APPEND, and writing small amounts means that the writes are "all or nothing". i.e. The OS takes care of ensuring that the write succeeds. This means that lines from different threads will get put into the log file in arbitrary order. But the lines *won't* be split in the middle. Alan DeKok.
Alan DeKok wrote:
Phil Mayers wrote:
It appears rlm_linelog doesn't lock the file before writing to it. Should it? Won't lines get interspersed at high logging rates if not?
IIRC, using O_APPEND, and writing small amounts means that the writes are "all or nothing". i.e. The OS takes care of ensuring that the write succeeds.
Ah - I see man 2 write says: """If the file was open(2)ed with O_APPEND, the file offset is first set to the end of the file before writing. The adjustment of the file offset and the write operation are performed as an atomic step...""" ...and goes on to list the (few) circumstances under which the number of bytes written is < number of bytes in buffer - basically, signals or out of disk space. Cool - thanks!
participants (2)
-
Alan DeKok -
Phil Mayers