summaryrefslogtreecommitdiffstats
path: root/mod_log_sql.c
diff options
context:
space:
mode:
Diffstat (limited to 'mod_log_sql.c')
-rw-r--r--mod_log_sql.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/mod_log_sql.c b/mod_log_sql.c
index faac51e..bce803e 100644
--- a/mod_log_sql.c
+++ b/mod_log_sql.c
@@ -1,4 +1,4 @@
1/* $Id: mod_log_sql.c,v 1.17 2004/03/02 05:34:50 urkle Exp $ */ 1/* $Id: mod_log_sql.c,v 1.18 2004/03/04 05:41:12 urkle Exp $ */
2/* --------* 2/* --------*
3 * DEFINES * 3 * DEFINES *
4 * --------*/ 4 * --------*/
@@ -149,12 +149,13 @@ LOGSQL_DECLARE(void) log_sql_register_item(server_rec *s, apr_pool_t *p,
149static logsql_opendb_ret log_sql_opendb_link(server_rec* s) 149static logsql_opendb_ret log_sql_opendb_link(server_rec* s)
150{ 150{
151 logsql_opendb_ret result; 151 logsql_opendb_ret result;
152 if (global_config.forcepreserve) 152 if (global_config.forcepreserve) {
153 global_config.db.connected = 1; 153 global_config.db.connected = 1;
154 return LOGSQL_OPENDB_PRESERVE; 154 return LOGSQL_OPENDB_PRESERVE;
155 155 }
156 if (global_config.db.connected) 156 if (global_config.db.connected) {
157 return LOGSQL_OPENDB_ALREADY; 157 return LOGSQL_OPENDB_ALREADY;
158 }
158 /* database 159 /* database
159 host 160 host
160 user 161 user
@@ -196,7 +197,7 @@ static void preserve_entry(request_rec *r, const char *query)
196 result = (fp)?0:1; 197 result = (fp)?0:1;
197 #endif 198 #endif
198 if (result != APR_SUCCESS) { 199 if (result != APR_SUCCESS) {
199 log_error(APLOG_MARK,APLOG_ERR,r->server,"mod_log_sql: attempted append of local preserve file but failed."); 200 log_error(APLOG_MARK,APLOG_ERR,r->server,"attempted append of local preserve file '%s' but failed.",cls->preserve_file);
200 } else { 201 } else {
201 #if defined(WITH_APACHE20) 202 #if defined(WITH_APACHE20)
202 apr_file_printf(fp,"%s;\n", query); 203 apr_file_printf(fp,"%s;\n", query);
@@ -205,9 +206,7 @@ static void preserve_entry(request_rec *r, const char *query)
205 fprintf(fp,"%s;\n", query); 206 fprintf(fp,"%s;\n", query);
206 ap_pfclose(r->pool, fp); 207 ap_pfclose(r->pool, fp);
207 #endif 208 #endif
208 #ifdef DEBUG 209 log_error(APLOG_MARK,APLOG_DEBUG,r->server,"mod_log_sql: entry preserved in %s", cls->preserve_file);
209 log_error(APLOG_MARK,APLOG_DEBUG,r->server,"mod_log_sql: entry preserved in %s", cls->preserve_file);
210 #endif
211 } 210 }
212} 211}
213 212
@@ -367,17 +366,16 @@ static void log_sql_child_exit(server_rec *s, apr_pool_t *p)
367/* Child Init */ 366/* Child Init */
368#if defined(WITH_APACHE20) 367#if defined(WITH_APACHE20)
369static void log_sql_child_init(apr_pool_t *p, server_rec *s) 368static void log_sql_child_init(apr_pool_t *p, server_rec *s)
370{
371 apr_pool_cleanup_register(p, NULL, log_sql_close_link, log_sql_close_link);
372}
373
374static int log_sql_open(apr_pool_t *pc, apr_pool_t *p, apr_pool_t *pt, server_rec *s)
375#elif defined(WITH_APACHE13) 369#elif defined(WITH_APACHE13)
376static void log_sql_child_init(server_rec *s, apr_pool_t *p) 370static void log_sql_child_init(server_rec *s, apr_pool_t *p)
377#endif 371#endif
378{ 372{
379 logsql_opendb_ret retval; 373 logsql_opendb_ret retval;
380 /* Open a link to the database */ 374# if defined(WITH_APACHE20)
375 /* Register cleanup hook to close DDB connection (apache 2 doesn't have child_exit) */
376 apr_pool_cleanup_register(p, NULL, log_sql_close_link, log_sql_close_link);
377# endif
378 /* Open a link to the database */
381 retval = log_sql_opendb_link(s); 379 retval = log_sql_opendb_link(s);
382 switch (retval) { 380 switch (retval) {
383 case LOGSQL_OPENDB_FAIL: 381 case LOGSQL_OPENDB_FAIL:
@@ -391,9 +389,6 @@ static void log_sql_child_init(server_rec *s, apr_pool_t *p)
391 log_error(APLOG_MARK,APLOG_DEBUG,s,"mod_log_sql: open_logdb_link said that preservation is forced"); 389 log_error(APLOG_MARK,APLOG_DEBUG,s,"mod_log_sql: open_logdb_link said that preservation is forced");
392 break; 390 break;
393 } 391 }
394#if defined(WITH_APACHE20)
395 return OK;
396#endif
397} 392}
398 393
399/* post_config / module_init */ 394/* post_config / module_init */
@@ -403,12 +398,6 @@ static int log_sql_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptem
403static void log_sql_module_init(server_rec *s, apr_pool_t *p) 398static void log_sql_module_init(server_rec *s, apr_pool_t *p)
404#endif 399#endif
405{ 400{
406 /* Initialize Global configuration */
407 if (!apr_table_get(global_config.db.parms,"socketfile"))
408 apr_table_setn(global_config.db.parms,"socketfile","/tmp/mysql.sock");
409 if (!apr_table_get(global_config.db.parms,"tcpport"))
410 apr_table_setn(global_config.db.parms,"tcpport","3306");
411
412 /* TODO: Add local_address, remote_address, server_name, connection_status */ 401 /* TODO: Add local_address, remote_address, server_name, connection_status */
413 /* Register handlers */ 402 /* Register handlers */
414 log_sql_register_item(s,p,'A', extract_agent, "agent", 1, 1); 403 log_sql_register_item(s,p,'A', extract_agent, "agent", 1, 1);
@@ -1063,10 +1052,6 @@ static const command_rec log_sql_cmds[] = {
1063 (void *)"database", RSRC_CONF, 1052 (void *)"database", RSRC_CONF,
1064 "The name of the database database for logging") 1053 "The name of the database database for logging")
1065 , 1054 ,
1066 AP_INIT_TAKE1("LogSQLDelayedInserts", set_dbparam_slot,
1067 (void *)"insertdelayed", RSRC_CONF,
1068 "Whether to use delayed inserts")
1069 ,
1070 AP_INIT_TAKE1("LogSQLTableType", set_dbparam_slot, 1055 AP_INIT_TAKE1("LogSQLTableType", set_dbparam_slot,
1071 (void *)"tabletype", RSRC_CONF, 1056 (void *)"tabletype", RSRC_CONF,
1072 "What kind of table to create (MyISAM, InnoDB,...) when creating tables") 1057 "What kind of table to create (MyISAM, InnoDB,...) when creating tables")
@@ -1086,7 +1071,6 @@ static const command_rec log_sql_cmds[] = {
1086static void register_hooks(apr_pool_t *p) { 1071static void register_hooks(apr_pool_t *p) {
1087 ap_hook_post_config(log_sql_post_config, NULL, NULL, APR_HOOK_REALLY_FIRST); 1072 ap_hook_post_config(log_sql_post_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
1088 ap_hook_child_init(log_sql_child_init, NULL, NULL, APR_HOOK_MIDDLE); 1073 ap_hook_child_init(log_sql_child_init, NULL, NULL, APR_HOOK_MIDDLE);
1089 ap_hook_open_logs(log_sql_open, NULL, NULL, APR_HOOK_MIDDLE);
1090 ap_hook_log_transaction(log_sql_transaction, NULL, NULL, APR_HOOK_MIDDLE); 1074 ap_hook_log_transaction(log_sql_transaction, NULL, NULL, APR_HOOK_MIDDLE);
1091} 1075}
1092 1076