aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorMartin Peach <mrpeach@users.sourceforge.net>2009-03-02 17:01:36 +0000
committerMartin Peach <mrpeach@users.sourceforge.net>2009-03-02 17:01:36 +0000
commitaea687c3034b7d68e1aa8b476340a6dfef4318ac (patch)
tree675099a2ac73d5defb984ff17f78c3817ea2e110 /net
parent4fd4a8e393efd1c5ec6fbeaa3f5a7ff4706e0d28 (diff)
Fixed a bug that prevented the send routine from leaving the loop when no more data can be sent.
Now it won't hang if you try sending to a recently disconnected client, honest! svn path=/trunk/externals/mrpeach/; revision=10828
Diffstat (limited to 'net')
-rw-r--r--net/tcpserver.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/tcpserver.c b/net/tcpserver.c
index 48f55a1..9b7ef4e 100644
--- a/net/tcpserver.c
+++ b/net/tcpserver.c
@@ -415,6 +415,7 @@ static size_t tcpserver_send_buf(int client, int sockfd, char *byte_buf, size_t
bp += result;
}
}
+ else return sent;/* abandon any further attempts to send so we don't block */
}
return sent;
}
@@ -607,11 +608,15 @@ static int tcpserver_set_socket_send_buf_size(int sockfd, int size)
int optLen = sizeof(int);
#ifdef MSW
if (setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char*)&optVal, optLen) == SOCKET_ERROR)
+ {
post("%s_set_socket_send_buf_size: setsockopt returned %d\n", objName, WSAGetLastError());
#else
if (setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char*)&optVal, optLen) == -1)
+ {
post("%s_set_socket_send_buf_size: setsockopt returned %d\n", objName, errno);
#endif
+ return 0;
+ }
else return (tcpserver_get_socket_send_buf_size(sockfd));
}