Lines 44-49
Link Here
|
44 |
#include "apr_file_io.h" |
44 |
#include "apr_file_io.h" |
45 |
#include "apr_file_info.h" |
45 |
#include "apr_file_info.h" |
46 |
#include "apr_general.h" |
46 |
#include "apr_general.h" |
|
|
47 |
#include "apr_poll.h" |
48 |
#include "apr_portable.h" |
47 |
#include "apr_time.h" |
49 |
#include "apr_time.h" |
48 |
#include "apr_getopt.h" |
50 |
#include "apr_getopt.h" |
49 |
|
51 |
|
Lines 64-69
Link Here
|
64 |
#define MAX_PATH 1024 |
66 |
#define MAX_PATH 1024 |
65 |
#endif |
67 |
#endif |
66 |
|
68 |
|
|
|
69 |
#if APR_FILES_AS_SOCKETS |
70 |
static apr_pollfd_t wait_pollfd; |
71 |
static apr_status_t wait_for_io_or_timeout(apr_file_t *f, |
72 |
apr_interval_time_t timeout, |
73 |
apr_pool_t *pool) |
74 |
{ |
75 |
apr_int32_t nd; |
76 |
|
77 |
if (!wait_pollfd.p) { |
78 |
wait_pollfd.p = pool; |
79 |
} |
80 |
wait_pollfd.desc_type = APR_POLL_FILE; |
81 |
wait_pollfd.reqevents = APR_POLLIN; |
82 |
wait_pollfd.desc.f = f; |
83 |
|
84 |
return apr_poll(&wait_pollfd, 1, &nd, timeout); |
85 |
} |
86 |
#elif defined(WIN32) |
87 |
static apr_status_t wait_for_io_or_timeout(apr_file_t *f, |
88 |
apr_interval_time_t timeout, |
89 |
apr_pool_t *pool) |
90 |
{ |
91 |
HANDLE h; |
92 |
char c; |
93 |
DWORD r; |
94 |
apr_interval_time_t s = 0; |
95 |
|
96 |
apr_os_file_get(&h, f); |
97 |
while (PeekNamedPipe(h, &c, 1, &r, NULL, NULL)) { |
98 |
if (r == 1) |
99 |
break; |
100 |
if (s >= timeout) { |
101 |
return APR_TIMEUP; |
102 |
} |
103 |
Sleep(100); |
104 |
s += 100000; |
105 |
} |
106 |
return APR_SUCCESS; |
107 |
} |
108 |
#else |
109 |
static apr_status_t wait_for_io_or_timeout(apr_file_t *f, |
110 |
apr_interval_time_t timeout, |
111 |
apr_pool_t *pool) |
112 |
{ |
113 |
return APR_SUCCESS; |
114 |
} |
115 |
#endif /* APR_FILES_AS_SOCKETS */ |
116 |
|
67 |
static void usage(const char *argv0, const char *reason) |
117 |
static void usage(const char *argv0, const char *reason) |
68 |
{ |
118 |
{ |
69 |
if (reason) { |
119 |
if (reason) { |
Lines 198-204
Link Here
|
198 |
* since we reset bypass_io after the 1st loop |
248 |
* since we reset bypass_io after the 1st loop |
199 |
*/ |
249 |
*/ |
200 |
if (!bypass_io) { |
250 |
if (!bypass_io) { |
201 |
if (apr_file_read(f_stdin, buf, &nRead) != APR_SUCCESS) { |
251 |
apr_status_t rv; |
|
|
252 |
|
253 |
rv = wait_for_io_or_timeout(f_stdin, apr_time_from_sec(1), pool); |
254 |
if (rv == APR_SUCCESS) { |
255 |
if (apr_file_read(f_stdin, buf, &nRead) != APR_SUCCESS) { |
256 |
exit(3); |
257 |
} |
258 |
} |
259 |
else if (APR_STATUS_IS_TIMEUP(rv)) { |
260 |
nRead = 0; |
261 |
} |
262 |
else { |
202 |
exit(3); |
263 |
exit(3); |
203 |
} |
264 |
} |
204 |
} |
265 |
} |