summaryrefslogtreecommitdiffstats
path: root/apache20.h
diff options
context:
space:
mode:
<Gravatar Edward Rudd Gravatar Edward Rudd
2004-04-29 23:14:02 +0000
2004-04-29 23:14:02 +0000
commit72719c0edc071df875abd5e1a481f1370b62654d (patch)
tree6b775e64b874627079f9b037e5236f8dcf6e25b7 /apache20.h
parent211c72fce4173b76712ae36bc240ca63c4fc1e31 (diff)
update svn:ignore
Diffstat (limited to 'apache20.h')
0 files changed, 0 insertions, 0 deletions
add' style='width: 56.5%;'/>
1 files changed, 35 insertions, 27 deletions
diff --git a/mod_log_sql.c b/mod_log_sql.c
index a247f30..3b4e6f4 100644
--- a/mod_log_sql.c
+++ b/mod_log_sql.c
@@ -164,7 +164,8 @@ static logsql_opendb_ret log_sql_opendb_link(server_rec* s)
164 } 164 }
165 return result; 165 return result;
166 } else { 166 } else {
167 log_error(APLOG_MARK,APLOG_ERR,s,"mod_log_sql: insufficient configuration info to establish database link"); 167 log_error(APLOG_MARK, APLOG_ERR, 0, s,
168 "mod_log_sql: insufficient configuration info to establish database link");
168 return LOGSQL_OPENDB_FAIL; 169 return LOGSQL_OPENDB_FAIL;
169 } 170 }
170} 171}
@@ -188,10 +189,11 @@ static void preserve_entry(request_rec *r, const char *query)
188 FILE *fp; 189 FILE *fp;
189 int result; 190 int result;
190 fp = ap_pfopen(r->pool, cls->preserve_file, "a"); 191 fp = ap_pfopen(r->pool, cls->preserve_file, "a");
191 result = (fp)?0:1; 192 result = (fp)?0:errno;
192 #endif 193 #endif
193 if (result != APR_SUCCESS) { 194 if (result != APR_SUCCESS) {
194 log_error(APLOG_MARK,APLOG_ERR,r->server,"attempted append of local preserve file '%s' but failed.",cls->preserve_file); 195 log_error(APLOG_MARK, APLOG_ERR, result, r->server,
196 "attempted append of local preserve file '%s' but failed.",cls->preserve_file);
195 } else { 197 } else {
196 #if defined(WITH_APACHE20) 198 #if defined(WITH_APACHE20)
197 apr_file_printf(fp,"%s;\n", query); 199 apr_file_printf(fp,"%s;\n", query);
@@ -200,7 +202,8 @@ static void preserve_entry(request_rec *r, const char *query)
200 fprintf(fp,"%s;\n", query); 202 fprintf(fp,"%s;\n", query);
201 ap_pfclose(r->pool, fp); 203 ap_pfclose(r->pool, fp);
202 #endif 204 #endif
203 log_error(APLOG_MARK,APLOG_DEBUG,r->server,"mod_log_sql: entry preserved in %s", cls->preserve_file); 205 log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
206 "mod_log_sql: entry preserved in %s", cls->preserve_file);
204 } 207 }
205} 208}
206 209
@@ -403,14 +406,17 @@ static void log_sql_child_init(server_rec *s, apr_pool_t *p)
403 retval = log_sql_opendb_link(s); 406 retval = log_sql_opendb_link(s);
404 switch (retval) { 407 switch (retval) {
405 case LOGSQL_OPENDB_FAIL: 408 case LOGSQL_OPENDB_FAIL:
406 log_error(APLOG_MARK,APLOG_ERR,s,"mod_log_sql: child spawned but unable to open database link"); 409 log_error(APLOG_MARK, APLOG_ERR, 0, s,
410 "mod_log_sql: child spawned but unable to open database link");
407 break; 411 break;
408 case LOGSQL_OPENDB_SUCCESS: 412 case LOGSQL_OPENDB_SUCCESS:
409 case LOGSQL_OPENDB_ALREADY: 413 case LOGSQL_OPENDB_ALREADY:
410 log_error(APLOG_MARK,APLOG_DEBUG,s,"mod_log_sql: open_logdb_link successful"); 414 log_error(APLOG_MARK,APLOG_DEBUG,0, s,
415 "mod_log_sql: open_logdb_link successful");
411 break; 416 break;
412 case LOGSQL_OPENDB_PRESERVE: 417 case LOGSQL_OPENDB_PRESERVE:
413 log_error(APLOG_MARK,APLOG_DEBUG,s,"mod_log_sql: open_logdb_link said that preservation is forced"); 418 log_error(APLOG_MARK,APLOG_DEBUG, 0, s,
419 "mod_log_sql: open_logdb_link said that preservation is forced");
414 break; 420 break;
415 } 421 }
416} 422}
@@ -488,7 +494,7 @@ static logsql_query_ret safe_sql_insert(request_rec *r, logsql_tabletype table_t
488 global_config.db.connected = 0; 494 global_config.db.connected = 0;
489 /* re-open the connection and try again */ 495 /* re-open the connection and try again */
490 if (log_sql_opendb_link(r->server) != LOGSQL_OPENDB_FAIL) { 496 if (log_sql_opendb_link(r->server) != LOGSQL_OPENDB_FAIL) {
491 log_error(APLOG_MARK,APLOG_ERR,r->server,"db reconnect successful"); 497 log_error(APLOG_MARK,APLOG_NOTICE,0, r->server,"db reconnect successful");
492# if defined(WITH_APACHE20) 498# if defined(WITH_APACHE20)
493 apr_sleep(apr_time_from_sec(0.25)); /* pause for a quarter second */ 499 apr_sleep(apr_time_from_sec(0.25)); /* pause for a quarter second */
494# elif defined(WITH_APACHE13) 500# elif defined(WITH_APACHE13)
@@ -499,7 +505,7 @@ static logsql_query_ret safe_sql_insert(request_rec *r, logsql_tabletype table_t
499 delay.tv_nsec = 250000000; /* pause for a quarter second */ 505 delay.tv_nsec = 250000000; /* pause for a quarter second */
500 nanoret = nanosleep(&delay, &remainder); 506 nanoret = nanosleep(&delay, &remainder);
501 if (nanoret && errno != EINTR) { 507 if (nanoret && errno != EINTR) {
502 log_error(APLOG_MARK,APLOG_ERR,r->server,"nanosleep unsuccessful"); 508 log_error(APLOG_MARK,APLOG_ERR, errno, r->server,"nanosleep unsuccessful");
503 } 509 }
504 } 510 }
505# endif 511# endif
@@ -507,50 +513,52 @@ static logsql_query_ret safe_sql_insert(request_rec *r, logsql_tabletype table_t
507 if (result == LOGSQL_QUERY_SUCCESS) { 513 if (result == LOGSQL_QUERY_SUCCESS) {
508 return LOGSQL_QUERY_SUCCESS; 514 return LOGSQL_QUERY_SUCCESS;
509 } else { 515 } else {
510 log_error(APLOG_MARK,APLOG_ERR,r->server,"second attempt failed"); 516 log_error(APLOG_MARK,APLOG_ERR,0,r->server,"second attempt failed");
511 preserve_entry(r, query); 517 preserve_entry(r, query);
512 return LOGSQL_QUERY_PRESERVED; 518 return LOGSQL_QUERY_PRESERVED;
513 } 519 }
514 } else { 520 } else {
515 log_error(APLOG_MARK,APLOG_ERR,r->server,"reconnect failed, unable to reach database. SQL logging stopped until child regains a db connection."); 521 log_error(APLOG_MARK,APLOG_ERR,0,r->server,
516 log_error(APLOG_MARK,APLOG_ERR,r->server,"log entries are being preserved in %s",cls->preserve_file); 522 "reconnect failed, unable to reach database. SQL logging stopped until child regains a db connection.");
523 log_error(APLOG_MARK,APLOG_ERR,0,r->server,
524 "log entries are being preserved in %s",cls->preserve_file);
517 preserve_entry(r, query); 525 preserve_entry(r, query);
518 return LOGSQL_QUERY_PRESERVED; 526 return LOGSQL_QUERY_PRESERVED;
519 } 527 }
520 break; 528 break;
521 case LOGSQL_QUERY_NOTABLE: 529 case LOGSQL_QUERY_NOTABLE:
522 if (global_config.createtables) { 530 if (global_config.createtables) {
523 log_error(APLOG_MARK,APLOG_ERR,r->server, 531 log_error(APLOG_MARK,APLOG_ERR,0,r->server,
524 "table doesn't exist...creating now"); 532 "table doesn't exist...creating now");
525 if ((result = log_sql_mysql_create(r, &global_config.db, table_type, 533 if ((result = log_sql_mysql_create(r, &global_config.db, table_type,
526 table_name))!=LOGSQL_TABLE_SUCCESS) { 534 table_name))!=LOGSQL_TABLE_SUCCESS) {
527 log_error(APLOG_MARK,APLOG_ERR,r->server, 535 log_error(APLOG_MARK,APLOG_ERR,result,r->server,
528 "child attempted but failed to create one or more tables for %s, preserving query", ap_get_server_name(r)); 536 "child attempted but failed to create one or more tables for %s, preserving query", ap_get_server_name(r));
529 preserve_entry(r, query); 537 preserve_entry(r, query);
530 return LOGSQL_QUERY_PRESERVED; 538 return LOGSQL_QUERY_PRESERVED;
531 } else { 539 } else {
532 log_error(APLOG_MARK,APLOG_ERR,r->server, 540 log_error(APLOG_MARK,APLOG_ERR,result, r->server,
533 "tables successfully created - retrying query"); 541 "tables successfully created - retrying query");
534 if ((result = log_sql_mysql_query(r,&global_config.db,query))!=LOGSQL_QUERY_SUCCESS) { 542 if ((result = log_sql_mysql_query(r,&global_config.db,query))!=LOGSQL_QUERY_SUCCESS) {
535 log_error(APLOG_MARK,APLOG_ERR,r->server, 543 log_error(APLOG_MARK,APLOG_ERR,result, r->server,
536 "giving up, preserving query"); 544 "giving up, preserving query");
537 preserve_entry(r, query); 545 preserve_entry(r, query);
538 return LOGSQL_QUERY_PRESERVED; 546 return LOGSQL_QUERY_PRESERVED;
539 } else { 547 } else {
540 log_error(APLOG_MARK,APLOG_ERR,r->server, 548 log_error(APLOG_MARK,APLOG_NOTICE,0, r->server,
541 "query successful after table creation"); 549 "query successful after table creation");
542 return LOGSQL_QUERY_SUCCESS; 550 return LOGSQL_QUERY_SUCCESS;
543 } 551 }
544 } 552 }
545