From 9554ca7cc8b26c328d870760f3aaac4e701ba7ed Mon Sep 17 00:00:00 2001

From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi

Date: Tue, 2 Nov 2021 18:53:30 +0200

Subject: [PATCH 1/1] Socket: Handling error while sending

If the peer closes the socket while we were still sending, it was possible that anything that the peer received was not read at all.

Now we keep reading (and failing to send) until the peer's response has been fully read.


src/platform/posix/socket.c | 55 +++++++++++++++++++------------------

1 file changed, 29 insertions(+), 26 deletions(-)

diff --git a/src/platform/posix/socket.c b/src/platform/posix/socket.c

index 5dcaed0..047ce16 100644

--- a/src/platform/posix/socket.c

+++ b/src/platform/posix/socket.c

@@ -128,10 +128,32 @@ static iThreadResult run_SocketThread_(iThread *thread) {

     if (FD_ISSET(output_Pipe(&d->wakeup), &reads)) {

         readByte_Pipe(&d->wakeup);

     }

     /* Problem with the socket? */

     if (FD_ISSET(d->socket->fd, &errors)) {

         if (status_Socket(d->socket) == connected_SocketStatus) {

             shutdown_Socket_(d->socket);

             return errno;

         }

@@ -154,9 +176,12 @@ static iThreadResult run_SocketThread_(iThread *thread) {

                 ssize_t sent = send(d->socket->fd, ptr, remaining, 0);

                 if (sent == -1) {

                     /* Error! */

                 }

                 remaining -= sent;

                 ptr += sent;

@@ -175,28 +200,6 @@ static iThreadResult run_SocketThread_(iThread *thread) {

             }

         });

     }

 }

 return 0;

}

--

2.25.1

Proxy Information
Original URL
gemini://git.skyjake.fi/the_Foundation/master/patch/9554ca7cc8b26c328d870760f3aaac4e701ba7ed.patch
Status Code
Success (20)
Meta
text/plain
Capsule Response Time
23.444285 milliseconds
Gemini-to-HTML Time
1.153749 milliseconds

This content has been proxied by September (ba2dc).