On 07/20/2010 03:05 PM, Paul Eggert wrote: > Staring at the code some more I see another race condition > that could explain the problem. Suppose the parent, just > after the last fork, races ahead of the child and jumps > ahead to the "read at_token" cleanup loop. The parent then > executes the last "read at_token" cleanup at a point > where the second-to-the-last child has already output > its token, but before the second-to-the-last-child has > closed the fifo. The "read at_token" will then return 0 (because > it sees end-of-file), but the parent incorrectly thinks > that it has seen a token and then closes down the fifo > before the last child gets a chance to write its token.
Hmm, maybe we should do more validation in the parent - not just read from the fifo, but validate that we actually read a token. That way, we can ignore EOF (on the grounds that it may be a temporary condition, and that more children remain to be run) and only advance when the token we read back is non-empty. -- Eric Blake [email protected] +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
