diff options
author | LRN <lrn1986@gmail.com> | 2012-11-24 08:08:27 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2012-11-24 08:08:27 +0000 |
commit | ad16d03db236ff504ec7ed2cbd32c5a6653bc315 (patch) | |
tree | 7207acb1021afb13e4a87d1cb76f549606598791 /src/transport/plugin_transport_udp.c | |
parent | b2ee4ce2ebbf50d55b5c6466cc10a406713ca860 (diff) | |
download | gnunet-ad16d03db236ff504ec7ed2cbd32c5a6653bc315.tar.gz gnunet-ad16d03db236ff504ec7ed2cbd32c5a6653bc315.zip |
Be more specific about UDP read failures
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 48ae61230..5396a4bf4 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -2136,14 +2136,32 @@ udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
2136 | (struct sockaddr *) &addr, &fromlen); | 2136 | (struct sockaddr *) &addr, &fromlen); |
2137 | #if MINGW | 2137 | #if MINGW |
2138 | /* On SOCK_DGRAM UDP sockets recvfrom might fail with a | 2138 | /* On SOCK_DGRAM UDP sockets recvfrom might fail with a |
2139 | * WSAECONNRESET error to indicate that previous sendto() (???) | 2139 | * WSAECONNRESET error to indicate that previous sendto() (yes, sendto!) |
2140 | * on this socket has failed. | 2140 | * on this socket has failed. |
2141 | * Quote from MSDN: | ||
2142 | * WSAECONNRESET - The virtual circuit was reset by the remote side | ||
2143 | * executing a hard or abortive close. The application should close | ||
2144 | * the socket; it is no longer usable. On a UDP-datagram socket this | ||
2145 | * error indicates a previous send operation resulted in an ICMP Port | ||
2146 | * Unreachable message. | ||
2141 | */ | 2147 | */ |
2142 | if ( (-1 == size) && (ECONNRESET == errno) ) | 2148 | if ( (-1 == size) && (ECONNRESET == errno) ) |
2143 | return; | 2149 | return; |
2144 | #endif | 2150 | #endif |
2145 | if ( (-1 == size) || (size < sizeof (struct GNUNET_MessageHeader))) | 2151 | if (-1 == size) |
2146 | { | 2152 | { |
2153 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2154 | "UDP failed to receive data: %s\n", STRERROR (errno)); | ||
2155 | /* Connection failure or something. Not a protocol violation. */ | ||
2156 | return; | ||
2157 | } | ||
2158 | if (size < sizeof (struct GNUNET_MessageHeader)) | ||
2159 | { | ||
2160 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
2161 | "UDP got %u bytes, which is not enough for a GNUnet message header\n", | ||
2162 | (unsigned int) size); | ||
2163 | /* _MAY_ be a connection failure (got partial message) */ | ||
2164 | /* But it _MAY_ also be that the other side uses non-GNUnet protocol. */ | ||
2147 | GNUNET_break_op (0); | 2165 | GNUNET_break_op (0); |
2148 | return; | 2166 | return; |
2149 | } | 2167 | } |