aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/response.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/response.c')
-rw-r--r--src/microhttpd/response.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index e7049a5a..93803813 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -597,10 +597,20 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh,
597 enum MHD_UpgradeAction action, 597 enum MHD_UpgradeAction action,
598 ...) 598 ...)
599{ 599{
600 struct MHD_Daemon *daemon = urh->connection->daemon;
601
600 switch (action) 602 switch (action)
601 { 603 {
602 case MHD_UPGRADE_ACTION_CLOSE: 604 case MHD_UPGRADE_ACTION_CLOSE:
603 /* Application is done with this connection, tear it down! */ 605 /* Application is done with this connection, tear it down! */
606 if (0 != (daemon->options & MHD_USE_SSL) )
607 {
608 DLL_remove (daemon->urh_head,
609 daemon->urh_tail,
610 urh);
611 /* FIXME: if running in epoll()-mode, do we have
612 to remove any of the FDs from any epoll-sets here? */
613 }
604 if ( (MHD_INVALID_SOCKET != urh->app_socket) && 614 if ( (MHD_INVALID_SOCKET != urh->app_socket) &&
605 (0 != MHD_socket_close_ (urh->app_socket)) ) 615 (0 != MHD_socket_close_ (urh->app_socket)) )
606 MHD_PANIC ("close failed\n"); 616 MHD_PANIC ("close failed\n");
@@ -636,6 +646,7 @@ int
636MHD_response_execute_upgrade_ (struct MHD_Response *response, 646MHD_response_execute_upgrade_ (struct MHD_Response *response,
637 struct MHD_Connection *connection) 647 struct MHD_Connection *connection)
638{ 648{
649 struct MHD_Daemon *daemon = connection->daemon;
639 struct MHD_UpgradeResponseHandle *urh; 650 struct MHD_UpgradeResponseHandle *urh;
640 int sv[2]; 651 int sv[2];
641 size_t rbo; 652 size_t rbo;
@@ -645,7 +656,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
645 MHD_HTTP_HEADER_UPGRADE)) 656 MHD_HTTP_HEADER_UPGRADE))
646 { 657 {
647#ifdef HAVE_MESSAGES 658#ifdef HAVE_MESSAGES
648 MHD_DLOG (connection->daemon, 659 MHD_DLOG (daemon,
649 "Invalid response for upgrade: application failed to set the 'Upgrade' header!\n"); 660 "Invalid response for upgrade: application failed to set the 'Upgrade' header!\n");
650#endif 661#endif
651 return MHD_NO; 662 return MHD_NO;
@@ -655,7 +666,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
655 if (NULL == urh) 666 if (NULL == urh)
656 return MHD_NO; 667 return MHD_NO;
657#if HTTPS_SUPPORT 668#if HTTPS_SUPPORT
658 if (0 != (connection->daemon->options & MHD_USE_SSL) ) 669 if (0 != (daemon->options & MHD_USE_SSL) )
659 { 670 {
660 /* FIXME: this is non-portable for now; W32 port pending... */ 671 /* FIXME: this is non-portable for now; W32 port pending... */
661 if (0 != socketpair (AF_UNIX, 672 if (0 != socketpair (AF_UNIX,
@@ -666,6 +677,23 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
666 free (urh); 677 free (urh);
667 return MHD_NO; 678 return MHD_NO;
668 } 679 }
680 if ( (! MHD_SCKT_FD_FITS_FDSET_(sv[1], NULL)) &&
681 (0 == (daemon->options & (MHD_USE_POLL | MHD_USE_EPOLL))) )
682 {
683#ifdef HAVE_MESSAGES
684 MHD_DLOG (daemon,
685 "Socketpair descriptor larger than FD_SETSIZE: %d > %d\n",
686 (int) sv[1],
687 (int) FD_SETSIZE);
688#endif
689 if (0 != MHD_socket_close_ (sv[0]))
690 MHD_PANIC ("close failed\n");
691 if (0 != MHD_socket_close_ (sv[1]))
692 MHD_PANIC ("close failed\n");
693 free (urh);
694 return MHD_NO;
695 }
696
669 urh->app_socket = sv[0]; 697 urh->app_socket = sv[0];
670 urh->mhd_socket = sv[1]; 698 urh->mhd_socket = sv[1];
671 urh->connection = connection; 699 urh->connection = connection;
@@ -682,8 +710,14 @@ MHD_response_execute_upgrade_ (struct MHD_Response *response,
682 suspended; it will be resumed once we are done 710 suspended; it will be resumed once we are done
683 in the #MHD_upgrade_action() function */ 711 in the #MHD_upgrade_action() function */
684 MHD_suspend_connection (connection); 712 MHD_suspend_connection (connection);
685 /* FIXME: also need to start some processing logic in _all_ MHD 713 urh->celi_mhd = MHD_EPOLL_STATE_UNREADY;
686 event loops for the sv traffic! (NOT IMPLEMENTED!!!) */ 714 urh->celi_client = MHD_EPOLL_STATE_UNREADY;
715 /* FIXME: is it possible we did not fully drain the client
716 socket yet and are thus read-ready already? This may
717 matter if we are in epoll() edge triggered mode... */
718 DLL_insert (connection->daemon->urh_head,
719 connection->daemon->urh_tail,
720 urh);
687 return MHD_YES; 721 return MHD_YES;
688 } 722 }
689#endif 723#endif