ASF Bugzilla – Attachment 23785 Details for
Bug 47345
rotatelogs timeout patch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for rotatelogs
rotatelogs.timeout.patch (text/plain), 2.38 KB, created by
Mladen Turk
on 2009-06-10 05:48:20 UTC
(
hide
)
Description:
Patch for rotatelogs
Filename:
MIME Type:
Creator:
Mladen Turk
Created:
2009-06-10 05:48:20 UTC
Size:
2.38 KB
patch
obsolete
>--- rotatelogs.c.org 2008-11-06 07:49:07.000000000 +0100 >+++ rotatelogs.c 2009-06-10 14:15:39.000000000 +0200 >@@ -44,6 +44,8 @@ > #include "apr_file_io.h" > #include "apr_file_info.h" > #include "apr_general.h" >+#include "apr_poll.h" >+#include "apr_portable.h" > #include "apr_time.h" > #include "apr_getopt.h" > >@@ -64,6 +66,53 @@ > #define MAX_PATH 1024 > #endif > >+#if APR_FILES_AS_SOCKETS >+static apr_pollfd_t wait_pollfd; >+static apr_status_t wait_for_io_or_timeout(apr_file_t *f, >+ apr_interval_time_t timeout, >+ apr_pool_t *pool) >+{ >+ apr_int32_t nd; >+ >+ if (!wait_pollfd.p) { >+ wait_pollfd.p = pool; >+ } >+ wait_pollfd.desc_type = APR_POLL_FILE; >+ wait_pollfd.reqevents = APR_POLLIN; >+ wait_pollfd.desc.f = f; >+ >+ return apr_poll(&wait_pollfd, 1, &nd, timeout); >+} >+#elif defined(WIN32) >+static apr_status_t wait_for_io_or_timeout(apr_file_t *f, >+ apr_interval_time_t timeout, >+ apr_pool_t *pool) >+{ >+ HANDLE h; >+ char c; >+ DWORD r; >+ int s = 0; >+ >+ apr_os_file_get(&h, f); >+ while (PeekNamedPipe(h, &c, 1, &r, NULL, NULL)) { >+ if (r == 1) >+ break; >+ if (s >= apr_time_msec(timeout)) >+ return APR_TIMEUP; >+ Sleep(100); >+ s += 100; >+ } >+ return APR_SUCCESS; >+} >+#else >+static apr_status_t wait_for_io_or_timeout(apr_file_t *f, >+ apr_interval_time_t timeout, >+ apr_pool_t *pool) >+{ >+ return APR_SUCCESS; >+} >+#endif /* APR_FILES_AS_SOCKETS */ >+ > static void usage(const char *argv0, const char *reason) > { > if (reason) { >@@ -198,7 +247,18 @@ > * since we reset bypass_io after the 1st loop > */ > if (!bypass_io) { >- if (apr_file_read(f_stdin, buf, &nRead) != APR_SUCCESS) { >+ apr_status_t rv; >+ >+ rv = wait_for_io_or_timeout(f_stdin, apr_time_from_sec(1), pool); >+ if (rv == APR_SUCCESS) { >+ if (apr_file_read(f_stdin, buf, &nRead) != APR_SUCCESS) { >+ exit(3); >+ } >+ } >+ else if (APR_STATUS_IS_TIMEUP(rv)) { >+ nRead = 0; >+ } >+ else { > exit(3); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 47345
:
23785
|
23786