Browse Source

some fixes in socket condition detection

1.0.0
Georg Hopp 11 years ago
parent
commit
2f6f4367cd
  1. 21
      src/i_socket.c
  2. 1
      src/socket_accept.c

21
src/i_socket.c

@ -57,7 +57,8 @@ TR_socketRecv(void * _this, size_t size)
if (! remote_data) {
switch (errno) {
case (EAGAIN|EWOULDBLOCK):
case EAGAIN:
// case EWOULDBLOCK: // is the same value as EAGAIN
TR_delete(remote_data);
return TR_emptyRemoteData;
@ -96,17 +97,25 @@ TR_socketSend(void * _this, TR_RemoteData data)
// of the whole application...
return -1;
case (EAGAIN|EWOULDBLOCK):
case EAGAIN:
//case EWOULDBLOCK: // is the same value as EAGAIN
return FALSE;
default:
case ECONNRESET:
case EPIPE:
// this is a remote close...
return -2;
default:
return -2;
}
}
} else if (size == 0) {
/*
* It might happen that a write returns 0. In that case the remote
* end was not ready to accept the data. This might be handled
* differently by the managing code so I return a separate value
* for this.
*/
return -3;
}
return size;
}

1
src/socket_accept.c

@ -54,7 +54,6 @@ TR_socketAccept(TR_TcpSocket this)
//fcntl(remote->handle, F_SETFL, flags | O_NONBLOCK);
if (-1 == remote->handle) {
perror("accept");
TR_delete(remote);
} else {
TR_socketAddrIpStr(remote, remote->host, TR_MAX_HOST);

Loading…
Cancel
Save