aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-07-04 12:22:42 +0000
committerng0 <ng0@n0.is>2019-07-04 12:22:42 +0000
commit67792e0c74b09848908e0cadcd7e3be89cb1b51d (patch)
tree2462326f499edc0f2fa0ca95ed76bc398917b9c7
parent5e99e18f2db625fbe937f99a7f2916e2eee82008 (diff)
downloadlibmicrohttpd-67792e0c74b09848908e0cadcd7e3be89cb1b51d.tar.gz
libmicrohttpd-67792e0c74b09848908e0cadcd7e3be89cb1b51d.zip
more from connection.c, without checks so far.
-rw-r--r--src/microhttpd/mhd_send.c40
1 files 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,
84 int eno, ret, optval; 84 int eno, ret, optval;
85 const MHD_SCKT_OPT_BOOL_ off_val = 0; 85 const MHD_SCKT_OPT_BOOL_ off_val = 0;
86 const MHD_SCKT_OPT_BOOL_ on_val = 1; 86 const MHD_SCKT_OPT_BOOL_ on_val = 1;
87 const int err = MHD_socket_get_error_ ();
87 88
88 // error handling from send_param_adapter() 89 // error handling from send_param_adapter()
89 if ( (MHD_INVALID_SOCKET == s) || 90 if ((MHD_INVALID_SOCKET == s) || (MHD_CONNECTION_CLOSED == connection->state))
90 (MHD_CONNECTION_CLOSED == connection->state) ) 91 {
91 { 92 return MHD_ERR_NOTCONN_;
92 return MHD_ERR_NOTCONN_; 93 }
93 }
94 94
95 // from send_param_adapter() 95 // from send_param_adapter()
96 if (buffer_size > MHD_SCKT_SEND_MAX_SIZE_) 96 if (buffer_size > MHD_SCKT_SEND_MAX_SIZE_)
@@ -192,6 +192,7 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
192 } 192 }
193#endif 193#endif
194 194
195 // prepare the send() to return.
195#if MSG_MORE 196#if MSG_MORE
196 ret = send (connection->socket_fd, 197 ret = send (connection->socket_fd,
197 buffer, 198 buffer,
@@ -200,7 +201,34 @@ MHD_send_on_connection_ (struct MHD_Connection *connection,
200#else 201#else
201 ret = send (connection->socket_fd, buffer, buffer_size, 0); 202 ret = send (connection->socket_fd, buffer, buffer_size, 0);
202#endif 203#endif
203 eno = errno; 204
205 // shouldn't we return 0 or -1? Why re-use the _ERR_ functions?
206 // error handling from send_param_adapter():
207 if (0 > ret)
208 {
209 if (MHD_SCKT_ERR_IS_EAGAIN_ (err))
210 {
211#if EPOLL_SUPPORT
212 /* EAGAIN, no longer write-ready */
213 connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
214#endif /* EPOLL_SUPPORT */
215 return MHD_ERR_AGAIN_;
216 }
217 if (MHD_SCKT_ERR_IS_EINTR_ (err))
218 return MHD_ERR_AGAIN_;
219 if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_))
220 return MHD_ERR_CONNRESET_;
221 /* Treat any other error as hard error. */
222 return MHD_ERR_NOTCONN_;
223 }
224#if EPOLL_SUPPORT
225 else if (i > (size_t) ret)
226 connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
227#endif /* EPOLL_SUPPORT */
228 // return ret; // should be return at the end of the function?
229
230 // previous error save:
231 // eno = errno;
204 232
205#if TCP_CORK 233#if TCP_CORK
206 if (use_corknopush) 234 if (use_corknopush)