Fix two pipe-initialization races that occur in replication.
commit3a8570e05e1e906435c97f456150ec8683b35c91
authorJeff Darcy <jdarcy@redhat.com>
Wed, 20 Oct 2010 01:10:49 +0000 (19 21:10 -0400)
committerroot <root@localhost.localdomain>
Wed, 20 Oct 2010 01:25:34 +0000 (19 21:25 -0400)
tree4e029131db6ad362dc594a2ec352f5f039d338bb
parente8e1e84c9af5996630f65b9bf0b9dbe1108092e9
Fix two pipe-initialization races that occur in replication.

Turns out there were two race conditions, either of which could lead to
a replication task hanging.  In the first, the consumer thread could
potentially run before the pipe_shared structure was re-initialized in
the producer.  In the second, the producer could post the first chunk
before the consumer initialized its pipe_private, so the sequence
numbers would be off.  That's kind of ironic, since the sequence number
isn't strictly necessary and is only there to guard against a whole
different class of synchronization problems (for which purpose I think
it should remain).  Here's a brief summary.

* replica.c: moved re-initialization of pipe_shared to be before thread
  start (race #1)
* mpipe.c: changed initialization of pp->sequence in pipe_init_private
  (race #2)
* iwh.h: added PID to DPRINTF to distinguish parent/child output
* backend.c: fixed bytes==0 behavior in fs_put_child (unrelated)
* rest.c: fixed pipe_prod_wait_init check in proxy_put_data (unrelated)
backend.c
iwh.h
mpipe.c
replica.c
rest.c