I think this is checking for the wrong sort of race.  I don't think we should ever see a Pipe change from one Connection to another, but we will see the Pipe for a given Connection change.  We should really be checking to see if the Pipe is no longer NULL and, if not, goto above.  But.. I think it is probably even simpler to just lock and unconditionally call back into submit_message with true.  Simpler and everything gets sorted out there...