Commit 2f6f4367cdd3a9f9095379fabe9a510eecab387a
1 parent
340a3c11
some fixes in socket condition detection
Showing
2 changed files
with
15 additions
and
7 deletions
| @@ -57,7 +57,8 @@ TR_socketRecv(void * _this, size_t size) | @@ -57,7 +57,8 @@ TR_socketRecv(void * _this, size_t size) | ||
| 57 | 57 | ||
| 58 | if (! remote_data) { | 58 | if (! remote_data) { |
| 59 | switch (errno) { | 59 | switch (errno) { |
| 60 | - case (EAGAIN|EWOULDBLOCK): | 60 | + case EAGAIN: |
| 61 | + // case EWOULDBLOCK: // is the same value as EAGAIN | ||
| 61 | TR_delete(remote_data); | 62 | TR_delete(remote_data); |
| 62 | return TR_emptyRemoteData; | 63 | return TR_emptyRemoteData; |
| 63 | 64 | ||
| @@ -96,17 +97,25 @@ TR_socketSend(void * _this, TR_RemoteData data) | @@ -96,17 +97,25 @@ TR_socketSend(void * _this, TR_RemoteData data) | ||
| 96 | // of the whole application... | 97 | // of the whole application... |
| 97 | return -1; | 98 | return -1; |
| 98 | 99 | ||
| 99 | - case (EAGAIN|EWOULDBLOCK): | 100 | + case EAGAIN: |
| 101 | + //case EWOULDBLOCK: // is the same value as EAGAIN | ||
| 100 | return FALSE; | 102 | return FALSE; |
| 101 | 103 | ||
| 104 | + default: | ||
| 102 | case ECONNRESET: | 105 | case ECONNRESET: |
| 106 | + case EPIPE: | ||
| 103 | // this is a remote close... | 107 | // this is a remote close... |
| 104 | return -2; | 108 | return -2; |
| 105 | - | ||
| 106 | - default: | ||
| 107 | - return -2; | ||
| 108 | } | 109 | } |
| 109 | - } | 110 | + } else if (size == 0) { |
| 111 | + /* | ||
| 112 | + * It might happen that a write returns 0. In that case the remote | ||
| 113 | + * end was not ready to accept the data. This might be handled | ||
| 114 | + * differently by the managing code so I return a separate value | ||
| 115 | + * for this. | ||
| 116 | + */ | ||
| 117 | + return -3; | ||
| 118 | + } | ||
| 110 | 119 | ||
| 111 | return size; | 120 | return size; |
| 112 | } | 121 | } |
| @@ -54,7 +54,6 @@ TR_socketAccept(TR_TcpSocket this) | @@ -54,7 +54,6 @@ TR_socketAccept(TR_TcpSocket this) | ||
| 54 | //fcntl(remote->handle, F_SETFL, flags | O_NONBLOCK); | 54 | //fcntl(remote->handle, F_SETFL, flags | O_NONBLOCK); |
| 55 | 55 | ||
| 56 | if (-1 == remote->handle) { | 56 | if (-1 == remote->handle) { |
| 57 | - perror("accept"); | ||
| 58 | TR_delete(remote); | 57 | TR_delete(remote); |
| 59 | } else { | 58 | } else { |
| 60 | TR_socketAddrIpStr(remote, remote->host, TR_MAX_HOST); | 59 | TR_socketAddrIpStr(remote, remote->host, TR_MAX_HOST); |
Please
register
or
login
to post a comment