summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Edward Rudd 2004-08-23 05:41:37 +0000
committerGravatar Edward Rudd 2004-08-23 05:41:37 +0000
commit104bb4c049e8a672af96977434bda814feee83b8 (patch)
tree8a6f307bc5cd60c625b8c57233f93ac8b75161e5
parentceb9aca770cf5b5464522fc032eb0f1cf73d6867 (diff)
fixes by Douglas E. Warner to fix "NULL" fields.
finally fixed the annoying reconnect mysql segfault.
-rw-r--r--mod_log_sql_mysql.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/mod_log_sql_mysql.c b/mod_log_sql_mysql.c
index fd1668a..5c426c9 100644
--- a/mod_log_sql_mysql.c
+++ b/mod_log_sql_mysql.c
@@ -67,6 +67,8 @@ static logsql_opendb_ret log_sql_mysql_connect(server_rec *s, logsql_dbconnectio
67static void log_sql_mysql_close(logsql_dbconnection *db) 67static void log_sql_mysql_close(logsql_dbconnection *db)
68{ 68{
69 mysql_close((MYSQL *)db->handle); 69 mysql_close((MYSQL *)db->handle);
70 /* mysql_close frees this data so NULL it out incase we reconnect later */
71 db->handle=NULL;
70} 72}
71 73
72/* Routine to escape the 'dangerous' characters that would otherwise 74/* Routine to escape the 'dangerous' characters that would otherwise
@@ -75,8 +77,9 @@ static void log_sql_mysql_close(logsql_dbconnection *db)
75static const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p, 77static const char *log_sql_mysql_escape(const char *from_str, apr_pool_t *p,
76 logsql_dbconnection *db) 78 logsql_dbconnection *db)
77{ 79{
78 if (!from_str) 80 /* Return "NULL" for empty strings */
79 return NULL; 81 if (!from_str || strlen(from_str) == 0)
82 return "NULL";
80 else { 83 else {
81 char *to_str; 84 char *to_str;
82 unsigned long length = strlen(from_str); 85 unsigned long length = strlen(from_str);
@@ -141,9 +144,11 @@ static logsql_query_ret log_sql_mysql_query(request_rec *r,logsql_dbconnection *
141 144
142 /* Run the query */ 145 /* Run the query */
143 if (!(retval = mysql_query(dblink, query))) { 146 if (!(retval = mysql_query(dblink, query))) {
144 SIGNAL_RELEASE 147 SIGNAL_RELEASE
145 return LOGSQL_QUERY_SUCCESS; 148 return LOGSQL_QUERY_SUCCESS;
146 } 149 }
150 log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
151 "mysql_query returned (%d)", retval);
147 /* Check to see if the error is "nonexistent table" */ 152 /* Check to see if the error is "nonexistent table" */
148 real_error = mysql_errno(dblink); 153 real_error = mysql_errno(dblink);
149 154
@@ -186,7 +191,7 @@ static logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection
186 bytes_sent int unsigned,\ 191 bytes_sent int unsigned,\
187 child_pid smallint unsigned,\ 192 child_pid smallint unsigned,\
188 cookie varchar(255),\ 193 cookie varchar(255),\
189 machine_id varchar(25),\ 194 machine_id varchar(25),\
190 request_file varchar(255),\ 195 request_file varchar(255),\
191 referer varchar(255),\ 196 referer varchar(255),\
192 remote_host varchar(50),\ 197 remote_host varchar(50),\
@@ -198,7 +203,7 @@ static logsql_table_ret log_sql_mysql_create(request_rec *r, logsql_dbconnection
198 request_protocol varchar(10),\ 203 request_protocol varchar(10),\
199 request_time char(28),\ 204 request_time char(28),\
200 request_uri varchar(255),\ 205 request_uri varchar(255),\
201 request_args varchar(255),\ 206 request_args varchar(255),\
202 server_port smallint unsigned,\ 207 server_port smallint unsigned,\
203 ssl_cipher varchar(25),\ 208 ssl_cipher varchar(25),\
204 ssl_keysize smallint unsigned,\ 209 ssl_keysize smallint unsigned,\