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:
parent
1fd443f79f
commit
6c64b7eeb5
12
ChangeLog
12
ChangeLog
@ -2,6 +2,18 @@
|
||||
Version 1.8.0
|
||||
*******************************************************************************
|
||||
|
||||
2010-11-10 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
|
||||
|
||||
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.
|
||||
|
||||
2010-09-18 Chandra Penke <chandrapenke(at)mcntech.com>
|
||||
|
||||
This is a minor build fix. The new Template*.h files added in the latest
|
||||
|
@ -2057,7 +2057,7 @@ EXPORT_SPEC int UpnpOpenHttpGet(
|
||||
int *httpStatus,
|
||||
/*! [in] The time out value sent with the request during which a response
|
||||
* is expected from the server, failing which, an error is reported
|
||||
* back to the user. */
|
||||
* back to the user. If value is negative, timeout is infinite. */
|
||||
int timeout);
|
||||
|
||||
|
||||
@ -2104,7 +2104,7 @@ EXPORT_SPEC int UpnpOpenHttpGetProxy(
|
||||
int *httpStatus,
|
||||
/*! [in] The time out value sent with the request during which a response
|
||||
* is expected from the server, failing which, an error is reported
|
||||
* back to the user. */
|
||||
* back to the user. If value is negative, timeout is infinite. */
|
||||
int timeout);
|
||||
|
||||
|
||||
@ -2155,7 +2155,7 @@ EXPORT_SPEC int UpnpOpenHttpGetEx(
|
||||
int highRange,
|
||||
/*! [in] A time out value sent with the request during which a response is
|
||||
* expected from the server, failing which, an error is reported back
|
||||
* to the user. */
|
||||
* to the user. If value is negative, timeout is infinite. */
|
||||
int timeout);
|
||||
|
||||
|
||||
@ -2185,7 +2185,7 @@ EXPORT_SPEC int UpnpReadHttpGet(
|
||||
size_t *size,
|
||||
/*! [in] The time out value sent with the request during which a response is
|
||||
* expected from the server, failing which, an error is reported back to
|
||||
* the user. */
|
||||
* the user. If value is negative, timeout is infinite. */
|
||||
int timeout);
|
||||
|
||||
|
||||
@ -2268,7 +2268,8 @@ EXPORT_SPEC int UpnpOpenHttpPost(
|
||||
/*! [in] The length of the content, in bytes, being posted. */
|
||||
int contentLength,
|
||||
/*! [in] The time out value sent with the request during which a response
|
||||
* is expected from the receiver, failing which, an error is reported. */
|
||||
* is expected from the receiver, failing which, an error is reported.
|
||||
* If value is negative, timeout is infinite. */
|
||||
int timeout);
|
||||
|
||||
|
||||
@ -2294,7 +2295,8 @@ EXPORT_SPEC int UpnpWriteHttpPost(
|
||||
/*! [in] The size, in bytes of \b buf. */
|
||||
unsigned int *size,
|
||||
/*! [in] A timeout value sent with the request during which a response is
|
||||
* expected from the server, failing which, an error is reported. */
|
||||
* expected from the server, failing which, an error is reported. If
|
||||
* value is negative, timeout is infinite. */
|
||||
int timeout);
|
||||
|
||||
|
||||
@ -2318,7 +2320,8 @@ EXPORT_SPEC int UpnpCloseHttpPost(
|
||||
/*! [in,out] A pointer to a buffer to store the final status of the connection. */
|
||||
int *httpStatus,
|
||||
/*! [in] A time out value sent with the request during which a response is
|
||||
* expected from the server, failing which, an error is reported. */
|
||||
* expected from the server, failing which, an error is reported. If
|
||||
* value is negative, timeout is infinite. */
|
||||
int timeout);
|
||||
|
||||
|
||||
|
@ -1324,7 +1324,7 @@ static int http_RecvPostMessage(
|
||||
{
|
||||
unsigned int Data_Buf_Size = 1024;
|
||||
char Buf[1024];
|
||||
int Timeout = 0;
|
||||
int Timeout = -1;
|
||||
long Num_Write = 0;
|
||||
FILE *Fp;
|
||||
parse_status_t status = PARSE_OK;
|
||||
@ -1456,7 +1456,7 @@ void web_server_callback(http_parser_t *parser, INOUT http_message_t *req,
|
||||
SOCKINFO *info)
|
||||
{
|
||||
int ret;
|
||||
int timeout = 0;
|
||||
int timeout = -1;
|
||||
enum resp_type rtype = 0;
|
||||
membuffer headers;
|
||||
membuffer filename;
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user