summaryrefslogtreecommitdiffstats
path: root/mod_log_sql_mysql.c
diff options
context:
space:
mode:
authorGravatar Edward Rudd 2004-04-29 21:19:30 +0000
committerGravatar Edward Rudd 2004-04-29 21:19:30 +0000
commit7c378cc1fac4e9fec1ca32d8d314ea86761a7404 (patch)
treebc82e7e864ce3978904bc1cb9d9eb6fa52e95dde /mod_log_sql_mysql.c
parentbe0fe66bcd84e4660b9dba4c1f1f20a649b66c61 (diff)
win32 updates and build script
added LogSQLDisablePreserve set default of preserve file to root_relative logs/mod_log_sql-preserve
Diffstat (limited to 'mod_log_sql_mysql.c')
-rw-r--r--mod_log_sql_mysql.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/mod_log_sql_mysql.c b/mod_log_sql_mysql.c
index 3749d64..e8a149e 100644
--- a/mod_log_sql_mysql.c
+++ b/mod_log_sql_mysql.c
@@ -109,13 +109,22 @@ static const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p,
109 return from_str; 109 return from_str;
110 } 110 }
111} 111}
112 112#if defined(WIN32)
113#define SIGNAL_GRAB
114#define SIGNAL_RELEASE
115#define SIGNAL_VAR
116#else
117#define SIGNAL_VAR void (*handler) (int)
118#define SIGNAL_GRAB handler = signal(SIGPIPE, SIG_IGN)
119#define SIGNAL_RELEASE signal(SIGPIPE, handler);
120#endif
113/* Run a mysql insert query and return a categorized error or success */ 121/* Run a mysql insert query and return a categorized error or success */
114static logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *db, 122static logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *db,
115 const char *query) 123 const char *query)
116{ 124{
117 int retval; 125 int retval;
118 void (*handler) (int); 126 SIGNAL_VAR
127
119 unsigned int real_error = 0; 128 unsigned int real_error = 0;
120 /*const char *real_error_str = NULL;*/ 129 /*const char *real_error_str = NULL;*/
121 130
@@ -124,12 +133,13 @@ static logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *
124 if (!dblink) { 133 if (!dblink) {
125 return LOGSQL_QUERY_NOLINK; 134 return LOGSQL_QUERY_NOLINK;
126 } 135 }
136
127 /* A failed mysql_query() may send a SIGPIPE, so we ignore that signal momentarily. */ 137 /* A failed mysql_query() may send a SIGPIPE, so we ignore that signal momentarily. */
128 handler = signal(SIGPIPE, SIG_IGN); 138 SIGNAL_GRAB
129 139
130 /* Run the query */ 140 /* Run the query */
131 if (!(retval = mysql_query(dblink, query))) { 141 if (!(retval = mysql_query(dblink, query))) {
132 signal(SIGPIPE, handler); 142 SIGNAL_RELEASE
133 return LOGSQL_QUERY_SUCCESS; 143 return LOGSQL_QUERY_SUCCESS;
134 } 144 }
135 /* Check to see if the error is "nonexistent table" */ 145 /* Check to see if the error is "nonexistent table" */
@@ -138,12 +148,12 @@ static logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *
138 if (real_error == ER_NO_SUCH_TABLE) { 148 if (real_error == ER_NO_SUCH_TABLE) {
139 log_error(APLOG_MARK,APLOG_ERR,0, r->server,"table does not exist, preserving query"); 149 log_error(APLOG_MARK,APLOG_ERR,0, r->server,"table does not exist, preserving query");
140 /* Restore SIGPIPE to its original handler function */ 150 /* Restore SIGPIPE to its original handler function */
141 signal(SIGPIPE, handler); 151 SIGNAL_RELEASE
142 return LOGSQL_QUERY_NOTABLE; 152 return LOGSQL_QUERY_NOTABLE;
143 } 153 }
144 154
145 /* Restore SIGPIPE to its original handler function */ 155 /* Restore SIGPIPE to its original handler function */
146 signal(SIGPIPE, handler); 156 SIGNAL_RELEASE
147 return LOGSQL_QUERY_FAIL; 157 return LOGSQL_QUERY_FAIL;
148} 158}
149 159
@@ -153,7 +163,7 @@ static logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection
153{ 163{
154 int retval; 164 int retval;
155 const char *tabletype = apr_table_get(db->parms,"tabletype"); 165 const char *tabletype = apr_table_get(db->parms,"tabletype");
156 void (*handler) (int); 166 SIGNAL_VAR
157 char *type_suffix = NULL; 167 char *type_suffix = NULL;
158 168
159 char *create_prefix = "create table if not exists `"; 169 char *create_prefix = "create table if not exists `";
@@ -220,16 +230,16 @@ static logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection
220 return LOGSQL_QUERY_NOLINK; 230 return LOGSQL_QUERY_NOLINK;
221 } 231 }
222 /* A failed mysql_query() may send a SIGPIPE, so we ignore that signal momentarily. */ 232 /* A failed mysql_query() may send a SIGPIPE, so we ignore that signal momentarily. */
223 handler = signal(SIGPIPE, SIG_IGN); 233 SIGNAL_GRAB
224 234
225 /* Run the create query */ 235 /* Run the create query */
226 if ((retval = mysql_query(dblink, create_sql))) { 236 if ((retval = mysql_query(dblink, create_sql))) {
227 log_error(APLOG_MARK,APLOG_ERR,0, r->server,"failed to create table: %s", 237 log_error(APLOG_MARK,APLOG_ERR,0, r->server,"failed to create table: %s",
228 table_name); 238 table_name);
229 signal(SIGPIPE, handler); 239 SIGNAL_RELEASE
230 return LOGSQL_TABLE_FAIL; 240 return LOGSQL_TABLE_FAIL;
231 } 241 }
232 signal(SIGPIPE, handler); 242 SIGNAL_RELEASE
233 return LOGSQL_TABLE_SUCCESS; 243 return LOGSQL_TABLE_SUCCESS;
234} 244}
235 245