diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-09-18 12:08:41 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-09-18 12:08:41 +0200 |
commit | a6ed6a31484243e684a51d4cb3114f17f44c3233 (patch) | |
tree | ce3f20806d223310ae5e765a3ddeef61727fc3de | |
parent | d7ea34ee710fe97fc57235dce165fcc5f50a512a (diff) | |
download | busybox-w32-a6ed6a31484243e684a51d4cb3114f17f44c3233.tar.gz busybox-w32-a6ed6a31484243e684a51d4cb3114f17f44c3233.tar.bz2 busybox-w32-a6ed6a31484243e684a51d4cb3114f17f44c3233.zip |
httpd: make sire pfd[TO_CGI].revents is cleared before poll()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/httpd.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 143331389..621d9cddc 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -1104,23 +1104,31 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post | |||
1104 | 1104 | ||
1105 | /* NB: breaking out of this loop jumps to log_and_exit() */ | 1105 | /* NB: breaking out of this loop jumps to log_and_exit() */ |
1106 | out_cnt = 0; | 1106 | out_cnt = 0; |
1107 | pfd[FROM_CGI].fd = fromCgi_rd; | ||
1108 | pfd[FROM_CGI].events = POLLIN; | ||
1109 | pfd[TO_CGI].fd = toCgi_wr; | ||
1107 | while (1) { | 1110 | while (1) { |
1108 | /* Note: even pfd[0].events == 0 won't prevent | 1111 | /* Note: even pfd[0].events == 0 won't prevent |
1109 | * revents == POLLHUP|POLLERR reports from closed stdin. | 1112 | * revents == POLLHUP|POLLERR reports from closed stdin. |
1110 | * This works: */ | 1113 | * Setting fd to -1 works: */ |
1111 | pfd[0].fd = -1; | 1114 | pfd[0].fd = -1; |
1115 | pfd[0].events = POLLIN; | ||
1116 | pfd[0].revents = 0; /* probably not needed, paranoia */ | ||
1112 | 1117 | ||
1113 | pfd[FROM_CGI].fd = fromCgi_rd; | 1118 | /* We always poll this fd, thus kernel always sets revents: */ |
1114 | pfd[FROM_CGI].events = POLLIN; | 1119 | /*pfd[FROM_CGI].events = POLLIN; - moved out of loop */ |
1120 | /*pfd[FROM_CGI].revents = 0; - not needed */ | ||
1115 | 1121 | ||
1116 | pfd[TO_CGI].fd = toCgi_wr; | 1122 | /* gcc-4.8.0 still doesnt fill two shorts with one insn :( */ |
1123 | /* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47059 */ | ||
1124 | /* hopefully one day it will... */ | ||
1117 | pfd[TO_CGI].events = POLLOUT; | 1125 | pfd[TO_CGI].events = POLLOUT; |
1126 | pfd[TO_CGI].revents = 0; /* needed! */ | ||
1118 | 1127 | ||
1119 | if (toCgi_wr && hdr_cnt <= 0) { | 1128 | if (toCgi_wr && hdr_cnt <= 0) { |
1120 | if (post_len > 0) { | 1129 | if (post_len > 0) { |
1121 | /* Expect more POST data from network */ | 1130 | /* Expect more POST data from network */ |
1122 | pfd[0].fd = 0; | 1131 | pfd[0].fd = 0; |
1123 | pfd[0].events = POLLIN; | ||
1124 | } else { | 1132 | } else { |
1125 | /* post_len <= 0 && hdr_cnt <= 0: | 1133 | /* post_len <= 0 && hdr_cnt <= 0: |
1126 | * no more POST data to CGI, | 1134 | * no more POST data to CGI, |