From: Adrian Bondrescu Date: Fri, 1 Jun 2012 02:11:42 +0000 (+0300) Subject: Tentative fix for the RecvFrom function. X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=93cdd6985320d3cf133ee08fde64dafa04d2d1b6;hp=76819a02188af33c0093cf776c4b86bfaf18d4fb;p=swifty.git Tentative fix for the RecvFrom function. --- diff --git a/src/libswift/channel.cpp b/src/libswift/channel.cpp index 2d9640c..5313095 100644 --- a/src/libswift/channel.cpp +++ b/src/libswift/channel.cpp @@ -322,9 +322,13 @@ int Channel::RecvFrom (evutil_socket_t sock, Address& addr, struct evbuffer **ev print_error("error on recv"); } length = 0; + printf("Received from %d addresses in one system call.\n", addr.addr->count); for (int i=0; icount; ++i) { - length += iov[i].iov_len; - vec[i].iov_len = iov[i].iov_len; + struct in_addr aux; + aux.s_addr = addr.addr->dests[i].addr; + printf("Received from %s, %d bytes\n", inet_ntoa(aux), addr.addr->dests[i].bytes); + length += addr.addr->dests[i].bytes; + vec[i].iov_len = addr.addr->dests[i].bytes; if (evbuffer_commit_space(evb[i], &vec[i], 1) < 0) { length = 0; print_error("error on evbuffer_commit_space"); diff --git a/src/libswift/sendrecv.cpp b/src/libswift/sendrecv.cpp index 6676913..5ea0fc7 100644 --- a/src/libswift/sendrecv.cpp +++ b/src/libswift/sendrecv.cpp @@ -914,7 +914,7 @@ void Channel::LibeventReceiveCallback(evutil_socket_t fd, short event, void *arg event_add(&evrecv, NULL); } -#define NUM_DATAGRAMS 1 +#define NUM_DATAGRAMS 10 void Channel::RecvDatagram (evutil_socket_t socket) { struct evbuffer *pevb[NUM_DATAGRAMS]; @@ -927,7 +927,6 @@ void Channel::RecvDatagram (evutil_socket_t socket) { addr.addr->count = NUM_DATAGRAMS; RecvFrom(socket, addr, pevb); int i = 0; - printf("Got %d addresses\n", addr.addr->count); for (; icount; ++i) { struct evbuffer *evb = pevb[i]; Address fromi;