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.c70
1 files changed, 7 insertions, 63 deletions
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index aa79196d..c08117d7 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -632,55 +632,27 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh,
632 /* just need to signal the thread that we are done */ 632 /* just need to signal the thread that we are done */
633 MHD_semaphore_up (connection->upgrade_sem); 633 MHD_semaphore_up (connection->upgrade_sem);
634 } 634 }
635#if HTTPS_SUPPORT
635 else 636 else
636 { 637 {
637 /* signal thread by shutdown() of 'app' socket */ 638 /* signal thread by shutdown() of 'app' socket */
638 shutdown (urh->app.socket, SHUT_RDWR); 639 shutdown (urh->app.socket,
640 SHUT_RDWR);
639 } 641 }
642#endif
640 return MHD_YES; 643 return MHD_YES;
641 } 644 }
642#if HTTPS_SUPPORT 645#if HTTPS_SUPPORT
643 if (0 != (daemon->options & MHD_USE_SSL) ) 646 if (0 != (daemon->options & MHD_USE_SSL) )
644 { 647 {
645 DLL_remove (daemon->urh_head, 648 urh->was_closed = MHD_YES;
646 daemon->urh_tail,
647 urh);
648 if (0 != (daemon->options & MHD_USE_EPOLL))
649 {
650 /* epoll documentation suggests that closing a FD
651 automatically removes it from the epoll set; however,
652 this is not true as if we fail to do manually remove it,
653 we are still seeing an event for this fd in epoll,
654 causing grief (use-after-free...) --- at least on my
655 system. */
656 if (0 != epoll_ctl (daemon->epoll_upgrade_fd,
657 EPOLL_CTL_DEL,
658 connection->socket_fd,
659 NULL))
660 MHD_PANIC ("Failed to remove FD from epoll set\n");
661 }
662 if (MHD_INVALID_SOCKET != urh->app.socket) 649 if (MHD_INVALID_SOCKET != urh->app.socket)
663 { 650 {
664 if (0 != MHD_socket_close_ (urh->app.socket)) 651 if (0 != MHD_socket_close_ (urh->app.socket))
665 MHD_PANIC ("close failed\n"); 652 MHD_PANIC ("close failed\n");
653 urh->app.socket = MHD_INVALID_SOCKET;
666 } 654 }
667 if (MHD_INVALID_SOCKET != urh->mhd.socket) 655 return MHD_YES;
668 {
669 /* epoll documentation suggests that closing a FD
670 automatically removes it from the epoll set; however,
671 this is not true as if we fail to do manually remove it,
672 we are still seeing an event for this fd in epoll,
673 causing grief (use-after-free...) --- at least on my
674 system. */
675 if ( (0 != (daemon->options & MHD_USE_EPOLL)) &&
676 (0 != epoll_ctl (daemon->epoll_upgrade_fd,
677 EPOLL_CTL_DEL,
678 urh->mhd.socket,
679 NULL)) )
680 MHD_PANIC ("Failed to remove FD from epoll set\n");
681 if (0 != MHD_socket_close_ (urh->mhd.socket))
682 MHD_PANIC ("close failed\n");
683 }
684 } 656 }
685#endif 657#endif
686 MHD_resume_connection (connection); 658 MHD_resume_connection (connection);
@@ -688,34 +660,6 @@ MHD_upgrade_action (struct MHD_UpgradeResponseHandle *urh,
688 MHD_REQUEST_TERMINATED_COMPLETED_OK); 660 MHD_REQUEST_TERMINATED_COMPLETED_OK);
689 free (urh); 661 free (urh);
690 return MHD_YES; 662 return MHD_YES;
691 case MHD_UPGRADE_ACTION_CORK:
692 /* FIXME: not implemented */
693 return MHD_NO;
694 case MHD_UPGRADE_ACTION_FLUSH:
695#if HTTPS_SUPPORT
696 if (0 != (daemon->options & MHD_USE_SSL))
697 {
698 int avail;
699
700 /* First, check that our pipe is empty, to be sure we do
701 have it all in the buffer. */
702 if ( (0 ==
703#if WINDOWS
704 ioctlsocket
705#else
706 ioctl
707#endif
708 (urh->mhd.socket,
709 FIONREAD,
710 &avail)) &&
711 (0 != avail) )
712 return MHD_NO;
713 /* then, refuse 'flush' unless our buffer is empty */
714 if (0 != urh->out_buffer_off)
715 return MHD_NO;
716 }
717#endif
718 return MHD_YES;
719 default: 663 default:
720 /* we don't understand this one */ 664 /* we don't understand this one */
721 return MHD_NO; 665 return MHD_NO;