diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-07-19 19:12:00 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-07-19 19:12:00 +0200 |
commit | f5170975b4fad18e6156884aef533b137843cff3 (patch) | |
tree | 22ca28ca03baebd5cf42ef275b8ada9e8a80451c | |
parent | 1f08febcc06a20ba2ce4412b8a3b04943965d7d3 (diff) | |
download | libmicrohttpd-f5170975b4fad18e6156884aef533b137843cff3.tar.gz libmicrohttpd-f5170975b4fad18e6156884aef533b137843cff3.zip |
move TLS branch to right position
-rw-r--r-- | src/microhttpd/mhd_send.c | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index 36ee0c50..315ee563 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c | |||
@@ -81,6 +81,7 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, | |||
81 | bool want_cork; | 81 | bool want_cork; |
82 | bool have_cork; | 82 | bool have_cork; |
83 | bool have_more; | 83 | bool have_more; |
84 | bool using_tls = false; | ||
84 | /* The socket. */ | 85 | /* The socket. */ |
85 | MHD_socket s = connection->socket_fd; | 86 | MHD_socket s = connection->socket_fd; |
86 | int eno; | 87 | int eno; |
@@ -137,6 +138,10 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, | |||
137 | use_corknopush = true; | 138 | use_corknopush = true; |
138 | #endif | 139 | #endif |
139 | 140 | ||
141 | #ifdef HTTPS_SUPPORT | ||
142 | using_tls = (0 != (connection->daemon->options & MHD_USE_TLS)); | ||
143 | #endif | ||
144 | |||
140 | #if TCP_CORK | 145 | #if TCP_CORK |
141 | if (use_corknopush) | 146 | if (use_corknopush) |
142 | { | 147 | { |
@@ -197,16 +202,23 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, | |||
197 | } | 202 | } |
198 | #endif | 203 | #endif |
199 | 204 | ||
200 | // prepare the send() to return. | 205 | #ifdef HTTPS_SUPPORT |
206 | if (using_tls) | ||
207 | { | ||
208 | send_tls_adapter(connection, buffer, buffer_size); | ||
209 | } | ||
210 | else | ||
211 | #endif | ||
212 | { | ||
201 | #if MSG_MORE | 213 | #if MSG_MORE |
202 | ret = send (connection->socket_fd, | 214 | ret = send (connection->socket_fd, |
203 | buffer, | 215 | buffer, |
204 | buffer_size, | 216 | buffer_size, |
205 | (want_cork ? MSG_MORE : 0)); | 217 | (want_cork ? MSG_MORE : 0)); |
206 | #else | 218 | #else |
207 | ret = send (connection->socket_fd, buffer, buffer_size, 0); | 219 | ret = send (connection->socket_fd, buffer, buffer_size, 0); |
208 | #endif | 220 | #endif |
209 | 221 | } | |
210 | #if TCP_CORK | 222 | #if TCP_CORK |
211 | if (use_corknopush) | 223 | if (use_corknopush) |
212 | { | 224 | { |
@@ -261,39 +273,31 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, | |||
261 | gnutls_record_uncork(connection->tls_session); | 273 | gnutls_record_uncork(connection->tls_session); |
262 | */ | 274 | */ |
263 | 275 | ||
264 | /* for TLS*/ | 276 | // shouldn't we return 0 or -1? Why re-use the _ERR_ functions? |
265 | 277 | // error handling from send_param_adapter(): | |
266 | if (0 != (connection->daemon->options & MHD_USE_TLS)) | 278 | if (0 > ret) |
267 | send_tls_adapter(connection, buffer, buffer_size); | 279 | { |
268 | else { | 280 | if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) |
269 | 281 | { | |
270 | // shouldn't we return 0 or -1? Why re-use the _ERR_ functions? | ||
271 | // error handling from send_param_adapter(): | ||
272 | if (0 > ret) | ||
273 | { | ||
274 | if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) | ||
275 | { | ||
276 | #if EPOLL_SUPPORT | ||
277 | /* EAGAIN, no longer write-ready */ | ||
278 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; | ||
279 | #endif /* EPOLL_SUPPORT */ | ||
280 | return MHD_ERR_AGAIN_; | ||
281 | } | ||
282 | if (MHD_SCKT_ERR_IS_EINTR_ (err)) | ||
283 | return MHD_ERR_AGAIN_; | ||
284 | if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_)) | ||
285 | return MHD_ERR_CONNRESET_; | ||
286 | /* Treat any other error as hard error. */ | ||
287 | return MHD_ERR_NOTCONN_; | ||
288 | } | ||
289 | #if EPOLL_SUPPORT | 282 | #if EPOLL_SUPPORT |
290 | else if (buffer_size > (size_t) ret) | 283 | /* EAGAIN, no longer write-ready */ |
291 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; | 284 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; |
292 | #endif /* EPOLL_SUPPORT */ | 285 | #endif /* EPOLL_SUPPORT */ |
293 | // return ret; // should be return at the end of the function? | 286 | return MHD_ERR_AGAIN_; |
294 | // previous error save: | 287 | } |
295 | // eno = errno; | 288 | if (MHD_SCKT_ERR_IS_EINTR_ (err)) |
289 | return MHD_ERR_AGAIN_; | ||
290 | if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_)) | ||
291 | return MHD_ERR_CONNRESET_; | ||
292 | /* Treat any other error as hard error. */ | ||
293 | return MHD_ERR_NOTCONN_; | ||
296 | } | 294 | } |
295 | #if EPOLL_SUPPORT | ||
296 | else if (buffer_size > (size_t) ret) | ||
297 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; | ||
298 | #endif /* EPOLL_SUPPORT */ | ||
299 | // return ret; // should be return at the end of the function? | ||
300 | // previous error save: | ||
297 | errno = eno; | 301 | errno = eno; |
298 | return ret; | 302 | return ret; |
299 | } | 303 | } |