diff options
-rw-r--r-- | src/microhttpd/connection_https.c | 2 | ||||
-rw-r--r-- | src/microhttpd/connection_https.h | 14 | ||||
-rw-r--r-- | src/microhttpd/mhd_send.c | 85 | ||||
-rw-r--r-- | src/microhttpd/mhd_send.h | 1 |
4 files changed, 57 insertions, 45 deletions
diff --git a/src/microhttpd/connection_https.c b/src/microhttpd/connection_https.c index 5efced33..8202329b 100644 --- a/src/microhttpd/connection_https.c +++ b/src/microhttpd/connection_https.c | |||
@@ -98,7 +98,7 @@ recv_tls_adapter (struct MHD_Connection *connection, | |||
98 | * @return positive value for number of bytes actually sent or | 98 | * @return positive value for number of bytes actually sent or |
99 | * negative value for error number MHD_ERR_xxx_ | 99 | * negative value for error number MHD_ERR_xxx_ |
100 | */ | 100 | */ |
101 | static ssize_t | 101 | ssize_t |
102 | send_tls_adapter (struct MHD_Connection *connection, | 102 | send_tls_adapter (struct MHD_Connection *connection, |
103 | const void *other, | 103 | const void *other, |
104 | size_t i) | 104 | size_t i) |
diff --git a/src/microhttpd/connection_https.h b/src/microhttpd/connection_https.h index 1c12ea9f..e91a84d3 100644 --- a/src/microhttpd/connection_https.h +++ b/src/microhttpd/connection_https.h | |||
@@ -60,6 +60,20 @@ MHD_run_tls_handshake_ (struct MHD_Connection *connection); | |||
60 | */ | 60 | */ |
61 | bool | 61 | bool |
62 | MHD_tls_connection_shutdown (struct MHD_Connection *connection); | 62 | MHD_tls_connection_shutdown (struct MHD_Connection *connection); |
63 | |||
64 | /** | ||
65 | * Callback for writing data to the socket. | ||
66 | * | ||
67 | * @param connection the MHD connection structure | ||
68 | * @param other data to write | ||
69 | * @param i number of bytes to write | ||
70 | * @return positive value for number of bytes actually sent or | ||
71 | * negative value for error number MHD_ERR_xxx_ | ||
72 | */ | ||
73 | ssize_t | ||
74 | send_tls_adapter (struct MHD_Connection *connection, | ||
75 | const void *other, | ||
76 | size_t i); | ||
63 | #endif /* HTTPS_SUPPORT */ | 77 | #endif /* HTTPS_SUPPORT */ |
64 | 78 | ||
65 | #endif | 79 | #endif |
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c index 18996c00..36ee0c50 100644 --- a/src/microhttpd/mhd_send.c +++ b/src/microhttpd/mhd_send.c | |||
@@ -207,49 +207,6 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, | |||
207 | ret = send (connection->socket_fd, buffer, buffer_size, 0); | 207 | ret = send (connection->socket_fd, buffer, buffer_size, 0); |
208 | #endif | 208 | #endif |
209 | 209 | ||
210 | /* | ||
211 | // pseudo-code for gnutls corking | ||
212 | if (have_more_data && !corked) | ||
213 | gnutls_record_cork(connection->tls_session); | ||
214 | if (!have_more_data && corked) | ||
215 | gnutls_record_uncork(connection->tls_session); | ||
216 | */ | ||
217 | |||
218 | /* for TLS*/ | ||
219 | |||
220 | if (0 != (connection->daemon->options & MHD_USE_TLS)) | ||
221 | send_tls_adapter(connection, buffer, buffer_size); | ||
222 | else | ||
223 | ; | ||
224 | |||
225 | // shouldn't we return 0 or -1? Why re-use the _ERR_ functions? | ||
226 | // error handling from send_param_adapter(): | ||
227 | if (0 > ret) | ||
228 | { | ||
229 | if (MHD_SCKT_ERR_IS_EAGAIN_ (err)) | ||
230 | { | ||
231 | #if EPOLL_SUPPORT | ||
232 | /* EAGAIN, no longer write-ready */ | ||
233 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; | ||
234 | #endif /* EPOLL_SUPPORT */ | ||
235 | return MHD_ERR_AGAIN_; | ||
236 | } | ||
237 | if (MHD_SCKT_ERR_IS_EINTR_ (err)) | ||
238 | return MHD_ERR_AGAIN_; | ||
239 | if (MHD_SCKT_ERR_IS_ (err, MHD_SCKT_ECONNRESET_)) | ||
240 | return MHD_ERR_CONNRESET_; | ||
241 | /* Treat any other error as hard error. */ | ||
242 | return MHD_ERR_NOTCONN_; | ||
243 | } | ||
244 | #if EPOLL_SUPPORT | ||
245 | else if (buffer_size > (size_t) ret) | ||
246 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; | ||
247 | #endif /* EPOLL_SUPPORT */ | ||
248 | // return ret; // should be return at the end of the function? | ||
249 | |||
250 | // previous error save: | ||
251 | // eno = errno; | ||
252 | |||
253 | #if TCP_CORK | 210 | #if TCP_CORK |
254 | if (use_corknopush) | 211 | if (use_corknopush) |
255 | { | 212 | { |
@@ -295,6 +252,48 @@ MHD_send_on_connection_ (struct MHD_Connection *connection, | |||
295 | // ... | 252 | // ... |
296 | } | 253 | } |
297 | #endif | 254 | #endif |
255 | |||
256 | /* | ||
257 | // pseudo-code for gnutls corking | ||
258 | if (have_more_data && !corked) | ||
259 | gnutls_record_cork(connection->tls_session); | ||
260 | if (!have_more_data && corked) | ||
261 | gnutls_record_uncork(connection->tls_session); | ||
262 | */ | ||
263 | |||
264 | /* for TLS*/ | ||
265 | |||
266 | if (0 != (connection->daemon->options & MHD_USE_TLS)) | ||
267 | send_tls_adapter(connection, buffer, buffer_size); | ||
268 | else { | ||
269 | |||
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 | ||
290 | else if (buffer_size > (size_t) ret) | ||
291 | connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY; | ||
292 | #endif /* EPOLL_SUPPORT */ | ||
293 | // return ret; // should be return at the end of the function? | ||
294 | // previous error save: | ||
295 | // eno = errno; | ||
296 | } | ||
298 | errno = eno; | 297 | errno = eno; |
299 | return ret; | 298 | return ret; |
300 | } | 299 | } |
diff --git a/src/microhttpd/mhd_send.h b/src/microhttpd/mhd_send.h index 7bd79a16..9d2065f0 100644 --- a/src/microhttpd/mhd_send.h +++ b/src/microhttpd/mhd_send.h | |||
@@ -67,5 +67,4 @@ MHD_send_on_connection2_ (struct MHD_Connection *connection, | |||
67 | size_t header_size, | 67 | size_t header_size, |
68 | const char *buffer, | 68 | const char *buffer, |
69 | size_t buffer_size); | 69 | size_t buffer_size); |
70 | |||
71 | #endif /* MHD_SEND_H */ | 70 | #endif /* MHD_SEND_H */ |