Support for "polling" select in sock_read_write.

Currently, in sock_read_write function, if the timeout is 0, pupnp
realizes a "blocking" select (with an infinite timeout). With this
patch, if timeout is set to 0, pupnp will realize a "polling" select
and returns immediately if it can not read or write on the socket. This
is very useful for GENA notifications when pupnp is trying to send
events to a disconnected Control Point. "Blocking" select can now be
done by putting a negative timeout value.
This commit is contained in:
Fabrice Fontaine
2010-11-11 21:21:50 -02:00
committed by Marcelo Roberto Jimenez
parent 1fd443f79f
commit 6c64b7eeb5
4 changed files with 25 additions and 13 deletions

View File

@@ -122,9 +122,6 @@ static int sock_read_write(
SOCKET sockfd = info->socket;
long bytes_sent = 0, byte_left = 0, num_written;
if (*timeoutSecs < 0) {
return UPNP_E_TIMEDOUT;
}
FD_ZERO(&readSet);
FD_ZERO(&writeSet);
if (bRead) {
@@ -135,7 +132,7 @@ static int sock_read_write(
timeout.tv_sec = *timeoutSecs;
timeout.tv_usec = 0;
while (TRUE) {
if (*timeoutSecs == 0) {
if (*timeoutSecs < 0) {
retCode = select(sockfd + 1, &readSet, &writeSet,
NULL, NULL);
} else {