[Live-devel] Fix for deadlock

Jeremy Noring jnoring at logitech.com
Wed Feb 3 18:31:38 PST 2010


When streaming over TCP, Live555 can deadlock if it loses the connection to
the server for whatever reason (internet goes down, server has a power
outage, LAN fails, etc.).  I tracked the deadlock down to
RTPInterface::handleRead:

    while ((curBytesRead = readSocket(envir(), fNextTCPReadStreamSocketNum,
                      &buffer[bytesRead], curBytesToRead,
                      fromAddress)) > 0) {

readSocket has an optional timeout argument that defaults to NULL, which is
to block indefinitely.  The problem is if there is some interruption in
service at an unfortunate time, readSocket will block Live555 indefinitely
on a select() statement.  My fix for this is to add a timeout:

    struct timeval timeout; timeout.tv_sec = 2; timeout.tv_usec = 0;
    while ((curBytesRead = readSocket(envir(), fNextTCPReadStreamSocketNum,
                      &buffer[bytesRead], curBytesToRead,
                      fromAddress, &timeout)) > 0) {

...I pulled 2 seconds out of the air; I have no idea if that's a good
number.  I'd like some feedback on whether or not this change is something
I'll seriously regret, and/or if there are other better options at my
disposal to make sure Live555 continues processing data even in the event of
the server going away.

Thanks,

Jeremy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20100203/f05bb3f2/attachment.html>


More information about the live-devel mailing list