maidsafe-archive / MaidSafe-RUDP

Implementation of Reliable UDP
Other
95 stars 51 forks source link

Fixes deadlock caused by blocking Transport::Close() #26

Closed inetic closed 9 years ago

inetic commented 9 years ago

I must say I am not sure why the block was there. What the code did, it sent (as a job to another thread [1]) close request to the multiplexer and then blocked till the multiplexer finished. As said, the code was probably there to fix something, but it wasn't a correct fix so if it breaks something I'll deal with it differently. On first glance I didn't see a problem with removing it since lifetime of the multiplexer is preserved using a shared_pointer in the callback to the Multiplexer::Close() metond, and the method doesn't seem to access anything in this Transport object.

[1] Since there were only two threads active, we were in one of them and the other one was blocked by our mutex, the call to Multiplexer::Close was never executed.

ned14 commented 9 years ago

Looks like code I wrote :)

If I remember correctly, some code was dependent on Close() really being closed by the time Close() exited. But if your testing shows no problem, then great fix Peter. Thank god it was easy.

inetic commented 9 years ago

:) Now that you said it, this seems like also not a proper fix. When the transport is Closed and if someone then calls a Transport function that relies on the Multiplexer::IsOpen method to be correct (e.g. Transport::DoConnect), then that might be a problem. I'll have a look what I can do about it this week.