Set sockets non blocking
This commit is contained in:
parent
5672487ede
commit
7f2f0efd55
|
@ -2,6 +2,7 @@ $Id: Changelog.txt,v 1.29 2012/05/23 08:56:35 nanard Exp $
|
|||
|
||||
2012/05/21:
|
||||
Clean signal handling
|
||||
Set sockets non blocking
|
||||
|
||||
2012/05/18:
|
||||
Improve ProcessInterfaceWatch() under BSD.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: ifacewatch.c,v 1.12 2012/05/18 11:46:55 nanard Exp $ */
|
||||
/* $Id: ifacewatch.c,v 1.13 2012/05/21 17:13:11 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* (c) 2011-2012 Thomas Bernard
|
||||
* website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
|
@ -55,9 +55,14 @@ OpenAndConfInterfaceWatchSocket(void)
|
|||
* routing socket open per system. */
|
||||
#endif
|
||||
if(s < 0) {
|
||||
syslog(LOG_ERR, "OpenAndConfInterfaceWatchSocket socket: %m");
|
||||
syslog(LOG_ERR, "%s socket: %m",
|
||||
"OpenAndConfInterfaceWatchSocket");
|
||||
return -1;
|
||||
}
|
||||
if(!set_non_blocking(s)) {
|
||||
syslog(LOG_WARNING, "%s failed to set socket non blocking : %m",
|
||||
"OpenAndConfInterfaceWatchSocket");
|
||||
}
|
||||
#ifdef __linux__
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.nl_family = AF_NETLINK;
|
||||
|
|
|
@ -542,6 +542,8 @@ void processRequest(struct reqelem * req)
|
|||
|
||||
n = read(req->socket, buf, sizeof(buf));
|
||||
if(n<0) {
|
||||
if(errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
return; /* try again later */
|
||||
syslog(LOG_ERR, "(s=%d) processRequest(): read(): %m", req->socket);
|
||||
goto error;
|
||||
}
|
||||
|
@ -1076,6 +1078,8 @@ int main(int argc, char * * argv)
|
|||
else
|
||||
{
|
||||
syslog(LOG_INFO, "(s=%d) new request connection", s);
|
||||
if(!set_non_blocking(s))
|
||||
syslog(LOG_WARNING, "Failed to set new socket non blocking : %m");
|
||||
tmp = malloc(sizeof(struct reqelem));
|
||||
if(!tmp)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: openssdpsocket.c,v 1.11 2012/05/02 23:09:45 nanard Exp $ */
|
||||
/* $Id: openssdpsocket.c,v 1.12 2012/05/21 17:13:11 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2012 Thomas Bernard
|
||||
|
@ -17,6 +17,7 @@
|
|||
#include <syslog.h>
|
||||
|
||||
#include "openssdpsocket.h"
|
||||
#include "upnputils.h"
|
||||
|
||||
/* SSDP ip/port */
|
||||
#define SSDP_PORT (1900)
|
||||
|
@ -165,6 +166,10 @@ OpenAndConfSSDPReceiveSocket(int n_listen_addr,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if(!set_non_blocking(s)) {
|
||||
syslog(LOG_WARNING, "Failed to set SSDP socket non blocking : %m");
|
||||
}
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
memset(&sockname, 0, sizeof(struct sockaddr_storage));
|
||||
if(ipv6)
|
||||
|
|
Loading…
Reference in New Issue