[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated: mhd_send: finally handle sockets
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated: mhd_send: finally handle sockets errors in portable way |
Date: |
Fri, 16 Apr 2021 17:04:46 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
The following commit(s) were added to refs/heads/master by this push:
new 99f2df6d mhd_send: finally handle sockets errors in portable way
99f2df6d is described below
commit 99f2df6dea40624ff82b00ebe362e587f722985f
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Fri Apr 16 17:58:14 2021 +0300
mhd_send: finally handle sockets errors in portable way
---
src/microhttpd/mhd_send.c | 72 ++++++++++++++++++--------------------------
src/microhttpd/mhd_sockets.h | 6 ++++
2 files changed, 36 insertions(+), 42 deletions(-)
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index 02079c03..793df8d0 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -186,15 +186,17 @@ MHD_connection_set_nodelay_state_ (struct MHD_Connection
*connection,
connection->sk_nodelay = nodelay_state;
return true;
}
+
err_code = MHD_socket_get_error_ ();
- switch (err_code)
+ if (MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_EINVAL_) ||
+ MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_ENOPROTOOPT_) ||
+ MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_ENOTSOCK_))
{
- case EINVAL:
- case ENOPROTOOPT:
- case ENOTSOCK:
- if (_MHD_NO == connection->is_nonip)
- {
+ if (_MHD_UNKNOWN == connection->is_nonip)
+ connection->is_nonip = _MHD_YES;
#ifdef HAVE_MESSAGES
+ else
+ {
MHD_DLOG (connection->daemon,
_ ("Setting %s option to %s state failed "
"for TCP/IP socket %d: %s\n"),
@@ -202,26 +204,20 @@ MHD_connection_set_nodelay_state_ (struct MHD_Connection
*connection,
nodelay_state ? _ ("ON") : _ ("OFF"),
(int) connection->socket_fd,
MHD_socket_strerr_ (err_code));
-#endif /* HAVE_MESSAGES */
}
- else
- connection->is_nonip = _MHD_YES;
- break;
- case EBADF:
- case EFAULT:
- /* Hard errors, something is wrong. Too tricky to
- * break connection here, just log the message.
- * Shound't really happen too often. */
- default:
+#endif /* HAVE_MESSAGES */
+ }
#ifdef HAVE_MESSAGES
+ else
+ {
MHD_DLOG (connection->daemon,
_ ("Setting %s option to %s state failed: %s\n"),
"TCP_NODELAY",
nodelay_state ? _ ("ON") : _ ("OFF"),
MHD_socket_strerr_ (err_code));
-#endif /* HAVE_MESSAGES */
- break;
}
+#endif /* HAVE_MESSAGES */
+
return false;
}
@@ -255,15 +251,17 @@ connection_set_cork_state_ (struct MHD_Connection
*connection,
connection->sk_corked = cork_state;
return true;
}
+
err_code = MHD_socket_get_error_ ();
- switch (err_code)
+ if (MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_EINVAL_) ||
+ MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_ENOPROTOOPT_) ||
+ MHD_SCKT_ERR_IS_ (err_code, MHD_SCKT_ENOTSOCK_))
{
- case EINVAL:
- case ENOPROTOOPT:
- case ENOTSOCK:
- if (_MHD_NO == connection->is_nonip)
- {
+ if (_MHD_UNKNOWN == connection->is_nonip)
+ connection->is_nonip = _MHD_YES;
#ifdef HAVE_MESSAGES
+ else
+ {
MHD_DLOG (connection->daemon,
_ ("Setting %s option to %s state failed "
"for TCP/IP socket %d: %s\n"),
@@ -271,30 +269,20 @@ connection_set_cork_state_ (struct MHD_Connection
*connection,
nodelay_state ? _ ("ON") : _ ("OFF"),
(int) connection->socket_fd,
MHD_socket_strerr_ (err_code));
-#endif /* HAVE_MESSAGES */
}
- else
- connection->is_nonip = _MHD_YES;
- break;
- case EBADF:
- case EFAULT:
- /* Hard errors, something is wrong. Too tricky to
- * break connection here, just log the message.
- * Shound't really happen too often. */
- default:
+#endif /* HAVE_MESSAGES */
+ }
#ifdef HAVE_MESSAGES
+ else
+ {
MHD_DLOG (connection->daemon,
_ ("Setting %s option to %s state failed: %s\n"),
-#ifdef TCP_CORK
- "TCP_CORK",
-#else /* ! TCP_CORK */
- "TCP_NOPUSH",
-#endif /* ! TCP_CORK */
- cork_state ? _ ("ON") : _ ("OFF"),
+ "TCP_NODELAY",
+ nodelay_state ? _ ("ON") : _ ("OFF"),
MHD_socket_strerr_ (err_code));
-#endif /* HAVE_MESSAGES */
- break;
}
+#endif /* HAVE_MESSAGES */
+
return false;
}
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index c22a1b12..b16a8b1a 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -567,6 +567,11 @@ typedef int MHD_SCKT_SEND_SIZE_;
# else /* ! ENOSYS */
# define MHD_SCKT_ENOSYS_ MHD_SCKT_MISSING_ERR_CODE_
# endif /* ! ENOSYS */
+# ifdef ENOPROTOOPT
+# define MHD_SCKT_ENOPROTOOPT_ ENOPROTOOPT
+# else /* ! ENOPROTOOPT */
+# define MHD_SCKT_ENOSYS_ MHD_SCKT_MISSING_ERR_CODE_
+# endif /* ! ENOPROTOOPT */
# ifdef ENOTSUP
# define MHD_SCKT_ENOTSUP_ ENOTSUP
# else /* ! ENOTSUP */
@@ -603,6 +608,7 @@ typedef int MHD_SCKT_SEND_SIZE_;
# define MHD_SCKT_EINVAL_ WSAEINVAL
# define MHD_SCKT_EFAUL_ WSAEFAULT
# define MHD_SCKT_ENOSYS_ MHD_SCKT_MISSING_ERR_CODE_
+# define MHD_SCKT_ENOPROTOOPT_ WSAENOPROTOOPT
# define MHD_SCKT_ENOTSUP_ MHD_SCKT_MISSING_ERR_CODE_
# define MHD_SCKT_EOPNOTSUPP_ WSAEOPNOTSUPP
# define MHD_SCKT_EACCESS_ WSAEACCES
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libmicrohttpd] branch master updated: mhd_send: finally handle sockets errors in portable way,
gnunet <=