=> 9554ca7cc8b26c328d870760f3aaac4e701ba7ed
[1mdiff --git a/src/platform/posix/socket.c b/src/platform/posix/socket.c[m [1mindex 5dcaed0..047ce16 100644[m [1m--- a/src/platform/posix/socket.c[m [1m+++ b/src/platform/posix/socket.c[m [36m@@ -128,10 +128,32 @@[m [mstatic iThreadResult run_SocketThread_(iThread *thread) {[m if (FD_ISSET(output_Pipe(&d->wakeup), &reads)) {[m readByte_Pipe(&d->wakeup);[m }[m [32m+[m[32m /* Check for incoming data. */[m [32m+[m[32m if (FD_ISSET(d->socket->fd, &reads)) {[m [32m+[m[32m ssize_t readSize = recv(d->socket->fd, data_Block(inbuf), size_Block(inbuf), 0);[m [32m+[m[32m if (readSize == 0) {[m [32m+[m[32m iWarning("[Socket] peer closed the connection while we were receiving\n");[m [32m+[m[32m shutdown_Socket_(d->socket);[m [32m+[m[32m return 0;[m [32m+[m[32m }[m [32m+[m[32m if (readSize == -1) {[m [32m+[m[32m if (status_Socket(d->socket) == connected_SocketStatus) {[m [32m+[m[32m iWarning("[Socket] error when receiving: %s\n", strerror(errno));[m [32m+[m[32m shutdown_Socket_(d->socket);[m [32m+[m[32m return errno;[m [32m+[m[32m }[m [32m+[m[32m /* This was expected. */[m [32m+[m[32m return 0;[m [32m+[m[32m }[m [32m+[m[32m iGuardMutex(smx, {[m [32m+[m[32m writeData_Buffer(d->socket->input, constData_Block(inbuf), readSize);[m [32m+[m[32m });[m [32m+[m[32m iNotifyAudience(d->socket, readyRead, SocketReadyRead);[m [32m+[m[32m }[m /* Problem with the socket? */[m if (FD_ISSET(d->socket->fd, &errors)) {[m if (status_Socket(d->socket) == connected_SocketStatus) {[m [31m- iWarning("[Socket] error when receiving: %s\n", strerror(errno));[m [32m+[m[32m iWarning("[Socket] error while receiving: %s\n", strerror(errno));[m shutdown_Socket_(d->socket);[m return errno;[m }[m [36m@@ -154,9 +176,12 @@[m [mstatic iThreadResult run_SocketThread_(iThread *thread) {[m ssize_t sent = send(d->socket->fd, ptr, remaining, 0);[m if (sent == -1) {[m /* Error! */[m [31m- delete_Block(data);[m [31m- shutdown_Socket_(d->socket);[m [31m- return errno;[m [32m+[m[32m iWarning("[Socket] peer closed the connection while we were sending "[m [32m+[m[32m "(errno:%d)\n", errno);[m [32m+[m[32m /* Don't quit immediately because we need to see if something was received. */[m [32m+[m[32m /* TODO: Need to set the Socket in a fail state, though?[m [32m+[m[32m Now we're assuming that the error will be noticed later. */[m [32m+[m[32m break;[m }[m remaining -= sent;[m ptr += sent;[m [36m@@ -175,28 +200,6 @@[m [mstatic iThreadResult run_SocketThread_(iThread *thread) {[m }[m });[m }[m [31m- /* Check for incoming data. */[m [31m- if (FD_ISSET(d->socket->fd, &reads)) {[m [31m- ssize_t readSize = recv(d->socket->fd, data_Block(inbuf), size_Block(inbuf), 0);[m [31m- if (readSize == 0) {[m [31m- iWarning("[Socket] peer closed the connection\n");[m [31m- shutdown_Socket_(d->socket);[m [31m- return 0;[m [31m- }[m [31m- if (readSize == -1) {[m [31m- if (status_Socket(d->socket) == connected_SocketStatus) {[m [31m- iWarning("[Socket] error when receiving: %s\n", strerror(errno));[m [31m- shutdown_Socket_(d->socket);[m [31m- return errno;[m [31m- }[m [31m- /* This was expected. */[m [31m- return 0;[m [31m- }[m [31m- iGuardMutex(smx, {[m [31m- writeData_Buffer(d->socket->input, constData_Block(inbuf), readSize);[m [31m- });[m [31m- iNotifyAudience(d->socket, readyRead, SocketReadyRead);[m [31m- }[m }[m return 0;[m }[m
text/gemini; charset=utf-8
This content has been proxied by September (ba2dc).