gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 03/03: connection: report error details for recv() as we


From: gnunet
Subject: [libmicrohttpd] 03/03: connection: report error details for recv() as well
Date: Mon, 19 Apr 2021 15:26:07 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 523fa712fdc408997f8387c9fef62968c13758f2
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Mon Apr 19 16:22:43 2021 +0300

    connection: report error details for recv() as well
---
 src/microhttpd/connection.c       | 27 +++++++++++++++++++++------
 src/microhttpd/connection_https.c | 23 +++++++++++++++++++++--
 2 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 309683b8..916e75c8 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -208,9 +208,19 @@ recv_param_adapter (struct MHD_Connection *connection,
     }
     if (MHD_SCKT_ERR_IS_EINTR_ (err))
       return MHD_ERR_AGAIN_;
-    if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_))
+    if (MHD_SCKT_ERR_IS_REMOTE_DISCNN_ (err))
       return MHD_ERR_CONNRESET_;
-    /* Treat any other error as hard error. */
+    if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EOPNOTSUPP_))
+      return MHD_ERR_OPNOTSUPP_;
+    if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ENOTCONN_))
+      return MHD_ERR_NOTCONN_;
+    if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EINVAL_))
+      return MHD_ERR_INVAL_;
+    if (MHD_SCKT_ERR_IS_LOW_RESOURCES_ (err))
+      return MHD_ERR_NOMEM_;
+    if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EBADF_))
+      return MHD_ERR_BADF_;
+    /* Treat any other error as a hard error. */
     return MHD_ERR_NOTCONN_;
   }
 #ifdef EPOLL_SUPPORT
@@ -2852,11 +2862,16 @@ MHD_connection_handle_read (struct MHD_Connection 
*connection)
                                 "Socket disconnected while reading request."));
       return;
     }
+
+#ifdef HAVE_MESSAGES
+    if (MHD_CONNECTION_INIT != connection->state)
+      MHD_DLOG (connection->daemon,
+                _ ("Connection socket is closed when reading " \
+                   "request due to the error: %s\n"),
+                str_conn_error_ (bytes_read));
+#endif
     CONNECTION_CLOSE_ERROR (connection,
-                            (MHD_CONNECTION_INIT == connection->state) ?
-                            NULL :
-                            _ (
-                              "Connection socket is closed due to error when 
reading request."));
+                            NULL);
     return;
   }
 
diff --git a/src/microhttpd/connection_https.c 
b/src/microhttpd/connection_https.c
index 3d4b0bdb..0060c59a 100644
--- a/src/microhttpd/connection_https.c
+++ b/src/microhttpd/connection_https.c
@@ -73,9 +73,28 @@ recv_tls_adapter (struct MHD_Connection *connection,
   }
   if (res < 0)
   {
-    /* Likely 'GNUTLS_E_INVALID_SESSION' (client communication
-       disrupted); interpret as a hard error */
     connection->tls_read_ready = false;
+    if ( (GNUTLS_E_DECRYPTION_FAILED == res) ||
+         (GNUTLS_E_INVALID_SESSION == res) ||
+         (GNUTLS_E_DECOMPRESSION_FAILED == res) ||
+         (GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER == res) ||
+         (GNUTLS_E_UNSUPPORTED_VERSION_PACKET == res) ||
+         (GNUTLS_E_UNEXPECTED_PACKET_LENGTH == res) ||
+         (GNUTLS_E_UNEXPECTED_PACKET == res) ||
+         (GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET == res) ||
+         (GNUTLS_E_EXPIRED == res) ||
+         (GNUTLS_E_REHANDSHAKE == res) )
+      return MHD_ERR_TLS_;
+    if ( (GNUTLS_E_PULL_ERROR == res) ||
+         (GNUTLS_E_INTERNAL_ERROR == res) ||
+         (GNUTLS_E_CRYPTODEV_IOCTL_ERROR == res) ||
+         (GNUTLS_E_CRYPTODEV_DEVICE_ERROR == res) )
+      return MHD_ERR_PIPE_;
+    if (GNUTLS_E_PREMATURE_TERMINATION == res)
+      return MHD_ERR_CONNRESET_;
+    if (GNUTLS_E_MEMORY_ERROR == res)
+      return MHD_ERR_NOMEM_;
+    /* Treat any other error as a hard error. */
     return MHD_ERR_NOTCONN_;
   }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]