On 11.01.2009 15:53, Ruediger Pluem wrote:
On 01/11/2009 03:05 PM, [email protected] wrote:
Author: rjung
Date: Sun Jan 11 06:05:39 2009
New Revision: 733476
URL: http://svn.apache.org/viewvc?rev=733476&view=rev
Log:
Refactor rotatelogs to allow easier implementation
of signal triggered log rotation.
- move code into new functions checkRotate() and doRotate()
- bundle config data and runtime data in two structs to
allow easier passing to functions
- Simplify bypass_io logic as a first use case for doRotate
and rename flag to force_open to reflect the new logic
Modified:
httpd/httpd/trunk/support/rotatelogs.c
Modified: httpd/httpd/trunk/support/rotatelogs.c
URL:
http://svn.apache.org/viewvc/httpd/httpd/trunk/support/rotatelogs.c?rev=733476&r1=733475&r2=733476&view=diff
==============================================================================
--- httpd/httpd/trunk/support/rotatelogs.c (original)
+++ httpd/httpd/trunk/support/rotatelogs.c Sun Jan 11 06:05:39 2009
@@ -64,6 +64,37 @@
#define MAX_PATH 1024
#endif
+typedef struct rotate_config rotate_config_t;
+
+struct rotate_config {
+ unsigned int sRotation;
+ int tRotation;
+ int utc_offset;
+ int use_localtime;
+ int use_strftime;
+ int force_open;
+ const char *szLogRoot;
+};
+
+typedef struct rotate_status rotate_status_t;
+
+struct rotate_status {
+ apr_pool_t *pool;
+ apr_pool_t *pfile;
+ apr_pool_t *pfile_prev;
+ apr_file_t *nLogFD;
+ apr_file_t *nLogFDprev;
+ char filename[MAX_PATH];
+ char errbuf[ERRMSGSZ];
+ int needsRotate;
+ int tLogEnd;
+ int now;
+ int nMessCount;
+};
+
+static rotate_config_t config;
+static rotate_status_t status;
Why do they need to be global?
I need them in the signal handler which will be introduced as the next
step. The signal handler will allow to trigger rotation from outside.
...
+void checkRotate(rotate_config_t *config, rotate_status_t *status) {
+
+ if (status->nLogFD == NULL)
+ return;
No need to do further checks for status->nLogFD != NULL below.
Right, will be gone in the next commit.