aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2015-12-08 19:35:45 +0000
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2015-12-08 19:35:45 +0000
commit69c472a541a0646c919c5b51e61f34572cfb102a (patch)
treeb9fba5b76541e94d63b6dc1a82e52a3b3e2b9e34
parentf4cfc00ccbf65d421fd0b6edc06b75623de95555 (diff)
downloadlibmicrohttpd-69c472a541a0646c919c5b51e61f34572cfb102a.tar.gz
libmicrohttpd-69c472a541a0646c919c5b51e61f34572cfb102a.zip
MHD_get_fdset() & MHD_get_fdset2(): continue to add FDs to sets in case of error.
-rw-r--r--src/microhttpd/daemon.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 219fb1be..95e6d4c4 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -714,6 +714,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon,
714 unsigned int fd_setsize) 714 unsigned int fd_setsize)
715{ 715{
716 struct MHD_Connection *pos; 716 struct MHD_Connection *pos;
717 int result = MHD_YES;
717 718
718 if ( (NULL == daemon) 719 if ( (NULL == daemon)
719 || (NULL == read_fd_set) 720 || (NULL == read_fd_set)
@@ -733,7 +734,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon,
733#endif 734#endif
734 if (MHD_INVALID_SOCKET != daemon->socket_fd && 735 if (MHD_INVALID_SOCKET != daemon->socket_fd &&
735 MHD_YES != add_to_fd_set (daemon->socket_fd, read_fd_set, max_fd, fd_setsize)) 736 MHD_YES != add_to_fd_set (daemon->socket_fd, read_fd_set, max_fd, fd_setsize))
736 return MHD_NO; 737 result = MHD_NO;
737 738
738 for (pos = daemon->connections_head; NULL != pos; pos = pos->next) 739 for (pos = daemon->connections_head; NULL != pos; pos = pos->next)
739 { 740 {
@@ -741,19 +742,19 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon,
741 { 742 {
742 case MHD_EVENT_LOOP_INFO_READ: 743 case MHD_EVENT_LOOP_INFO_READ:
743 if (MHD_YES != add_to_fd_set (pos->socket_fd, read_fd_set, max_fd, fd_setsize)) 744 if (MHD_YES != add_to_fd_set (pos->socket_fd, read_fd_set, max_fd, fd_setsize))
744 return MHD_NO; 745 result = MHD_NO;
745 break; 746 break;
746 case MHD_EVENT_LOOP_INFO_WRITE: 747 case MHD_EVENT_LOOP_INFO_WRITE:
747 if (MHD_YES != add_to_fd_set (pos->socket_fd, write_fd_set, max_fd, fd_setsize)) 748 if (MHD_YES != add_to_fd_set (pos->socket_fd, write_fd_set, max_fd, fd_setsize))
748 return MHD_NO; 749 result = MHD_NO;
749 if (pos->read_buffer_size > pos->read_buffer_offset && 750 if (pos->read_buffer_size > pos->read_buffer_offset &&
750 MHD_YES != add_to_fd_set (pos->socket_fd, read_fd_set, max_fd, fd_setsize)) 751 MHD_YES != add_to_fd_set (pos->socket_fd, read_fd_set, max_fd, fd_setsize))
751 return MHD_NO; 752 result = MHD_NO;
752 break; 753 break;
753 case MHD_EVENT_LOOP_INFO_BLOCK: 754 case MHD_EVENT_LOOP_INFO_BLOCK:
754 if (pos->read_buffer_size > pos->read_buffer_offset && 755 if (pos->read_buffer_size > pos->read_buffer_offset &&
755 MHD_YES != add_to_fd_set (pos->socket_fd, read_fd_set, max_fd, fd_setsize)) 756 MHD_YES != add_to_fd_set (pos->socket_fd, read_fd_set, max_fd, fd_setsize))
756 return MHD_NO; 757 result = MHD_NO;
757 break; 758 break;
758 case MHD_EVENT_LOOP_INFO_CLEANUP: 759 case MHD_EVENT_LOOP_INFO_CLEANUP:
759 /* this should never happen */ 760 /* this should never happen */
@@ -768,7 +769,7 @@ MHD_get_fdset2 (struct MHD_Daemon *daemon,
768 *max_fd); 769 *max_fd);
769#endif 770#endif
770#endif 771#endif
771 return MHD_YES; 772 return result;
772} 773}
773 774
774 775