Commit 8332e25b authored by Ian Craggs's avatar Ian Craggs

Fix for issue #186

parent 475992f1
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* Ian Craggs - fix for bug 484496 * Ian Craggs - fix for bug 484496
* Juergen Kosel, Ian Craggs - fix for issue #135 * Juergen Kosel, Ian Craggs - fix for issue #135
* Ian Craggs - issue #217 * Ian Craggs - issue #217
* Ian Craggs - fix for issue #186
*******************************************************************************/ *******************************************************************************/
/** /**
...@@ -171,6 +172,13 @@ int Socket_addSocket(int newSd) ...@@ -171,6 +172,13 @@ int Socket_addSocket(int newSd)
FUNC_ENTRY; FUNC_ENTRY;
if (ListFindItem(s.clientsds, &newSd, intcompare) == NULL) /* make sure we don't add the same socket twice */ if (ListFindItem(s.clientsds, &newSd, intcompare) == NULL) /* make sure we don't add the same socket twice */
{
if (newSd >= FD_SETSIZE)
{
Log(LOG_ERROR, -1, "addSocket: exceeded FD_SETSIZE %d", FD_SETSIZE);
rc = SOCKET_ERROR;
}
else
{ {
int* pnewSd = (int*)malloc(sizeof(newSd)); int* pnewSd = (int*)malloc(sizeof(newSd));
*pnewSd = newSd; *pnewSd = newSd;
...@@ -178,6 +186,9 @@ int Socket_addSocket(int newSd) ...@@ -178,6 +186,9 @@ int Socket_addSocket(int newSd)
FD_SET(newSd, &(s.rset_saved)); FD_SET(newSd, &(s.rset_saved));
s.maxfdp1 = max(s.maxfdp1, newSd + 1); s.maxfdp1 = max(s.maxfdp1, newSd + 1);
rc = Socket_setnonblocking(newSd); rc = Socket_setnonblocking(newSd);
if (rc == SOCKET_ERROR)
Log(LOG_ERROR, -1, "addSocket: setnonblocking");
}
} }
else else
Log(LOG_ERROR, -1, "addSocket: socket %d already in the list", newSd); Log(LOG_ERROR, -1, "addSocket: socket %d already in the list", newSd);
...@@ -671,7 +682,7 @@ int Socket_new(char* addr, int port, int* sock) ...@@ -671,7 +682,7 @@ int Socket_new(char* addr, int port, int* sock)
Log(TRACE_MIN, -1, "New socket %d for %s, port %d", *sock, addr, port); Log(TRACE_MIN, -1, "New socket %d for %s, port %d", *sock, addr, port);
if (Socket_addSocket(*sock) == SOCKET_ERROR) if (Socket_addSocket(*sock) == SOCKET_ERROR)
rc = Socket_error("setnonblocking", *sock); rc = Socket_error("addSocket", *sock);
else else
{ {
/* this could complete immmediately, even though we are non-blocking */ /* this could complete immmediately, even though we are non-blocking */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment