trawick 01/03/31 05:25:46
Modified: include/arch/unix networkio.h
network_io/unix sendrecv.c sockets.c
Log:
apr_recvfrom() should only return APR_EOF if recvfrom() returned
zero *AND* this is a stream socket.
rc zero from a datagram socket just means that somebody sent you
a zero-byte datagram.
Remove the minimal parm checking from recvfrom()... better to
segfault as with most of the rest of APR.
Revision Changes Path
1.40 +1 -0 apr/include/arch/unix/networkio.h
Index: networkio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/networkio.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- networkio.h 2001/03/22 21:50:06 1.39
+++ networkio.h 2001/03/31 13:25:45 1.40
@@ -122,6 +122,7 @@
struct apr_socket_t {
apr_pool_t *cntxt;
int socketdes;
+ int type;
apr_sockaddr_t *local_addr;
apr_sockaddr_t *remote_addr;
apr_interval_time_t timeout;
1.64 +1 -8 apr/network_io/unix/sendrecv.c
Index: sendrecv.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sendrecv.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- sendrecv.c 2001/03/14 04:03:59 1.63
+++ sendrecv.c 2001/03/31 13:25:45 1.64
@@ -193,13 +193,6 @@
{
ssize_t rv;
- if (from == NULL){
- return APR_ENOMEM;
- /* Not sure if this is correct. Maybe we should just allocate
- the memory??
- */
- }
-
do {
rv = recvfrom(sock->socketdes, buf, (*len), flags,
(struct sockaddr*)&from->sa, &from->salen);
@@ -224,7 +217,7 @@
}
(*len) = rv;
- if (rv == 0)
+ if (rv == 0 && sock->type == SOCK_STREAM)
return APR_EOF;
return APR_SUCCESS;
1.72 +8 -5 apr/network_io/unix/sockets.c
Index: sockets.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- sockets.c 2001/02/16 04:16:02 1.71
+++ sockets.c 2001/03/31 13:25:45 1.72
@@ -72,8 +72,9 @@
}
}
-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;
@@ -152,7 +153,7 @@
if ((*new)->socketdes < 0) {
return errno;
}
- set_socket_vars(*new, family);
+ set_socket_vars(*new, family, type);
(*new)->timeout = -1;
apr_pool_cleanup_register((*new)->cntxt, (void *)(*new),
@@ -198,7 +199,7 @@
apr_status_t apr_accept(apr_socket_t **new, apr_socket_t *sock, 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);
#ifndef HAVE_POLL
(*new)->connected = 1;
@@ -305,7 +306,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)->socketdes = *os_sock_info->os_sock;
if (os_sock_info->local) {
@@ -337,7 +338,9 @@
if ((*sock) == NULL) {
alloc_socket(sock, cont);
/* XXX IPv6 figure out the family here! */
- set_socket_vars(*sock, APR_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, APR_INET, SOCK_STREAM);
(*sock)->timeout = -1;
}
(*sock)->local_port_unknown = (*sock)->local_interface_unknown = 1;