[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3994 - GNUnet/src/util/network
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3994 - GNUnet/src/util/network |
Date: |
Thu, 21 Dec 2006 14:08:09 -0800 (PST) |
Author: grothoff
Date: 2006-12-21 14:08:06 -0800 (Thu, 21 Dec 2006)
New Revision: 3994
Modified:
GNUnet/src/util/network/io.c
GNUnet/src/util/network/network.h
GNUnet/src/util/network/select.c
Log:
OS X FIONREAD includes IP headers
Modified: GNUnet/src/util/network/io.c
===================================================================
--- GNUnet/src/util/network/io.c 2006-12-21 21:25:40 UTC (rev 3993)
+++ GNUnet/src/util/network/io.c 2006-12-21 22:08:06 UTC (rev 3994)
@@ -105,6 +105,7 @@
ret->ectx = ectx;
ret->mon = mon;
ret->handle = osSocket;
+ ret->checksum = - ret->handle;
return ret;
}
@@ -121,6 +122,7 @@
GE_WARNING | GE_USER | GE_DEVELOPER | GE_BULK,
"close");
s->handle = -1;
+ s->checksum = 1;
}
void socket_destroy(struct SocketHandle * s) {
@@ -144,7 +146,8 @@
#ifdef OSX
static int socket_set_nosigpipe(struct SocketHandle * s,
int dontSigPipe) {
- return setsockopt(s->handle, SOL_SOCKET, SO_NOSIGPIPE,
+ return setsockopt(s->handle,
+ SOL_SOCKET, SO_NOSIGPIPE,
(void *)&dontSigPipe,
sizeof(dontSigPipe));
}
@@ -196,6 +199,7 @@
size_t pos;
size_t ret;
+ GE_ASSERT(NULL, s->checksum == - s->handle);
socket_set_blocking(s,
0 != (nc & NC_Blocking));
flags = 0;
@@ -219,10 +223,13 @@
#endif
pos = 0;
do {
+ GE_ASSERT(NULL, s->checksum == - s->handle);
+ GE_ASSERT(NULL, max > pos);
ret = (size_t) RECV(s->handle,
&((char*)buf)[pos],
max - pos,
flags);
+ GE_ASSERT(NULL, s->checksum == - s->handle);
if ( (ret == (size_t) -1) &&
(errno == EINTR) &&
(0 != (nc & NC_IgnoreInt)) )
@@ -254,6 +261,7 @@
os_network_monitor_notify_transmission(s->mon,
Download,
ret);
+ GE_ASSERT(NULL, pos + ret >= pos);
pos += ret;
} while ( (pos < max) &&
(0 != (nc & NC_Blocking)) );
Modified: GNUnet/src/util/network/network.h
===================================================================
--- GNUnet/src/util/network/network.h 2006-12-21 21:25:40 UTC (rev 3993)
+++ GNUnet/src/util/network/network.h 2006-12-21 22:08:06 UTC (rev 3994)
@@ -36,6 +36,8 @@
int handle;
+ int checksum;
+
} SocketHandle;
#endif
Modified: GNUnet/src/util/network/select.c
===================================================================
--- GNUnet/src/util/network/select.c 2006-12-21 21:25:40 UTC (rev 3993)
+++ GNUnet/src/util/network/select.c 2006-12-21 22:08:06 UTC (rev 3994)
@@ -617,7 +617,8 @@
&size,
clientAddr,
&lenOfIncomingAddr);
- } else if (pending >= 65536) {
+ } else if (pending >= 70000) {
+ /* allowing a bit more for OSX FIONREAD */
GE_BREAK(sh->ectx, 0);
socket_close(sh->listen_sock);
} else {
@@ -626,7 +627,7 @@
msg = MALLOC(pending);
size = 0;
if (YES != socket_recv_from(sh->listen_sock,
- NC_Blocking,
+ NC_Nonblocking,
msg,
pending,
&size,
@@ -644,6 +645,10 @@
/* validate msg format! */
const MESSAGE_HEADER * hdr;
+ /* on OSX, FIONREAD includes IP headers,
+ thus if size < pending, set pending to size */
+ if (size < pending)
+ pending = size;
hdr = (const MESSAGE_HEADER*) msg;
if ( (size == pending) &&
(size >= sizeof(MESSAGE_HEADER)) &&
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3994 - GNUnet/src/util/network,
grothoff <=