diff options
Diffstat (limited to 'src/testspdy/test_proxies.c')
-rw-r--r-- | src/testspdy/test_proxies.c | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/src/testspdy/test_proxies.c b/src/testspdy/test_proxies.c index 3f7b554a..38d5f3cb 100644 --- a/src/testspdy/test_proxies.c +++ b/src/testspdy/test_proxies.c | |||
@@ -85,6 +85,7 @@ int main() | |||
85 | { | 85 | { |
86 | //pid_t child; | 86 | //pid_t child; |
87 | int childstatus; | 87 | int childstatus; |
88 | pid_t wpid; | ||
88 | 89 | ||
89 | parent = getpid(); | 90 | parent = getpid(); |
90 | mhd_port = get_port(4000); | 91 | mhd_port = get_port(4000); |
@@ -95,7 +96,7 @@ int main() | |||
95 | if (child_mhd == 0) | 96 | if (child_mhd == 0) |
96 | { | 97 | { |
97 | //run MHD | 98 | //run MHD |
98 | int devnull; | 99 | pid_t devnull; |
99 | char *port_s; | 100 | char *port_s; |
100 | 101 | ||
101 | close(1); | 102 | close(1); |
@@ -117,7 +118,7 @@ int main() | |||
117 | if (child_spdy2http == 0) | 118 | if (child_spdy2http == 0) |
118 | { | 119 | { |
119 | //run spdy2http | 120 | //run spdy2http |
120 | int devnull; | 121 | pid_t devnull; |
121 | char *port_s; | 122 | char *port_s; |
122 | //char *url; | 123 | //char *url; |
123 | 124 | ||
@@ -141,7 +142,7 @@ int main() | |||
141 | if (child_mhd2spdy == 0) | 142 | if (child_mhd2spdy == 0) |
142 | { | 143 | { |
143 | //run MHD2sdpy | 144 | //run MHD2sdpy |
144 | int devnull; | 145 | pid_t devnull; |
145 | char *port_s; | 146 | char *port_s; |
146 | char *url; | 147 | char *url; |
147 | 148 | ||
@@ -166,7 +167,7 @@ int main() | |||
166 | { | 167 | { |
167 | //run curl | 168 | //run curl |
168 | FILE *p; | 169 | FILE *p; |
169 | int devnull; | 170 | pid_t devnull; |
170 | char *cmd; | 171 | char *cmd; |
171 | unsigned int i; | 172 | unsigned int i; |
172 | char buf[strlen(EXPECTED_BODY) + 1]; | 173 | char buf[strlen(EXPECTED_BODY) + 1]; |
@@ -200,18 +201,35 @@ int main() | |||
200 | 201 | ||
201 | do | 202 | do |
202 | { | 203 | { |
203 | if(waitpid(child_mhd,&childstatus,WNOHANG) == child_mhd | 204 | wpid = waitpid(child_mhd,&childstatus,WNOHANG); |
204 | || waitpid(child_spdy2http,&childstatus,WNOHANG) == child_spdy2http | 205 | if(wpid == child_mhd) |
205 | || waitpid(child_mhd2spdy,&childstatus,WNOHANG) == child_mhd2spdy) | 206 | { |
206 | { | 207 | fprintf(stderr, "mhd died unexpectedly\n"); |
207 | killchildren(); | 208 | killchildren(); |
208 | return 1; | 209 | return 1; |
209 | } | 210 | } |
210 | if(waitpid(child_curl,&childstatus,WNOHANG) == child_curl) | 211 | |
211 | { | 212 | wpid = waitpid(child_spdy2http,&childstatus,WNOHANG); |
212 | killchildren(); | 213 | if(wpid == child_spdy2http) |
213 | return WEXITSTATUS(childstatus); | 214 | { |
214 | } | 215 | fprintf(stderr, "spdy2http died unexpectedly\n"); |
216 | killchildren(); | ||
217 | return 1; | ||
218 | } | ||
219 | |||
220 | wpid = waitpid(child_mhd2spdy,&childstatus,WNOHANG); | ||
221 | if(wpid == child_mhd2spdy) | ||
222 | { | ||
223 | fprintf(stderr, "mhd2spdy died unexpectedly\n"); | ||
224 | killchildren(); | ||
225 | return 1; | ||
226 | } | ||
227 | |||
228 | if(waitpid(child_curl,&childstatus,WNOHANG) == child_curl) | ||
229 | { | ||
230 | killchildren(); | ||
231 | return WEXITSTATUS(childstatus); | ||
232 | } | ||
215 | sleep(1); | 233 | sleep(1); |
216 | } | 234 | } |
217 | while(true); | 235 | while(true); |