diff options
Diffstat (limited to 'src/lib/daemon_poll.c')
-rw-r--r-- | src/lib/daemon_poll.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/lib/daemon_poll.c b/src/lib/daemon_poll.c index bc705aea..92093652 100644 --- a/src/lib/daemon_poll.c +++ b/src/lib/daemon_poll.c | |||
@@ -450,4 +450,64 @@ MHD_daemon_poll_ (struct MHD_Daemon *daemon, | |||
450 | #endif | 450 | #endif |
451 | } | 451 | } |
452 | 452 | ||
453 | |||
454 | #ifdef HTTPS_SUPPORT | ||
455 | /** | ||
456 | * Process upgraded connection with a poll() loop. | ||
457 | * We are in our own thread, only processing @a con | ||
458 | * | ||
459 | * @param con connection to process | ||
460 | */ | ||
461 | void | ||
462 | MHD_daemon_upgrade_connection_with_poll_ (struct MHD_Connection *con) | ||
463 | { | ||
464 | struct MHD_UpgradeResponseHandle *urh = con->request.urh; | ||
465 | struct MHD_Daemon *daemon = con->daemon; | ||
466 | struct pollfd p[2]; | ||
467 | |||
468 | memset (p, | ||
469 | 0, | ||
470 | sizeof (p)); | ||
471 | p[0].fd = urh->connection->socket_fd; | ||
472 | p[1].fd = urh->mhd.socket; | ||
473 | |||
474 | while ( (0 != urh->in_buffer_size) || | ||
475 | (0 != urh->out_buffer_size) || | ||
476 | (0 != urh->in_buffer_used) || | ||
477 | (0 != urh->out_buffer_used) ) | ||
478 | { | ||
479 | int timeout; | ||
480 | |||
481 | urh_update_pollfd (urh, | ||
482 | p); | ||
483 | |||
484 | if ( (con->tls_read_ready) && | ||
485 | (urh->in_buffer_used < urh->in_buffer_size)) | ||
486 | timeout = 0; /* No need to wait if incoming data is already pending in TLS buffers. */ | ||
487 | else | ||
488 | timeout = -1; | ||
489 | |||
490 | if (MHD_sys_poll_ (p, | ||
491 | 2, | ||
492 | timeout) < 0) | ||
493 | { | ||
494 | const int err = MHD_socket_get_error_ (); | ||
495 | |||
496 | if (MHD_SCKT_ERR_IS_EINTR_ (err)) | ||
497 | continue; | ||
498 | #ifdef HAVE_MESSAGES | ||
499 | MHD_DLOG (con->daemon, | ||
500 | MHD_SC_UNEXPECTED_POLL_ERROR, | ||
501 | _("Error during poll: `%s'\n"), | ||
502 | MHD_socket_strerr_ (err)); | ||
503 | #endif | ||
504 | break; | ||
505 | } | ||
506 | urh_from_pollfd (urh, | ||
507 | p); | ||
508 | process_urh (urh); | ||
509 | } | ||
510 | } | ||
511 | #endif | ||
512 | |||
453 | /* end of daemon_poll.c */ | 513 | /* end of daemon_poll.c */ |