barchart / barchart-udt

Java wrapper for native C++ UDT protocol.
https://github.com/barchart/barchart-udt/wiki
128 stars 89 forks source link

close channel only after queues have stopped their workers, fixes #83 #84

Open jrudolph opened 8 years ago

jrudolph commented 8 years ago

Otherwise, the socket is closed and the file descriptor is freed prematurely. Due to a race condition the queues might then still be trying to use the old file descriptor which by now may already point to another unrelated socket. This may either lead to "stolen" data, data that is read accidentally by the queue worker for the already closed socket. Or it may lead to a complete deadlock, if the file descriptor now points to a blocking socket, so that delete m->second.m_pRcvQueue will never return because it joins the worker thread which blocks indefinitely on the wrong socket. After some time this deadlock will bring UDT completely to a halt because the above code holds the m_ControlLock into which all other work will run and block there after a while.

sequoiar commented 8 years ago

appreciate the fix.