trawick 01/04/02 16:58:38
Modified: include/arch/win32 networkio.h
network_io/win32 sendrecv.c sockets.c
Log:
fix apr_recvfrom() on Win32 so that it returns APR_EOF only for a
stream socket
Revision Changes Path
1.18 +1 -0 apr/include/arch/win32/networkio.h
Index: networkio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/win32/networkio.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- networkio.h 2001/02/16 04:15:52 1.17
+++ networkio.h 2001/04/02 23:58:36 1.18
@@ -61,6 +61,7 @@
struct apr_socket_t {
apr_pool_t *cntxt;
SOCKET sock;
+ int type; /* SOCK_STREAM, SOCK_DGRAM */
apr_sockaddr_t *local_addr;
apr_sockaddr_t *remote_addr;
apr_interval_time_t timeout;
1.37 +1 -9 apr/network_io/win32/sendrecv.c
Index: sendrecv.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/sendrecv.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- sendrecv.c 2001/04/02 17:54:01 1.36
+++ sendrecv.c 2001/04/02 23:58:37 1.37
@@ -179,22 +179,14 @@
{
apr_ssize_t rv;
- if (from == NULL){
- return APR_ENOMEM;
- /* Not sure if this is correct. Maybe we should just allocate
- the memory??
- */
- }
-
rv = recvfrom(sock->sock, buf, (*len), flags,
(struct sockaddr*)&from->sa, &from->salen);
if (rv == SOCKET_ERROR) {
(*len) = 0;
return apr_get_netos_error();
}
-
(*len) = rv;
- if (rv == 0)
+ if (rv == 0 && sock->type == SOCK_STREAM)
return APR_EOF;
return APR_SUCCESS;
1.53 +8 -5 apr/network_io/win32/sockets.c
Index: sockets.c
===================================================================
RCS file: /home/cvs/apr/network_io/win32/sockets.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- sockets.c 2001/03/31 18:58:16 1.52
+++ sockets.c 2001/04/02 23:58:37 1.53
@@ -72,8 +72,9 @@
return APR_SUCCESS;
}
-static void set_socket_vars(apr_socket_t *sock, int family)
+static void set_socket_vars(apr_socket_t *sock, int family, int type)
{
+ sock->type = type;
sock->local_addr->sa.sin.sin_family = family;
sock->remote_addr->sa.sin.sin_family = family;
@@ -150,7 +151,7 @@
if ((*new)->sock == INVALID_SOCKET) {
return apr_get_netos_error();
}
- set_socket_vars(*new, AF_INET);
+ set_socket_vars(*new, AF_INET, type);
(*new)->timeout = -1;
(*new)->disconnected = 0;
@@ -222,7 +223,7 @@
apr_pool_t *connection_context)
{
alloc_socket(new, connection_context);
- set_socket_vars(*new, sock->local_addr->sa.sin.sin_family);
+ set_socket_vars(*new, sock->local_addr->sa.sin.sin_family, SOCK_STREAM);
(*new)->timeout = -1;
(*new)->disconnected = 0;
@@ -326,7 +327,7 @@
apr_pool_t *cont)
{
alloc_socket(apr_sock, cont);
- set_socket_vars(*apr_sock, os_sock_info->family);
+ set_socket_vars(*apr_sock, os_sock_info->family, os_sock_info->type);
(*apr_sock)->timeout = -1;
(*apr_sock)->disconnected = 0;
(*apr_sock)->sock = *os_sock_info->os_sock;
@@ -358,7 +359,9 @@
{
if ((*sock) == NULL) {
alloc_socket(sock, cont);
- set_socket_vars(*sock, AF_INET);
+ /* XXX figure out the actual socket type here */
+ /* *or* just decide that apr_os_sock_put() has to be told the family
and type */
+ set_socket_vars(*sock, AF_INET, SOCK_STREAM);
(*sock)->timeout = -1;
(*sock)->disconnected = 0;
}