http://dovecot.org/tmp/concurrency.c
I'd want to know what results this program gives with different systems. Please test and reply (but don't bother if someone already replied with the same OS+result). I expect it to print:
- SMP kernels: "page size cut" once in a while
- UP (uniprocessor) kernels: Nothing
- The most important thing is that it never prints "broken data"
It might take a while for it to print anything. With my computer it takes anything from a few seconds to a minute or so. See the file itself for compiling/running instructions.
So far I've tested only with Linux 2.6.21 x86-64/SMP and a slow Solaris/Sparc/UP.
If you're interested in knowing what this is about:
Dovecot writes to dovecot.index.log files by first writing the transaction with its size being 0. After that it writes the 4 size bytes again (using a bit special format with all bytes ORed with 0x80).
I expected that when another process is read()ing the file and it notices the size being valid (all bytes having 0x80) that the whole transaction could always be read. But looks like if the size happens to be just before a memory page boundary, it's possible that the updated size is read, but the rest of the transaction isn't.