gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] 18/154: more from connection.c, without che


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] 18/154: more from connection.c, without checks so far.
Date: Mon, 19 Aug 2019 10:15:30 +0200

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

ng0 pushed a commit to branch master
in repository libmicrohttpd.

commit 67792e0c74b09848908e0cadcd7e3be89cb1b51d
Author: ng0 <address@hidden>
AuthorDate: Thu Jul 4 12:22:42 2019 +0000

    more from connection.c, without checks so far.
---
 src/microhttpd/mhd_send.c | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 2240ee0c..1cbe2d96 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -84,13 +84,13 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
   int eno, ret, optval;
   const MHD_SCKT_OPT_BOOL_ off_val = 0;
   const MHD_SCKT_OPT_BOOL_ on_val = 1;
+  const int err = MHD_socket_get_error_ ();
 
   // error handling from send_param_adapter()
-  if ( (MHD_INVALID_SOCKET == s) ||
-       (MHD_CONNECTION_CLOSED == connection->state) )
-    {
-      return MHD_ERR_NOTCONN_;
-    }
+  if ((MHD_INVALID_SOCKET == s) || (MHD_CONNECTION_CLOSED == 
connection->state))
+  {
+    return MHD_ERR_NOTCONN_;
+  }
 
   // from send_param_adapter()
   if (buffer_size > MHD_SCKT_SEND_MAX_SIZE_)
@@ -192,6 +192,7 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
   }
 #endif
 
+  // prepare the send() to return.
 #if MSG_MORE
   ret = send (connection->socket_fd,
               buffer,
@@ -200,7 +201,34 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
 #else
   ret = send (connection->socket_fd, buffer, buffer_size, 0);
 #endif
-  eno = errno;
+
+  // shouldn't we return 0 or -1? Why re-use the _ERR_ functions?
+  // error handling from send_param_adapter():
+  if (0 > ret)
+  {
+    if (MHD_SCKT_ERR_IS_EAGAIN_ (err))
+    {
+#if EPOLL_SUPPORT
+      /* EAGAIN, no longer write-ready */
+      connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
+#endif /* EPOLL_SUPPORT */
+      return MHD_ERR_AGAIN_;
+    }
+    if (MHD_SCKT_ERR_IS_EINTR_ (err))
+      return MHD_ERR_AGAIN_;
+    if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_))
+      return MHD_ERR_CONNRESET_;
+    /* Treat any other error as hard error. */
+    return MHD_ERR_NOTCONN_;
+  }
+#if EPOLL_SUPPORT
+  else if (i > (size_t) ret)
+    connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
+#endif /* EPOLL_SUPPORT */
+    //  return ret; // should be return at the end of the function?
+
+    // previous error save:
+    // eno = errno;
 
 #if TCP_CORK
   if (use_corknopush)

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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