[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 133/154: properly handle return value from
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 133/154: properly handle return value from send_on_connection2 |
Date: |
Mon, 19 Aug 2019 10:17:25 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository libmicrohttpd.
commit 8a4aec4d78fe4fb335aede980e8567b8bc51858f
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Aug 1 21:17:46 2019 +0200
properly handle return value from send_on_connection2
---
src/microhttpd/connection.c | 77 ++++++++++++++++++++++++++-------------------
1 file changed, 45 insertions(+), 32 deletions(-)
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index dab28878..67ff6017 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -3180,42 +3180,55 @@ MHD_connection_handle_write (struct MHD_Connection
*connection)
mhd_assert (0);
return;
case MHD_CONNECTION_HEADERS_SENDING:
- /* if the response body is not available, we use
MHD_send_on_connection_() */
- if (NULL != connection->response->crc)
- {
- ret = MHD_send_on_connection_ (connection,
- &connection->write_buffer
-
[connection->write_buffer_send_offset],
-
connection->write_buffer_append_offset -
- connection->write_buffer_send_offset,
- MHD_SSO_MAY_CORK);
- }
- else
- {
- ret = MHD_send_on_connection2_ (connection,
- &connection->write_buffer
-
[connection->write_buffer_send_offset],
-
connection->write_buffer_append_offset -
- connection->write_buffer_send_offset,
- connection->response->data,
-
connection->response->data_buffer_size);
- }
+ {
+ const size_t wb_ready =connection->write_buffer_append_offset -
+ connection->write_buffer_send_offset;
- if (ret < 0)
- {
- if (MHD_ERR_AGAIN_ == ret)
+ /* if the response body is not available, we use
MHD_send_on_connection_() */
+ if (NULL != connection->response->crc)
+ {
+ ret = MHD_send_on_connection_ (connection,
+ &connection->write_buffer
+
[connection->write_buffer_send_offset],
+ wb_ready,
+ MHD_SSO_MAY_CORK);
+ }
+ else
+ {
+ ret = MHD_send_on_connection2_ (connection,
+ &connection->write_buffer
+
[connection->write_buffer_send_offset],
+ wb_ready,
+ connection->response->data,
+
connection->response->data_buffer_size);
+ }
+
+ if (ret < 0)
+ {
+ if (MHD_ERR_AGAIN_ == ret)
+ return;
+ CONNECTION_CLOSE_ERROR (connection,
+ _("Connection was closed while sending
response headers.\n"));
return;
- CONNECTION_CLOSE_ERROR (connection,
- _("Connection was closed while sending
response headers.\n"));
+ }
+ if (ret > wb_ready)
+ {
+ mhd_assert (NULL == connection->repsonse->crc);
+ /* We sent not just header data but also some response data,
+ update both offsets! */
+ connection->write_buffer_send_offset += wb_ready;
+ ret -= wb_ready;
+ connection->response_write_position += ret;
+ }
+ else
+ connection->write_buffer_send_offset += ret;
+ MHD_update_last_activity_ (connection);
+ if (MHD_CONNECTION_HEADERS_SENDING != connection->state)
return;
- }
- connection->write_buffer_send_offset += ret;
- MHD_update_last_activity_ (connection);
- if (MHD_CONNECTION_HEADERS_SENDING != connection->state)
+ check_write_done (connection,
+ MHD_CONNECTION_HEADERS_SENT);
return;
- check_write_done (connection,
- MHD_CONNECTION_HEADERS_SENT);
- return;
+ }
case MHD_CONNECTION_HEADERS_SENT:
return;
case MHD_CONNECTION_NORMAL_BODY_READY:
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [libmicrohttpd] 98/154: simplify, (continued)
- [GNUnet-SVN] [libmicrohttpd] 98/154: simplify, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 104/154: skcork, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 124/154: mhd_send commented,, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 127/154: remove commentblock, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 112/154: configure.ac: define a check for HAVE_SENDMSG, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 121/154: MSG_MORE fix, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 115/154: gitignore build-aux., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 132/154: reduce variable scope, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 131/154: toggle Naggle if and only if corking is not possible by other means, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 126/154: fixes, comments, FIXMEs, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 133/154: properly handle return value from send_on_connection2,
gnunet <=
- [GNUnet-SVN] [libmicrohttpd] 130/154: always set nodelay, except if we cannot cork, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 135/154: add ways for application to control corking for upgraded sockets, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 138/154: mhd_send: fix failure to build, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 136/154: do it in both tests, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 139/154: Rename senfile_adapter to MHD_send_sendfile_ and remove duplicate prototype., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 151/154: mhd_send.c: for now, let EINVAL and EBADF fail hard., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 152/154: connection.c: remove dead code., gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 154/154: Revert "connection.c: remove dead code.", gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 114/154: writev check, gnunet, 2019/08/19
- [GNUnet-SVN] [libmicrohttpd] 144/154: connection.c: remove dead code, gnunet, 2019/08/19