diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-02-28 23:19:21 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-02-28 23:19:21 +0300 |
commit | 347cbe5f10709c146cc6fce06acb082de01f2995 (patch) | |
tree | 038333c1bd89e055b3cefa72dced9058ad6fda6b | |
parent | c36a7c7f305d3aaab29ab88b3ef49fa192988965 (diff) | |
download | libmicrohttpd-347cbe5f10709c146cc6fce06acb082de01f2995.tar.gz libmicrohttpd-347cbe5f10709c146cc6fce06acb082de01f2995.zip |
Fixed storing pointers and integers in one union in epoll mode.
-rw-r--r-- | src/microhttpd/daemon.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 803d55c2..283c8c45 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -3739,6 +3739,10 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon) | |||
3739 | } | 3739 | } |
3740 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ | 3740 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ |
3741 | 3741 | ||
3742 | /** | ||
3743 | * Pointer-marker to distinguish ITC slot in epoll sets. | ||
3744 | */ | ||
3745 | static const char * const epoll_itc_marker = "itc_marker"; | ||
3742 | 3746 | ||
3743 | /** | 3747 | /** |
3744 | * Do epoll()-based processing (this function is allowed to | 3748 | * Do epoll()-based processing (this function is allowed to |
@@ -3753,7 +3757,7 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
3753 | int may_block) | 3757 | int may_block) |
3754 | { | 3758 | { |
3755 | #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) | 3759 | #if defined(HTTPS_SUPPORT) && defined(UPGRADE_SUPPORT) |
3756 | static const char *upgrade_marker = "upgrade_ptr"; | 3760 | static const char * const upgrade_marker = "upgrade_ptr"; |
3757 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ | 3761 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ |
3758 | struct MHD_Connection *pos; | 3762 | struct MHD_Connection *pos; |
3759 | struct MHD_Connection *prev; | 3763 | struct MHD_Connection *prev; |
@@ -3900,13 +3904,7 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
3900 | continue; | 3904 | continue; |
3901 | } | 3905 | } |
3902 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ | 3906 | #endif /* HTTPS_SUPPORT && UPGRADE_SUPPORT */ |
3903 | /* UGH: we're storing pointers and fds in the same union | 3907 | if (epoll_itc_marker == events[i].data.ptr) |
3904 | here; incredibly ugly and somewhat risky, even though a | ||
3905 | pointer with the same numeric value as the itc.fd[0] can | ||
3906 | be expected to be rare... FIXME (a construction similar | ||
3907 | to what we did with the `upgrade_marker` should do) */ | ||
3908 | if ( (MHD_ITC_IS_VALID_(daemon->itc)) && | ||
3909 | (MHD_itc_r_fd_ (daemon->itc) == events[i].data.fd) ) | ||
3910 | { | 3908 | { |
3911 | /* It's OK to clear ITC here as all external | 3909 | /* It's OK to clear ITC here as all external |
3912 | conditions will be processed later. */ | 3910 | conditions will be processed later. */ |
@@ -4819,8 +4817,7 @@ setup_epoll_to_listen (struct MHD_Daemon *daemon) | |||
4819 | if (MHD_ITC_IS_VALID_(daemon->itc)) | 4817 | if (MHD_ITC_IS_VALID_(daemon->itc)) |
4820 | { | 4818 | { |
4821 | event.events = EPOLLIN; | 4819 | event.events = EPOLLIN; |
4822 | event.data.ptr = NULL; | 4820 | event.data.ptr = epoll_itc_marker; |
4823 | event.data.fd = MHD_itc_r_fd_ (daemon->itc); | ||
4824 | if (0 != epoll_ctl (daemon->epoll_fd, | 4821 | if (0 != epoll_ctl (daemon->epoll_fd, |
4825 | EPOLL_CTL_ADD, | 4822 | EPOLL_CTL_ADD, |
4826 | MHD_itc_r_fd_ (daemon->itc), | 4823 | MHD_itc_r_fd_ (daemon->itc), |