gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 03/04: mhd_send: more detailed error results


From: gnunet
Subject: [libmicrohttpd] 03/04: mhd_send: more detailed error results
Date: Sun, 18 Apr 2021 19:49:54 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit c5b661b67239534f976da20f95a4f0ff53e7700e
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Apr 18 17:13:01 2021 +0300

    mhd_send: more detailed error results
---
 src/microhttpd/connection.h  | 10 ++++++++++
 src/microhttpd/mhd_send.c    | 46 ++++++++++++++++++++++++++++++++++++++------
 src/microhttpd/mhd_sockets.h | 10 ++++++++--
 3 files changed, 58 insertions(+), 8 deletions(-)

diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h
index 8b1a0946..f7d7b17a 100644
--- a/src/microhttpd/connection.h
+++ b/src/microhttpd/connection.h
@@ -61,6 +61,16 @@
  */
 #define MHD_ERR_INVAL_ (-3078)
 
+/**
+ * Argument values are not supported
+ */
+#define MHD_ERR_OPNOTSUPP_ (-3079)
+
+/**
+ * Socket is shut down for writing or no longer connected
+ */
+#define MHD_ERR_PIPE_ (-3080)
+
 
 /**
  * Set callbacks for this connection to those for HTTP.
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index a1c50917..049034c9 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -789,6 +789,8 @@ MHD_send_data_ (struct MHD_Connection *connection,
       return MHD_ERR_AGAIN_;
     if ( (GNUTLS_E_ENCRYPTION_FAILED == ret) ||
          (GNUTLS_E_INVALID_SESSION == ret) )
+      return MHD_ERR_INVAL_;
+    if (GNUTLS_E_PREMATURE_TERMINATION == ret)
       return MHD_ERR_CONNRESET_;
     if (GNUTLS_E_MEMORY_ERROR == ret)
       return MHD_ERR_NOMEM_;
@@ -841,11 +843,21 @@ MHD_send_data_ (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_;
+      if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EPIPE_))
+        return MHD_ERR_PIPE_;
+      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_;
-      /* Treat any other error as hard error. */
+      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_;
     }
 #if EPOLL_SUPPORT
@@ -1075,11 +1087,21 @@ MHD_send_hdr_and_body_ (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_;
+    if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_EPIPE_))
+      return MHD_ERR_PIPE_;
+    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_;
-    /* Treat any other error as hard error. */
+    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_;
   }
 #if EPOLL_SUPPORT
@@ -1439,9 +1461,21 @@ send_iov_nontls (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_EPIPE_))
+      return MHD_ERR_PIPE_;
+    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_;
   }
 
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index 5e82faa6..56ea64db 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -557,6 +557,11 @@ typedef int MHD_SCKT_SEND_SIZE_;
 #  else  /* ! EINVAL */
 #    define MHD_SCKT_EINVAL_      MHD_SCKT_MISSING_ERR_CODE_
 #  endif /* ! EINVAL */
+#  ifdef EPIPE
+#    define MHD_SCKT_EPIPE_       EPIPE
+#  else  /* ! EPIPE */
+#    define MHD_SCKT_EPIPE_       MHD_SCKT_MISSING_ERR_CODE_
+#  endif /* ! EPIPE */
 #  ifdef EFAULT
 #    define MHD_SCKT_EFAUL_       EFAULT
 #  else  /* ! EFAULT */
@@ -568,9 +573,9 @@ typedef int MHD_SCKT_SEND_SIZE_;
 #    define MHD_SCKT_ENOSYS_      MHD_SCKT_MISSING_ERR_CODE_
 #  endif /* ! ENOSYS */
 #  ifdef ENOPROTOOPT
-#    define MHD_SCKT_ENOPROTOOPT_       ENOPROTOOPT
+#    define MHD_SCKT_ENOPROTOOPT_      ENOPROTOOPT
 #  else  /* ! ENOPROTOOPT */
-#    define MHD_SCKT_ENOSYS_      MHD_SCKT_MISSING_ERR_CODE_
+#    define MHD_SCKT_ENOPROTOOPT_      MHD_SCKT_MISSING_ERR_CODE_
 #  endif /* ! ENOPROTOOPT */
 #  ifdef ENOTSUP
 #    define MHD_SCKT_ENOTSUP_     ENOTSUP
@@ -606,6 +611,7 @@ typedef int MHD_SCKT_SEND_SIZE_;
 #  define MHD_SCKT_EBADF_         WSAEBADF
 #  define MHD_SCKT_ENOTSOCK_      WSAENOTSOCK
 #  define MHD_SCKT_EINVAL_        WSAEINVAL
+#  define MHD_SCKT_EPIPE_         WSAESHUTDOWN
 #  define MHD_SCKT_EFAUL_         WSAEFAULT
 #  define MHD_SCKT_ENOSYS_        MHD_SCKT_MISSING_ERR_CODE_
 #  define MHD_SCKT_ENOPROTOOPT_   WSAENOPROTOOPT

-- 
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]