diff options
Diffstat (limited to 'src/microhttpd/mhd_send.c')
-rw-r--r-- | src/microhttpd/mhd_send.c | 85 |
1 files changed, 42 insertions, 43 deletions
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 | } |