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:<br>
<br> while ((curBytesRead = readSocket(envir(), fNextTCPReadStreamSocketNum,<br> &buffer[bytesRead], curBytesToRead,<br> fromAddress)) > 0) {<br><br>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:<br>
<br> struct timeval timeout; timeout.tv_sec = 2; timeout.tv_usec = 0;<br> while ((curBytesRead = readSocket(envir(), fNextTCPReadStreamSocketNum,<br> &buffer[bytesRead], curBytesToRead,<br> fromAddress, &timeout)) > 0) {<br>
<br>...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.<br>
<br>Thanks,<br><br>Jeremy<br><br><br>