Browse Source

distinguish close and EAGAIN

1.0.0
Georg Hopp 11 years ago
parent
commit
485a4cff4f
  1. 4
      src/i_socket.c
  2. 2
      src/tcp_socket.c

4
src/i_socket.c

@ -55,7 +55,7 @@ TR_socketRecv(void * _this, size_t size)
TR_RETCALL(_this, TR_Socket, recv, remote_data, size);
if (((TR_SizedData)remote_data)->size < 0) {
if (! remote_data) {
switch (errno) {
case (EAGAIN|EWOULDBLOCK):
TR_delete(remote_data);
@ -75,7 +75,7 @@ TR_socketRecv(void * _this, size_t size)
} else if (((TR_SizedData)remote_data)->size == 0) {
// this is a remote close...
TR_delete(remote_data);
return NULL;
return (void*)-1;
}
return remote_data;

2
src/tcp_socket.c

@ -96,7 +96,7 @@ tcpSocketRecv(TR_Socket this, size_t size)
received = recv(this->handle, buffer, size, this->flags);
if (-1 == received) {
rdata = TR_new(TR_RemoteData, NULL, received, this);
rdata = NULL;
} else {
rdata = TR_new(TR_RemoteData, buffer, received, this);
}

Loading…
Cancel
Save