diff options
author | pgollucci <pgollucci@FreeBSD.org> | 2010-09-07 03:29:52 +0800 |
---|---|---|
committer | pgollucci <pgollucci@FreeBSD.org> | 2010-09-07 03:29:52 +0800 |
commit | 6c2b18cee7913d8cf9f1ced4e62361a4a4890d32 (patch) | |
tree | c3a0017c1246478055507de628ac9780e8a01ef4 /www | |
parent | f469f3011d513e188db3df02153f9782e1969a5d (diff) | |
download | freebsd-ports-gnome-6c2b18cee7913d8cf9f1ced4e62361a4a4890d32.tar.gz freebsd-ports-gnome-6c2b18cee7913d8cf9f1ced4e62361a4a4890d32.tar.zst freebsd-ports-gnome-6c2b18cee7913d8cf9f1ced4e62361a4a4890d32.zip |
- Fix bytes_sent bug [1]
- Fix a apache scoreboard bug
PR: ports/150296, ports/121134
Submitted by: Charles Sprickman <css@morefoo.com>
Obtained from: Fernando Kiernan, http://www.imagenesdigitales.com.ar/ [1]
Diffstat (limited to 'www')
-rw-r--r-- | www/mod_log_sql2-dtc/Makefile | 2 | ||||
-rw-r--r-- | www/mod_log_sql2-dtc/files/patch-mod_log_sql.c | 46 | ||||
-rw-r--r-- | www/mod_log_sql2-dtc/files/patch-mod_log_sql.h | 13 | ||||
-rw-r--r-- | www/mod_log_sql2-dtc/files/patch-mod_log_sql_mysql.c | 23 | ||||
-rw-r--r-- | www/mod_log_sql2-dtc/files/patch-mod_log_sql_pgsql.c | 23 |
5 files changed, 91 insertions, 16 deletions
diff --git a/www/mod_log_sql2-dtc/Makefile b/www/mod_log_sql2-dtc/Makefile index 45cd1fa25416..7664811a1a26 100644 --- a/www/mod_log_sql2-dtc/Makefile +++ b/www/mod_log_sql2-dtc/Makefile @@ -6,7 +6,7 @@ PORTNAME= mod_log_sql PORTVERSION= 1.101 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= www databases MASTER_SITES= http://www.outoforder.cc/downloads/${PORTNAME}/ PKGNAMEPREFIX= ${APACHE_PKGNAMEPREFIX} diff --git a/www/mod_log_sql2-dtc/files/patch-mod_log_sql.c b/www/mod_log_sql2-dtc/files/patch-mod_log_sql.c index 164d2c81f918..29769e9d6d8f 100644 --- a/www/mod_log_sql2-dtc/files/patch-mod_log_sql.c +++ b/www/mod_log_sql2-dtc/files/patch-mod_log_sql.c @@ -1,5 +1,5 @@ ---- ./mod_log_sql.c.orig 2006-11-07 02:43:23.000000000 +0000 -+++ ./mod_log_sql.c 2009-12-27 01:39:36.463108543 +0000 +--- mod_log_sql.c.orig 2006-11-06 23:43:23.000000000 -0300 ++++ mod_log_sql.c 2010-08-20 17:09:29.000000000 -0300 @@ -37,6 +37,11 @@ #define DEFAULT_HOUT_TABLE_NAME "headers_out" #define DEFAULT_COOKIE_TABLE_NAME "cookies" @@ -22,7 +22,18 @@ } logsql_state; -@@ -648,6 +656,9 @@ +@@ -460,6 +468,10 @@ + } + } + ++static char* log_sql_insert_enclose(char* insert_close,request_rec *r) { ++ return global_config.driver->enclose_insert_ignore(insert_close,r); ++} ++ + /* post_config / module_init */ + #if defined(WITH_APACHE20) + static int log_sql_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) +@@ -648,6 +660,9 @@ cls->hout_table_name = DEFAULT_HOUT_TABLE_NAME; cls->cookie_table_name = DEFAULT_COOKIE_TABLE_NAME; cls->preserve_file = DEFAULT_PRESERVE_FILE; @@ -32,7 +43,7 @@ cls->transfer_ignore_list = apr_array_make(p, 1, sizeof(char *)); cls->transfer_accept_list = apr_array_make(p, 1, sizeof(char *)); -@@ -759,6 +770,15 @@ +@@ -759,6 +774,15 @@ if (child->cookie_table_name == DEFAULT_COOKIE_TABLE_NAME) child->cookie_table_name = parent->cookie_table_name; @@ -48,7 +59,7 @@ DO_MERGE_ARRAY(parent->transfer_ignore_list, child->transfer_ignore_list, subp); DO_MERGE_ARRAY(parent->transfer_accept_list, child->transfer_accept_list, subp); DO_MERGE_ARRAY(parent->remhost_ignore_list, child->remhost_ignore_list, subp); -@@ -790,6 +810,11 @@ +@@ -790,6 +814,10 @@ const char *hout_tablename = cls->hout_table_name; const char *hin_tablename = cls->hin_table_name; const char *cookie_tablename = cls->cookie_table_name; @@ -56,11 +67,10 @@ + const char *scoreboard_subdomain = cls->scoreboard_subdomain; + const char *scoreboard_table_name = cls->scoreboard_table_name; + struct timeval now_time; -+ if (global_config.driver == NULL) { return OK; } -@@ -1110,6 +1135,29 @@ +@@ -1110,6 +1138,39 @@ if (cookie_query) safe_sql_insert(orig, LOGSQL_TABLE_COOKIES,cookie_tablename,cookie_query); @@ -69,28 +79,38 @@ + { + const char *score_query_insert; + const char *score_query_update; ++ const char *score_query_insert_ignore; + struct tm *ptr; + time_t tm; + char sql_month[60]; + char sql_year[60]; + char a[60]; ++ char* bytes_sent; + + tm = time(NULL); + ptr = localtime(&tm); + strftime(sql_month ,100 , "\%m",ptr); + strftime(sql_year ,100 , "\%Y",ptr); + -+ score_query_insert = apr_psprintf(r->pool, "insert ignore into %s (domain,vhost,month,year,count_impressions) values ('%s','%s','%s','%s','0')" ++ score_query_insert = apr_psprintf(r->pool, " %s (domain,vhost,month,year,count_impressions) values ('%s','%s','%s','%s','0')" + ,scoreboard_table_name,scoreboard_domain,scoreboard_subdomain,sql_month,sql_year); -+ safe_sql_insert(orig,LOGSQL_TABLE_SCORE,"score_board",score_query_insert); -+ score_query_update = apr_psprintf(r->pool, "update %s SET count_impressions = count_impressions+1, bytes_sent = bytes_sent+%s WHERE domain='%s' AND vhost='%s' AND month='%s' AND year='%s'" -+ ,scoreboard_table_name,extract_bytes_sent(r, a),scoreboard_domain,scoreboard_subdomain,sql_month,sql_year); -+ safe_sql_insert(orig,LOGSQL_TABLE_SCORE,"score_board",score_query_update); ++ // Add insert ignore into ... ; ++ // or begin; insert into ... ; commit; ++ // depending on the drive used ++ score_query_insert_ignore = log_sql_insert_enclose(score_query_insert,r); ++ ++ safe_sql_insert(orig,LOGSQL_TABLE_SCORE,"score_board",score_query_insert_ignore); ++ bytes_sent = extract_bytes_sent(r, a); ++ if (bytes_sent[0] != '-'){ ++ score_query_update = apr_psprintf(r->pool, "update %s SET count_impressions = count_impressions+1, bytes_sent = bytes_sent+%s WHERE domain='%s' AND vhost='%s' AND month='%s' AND year='%s'" ++ ,scoreboard_table_name,extract_bytes_sent(r, a),scoreboard_domain,scoreboard_subdomain,sql_month,sql_year); ++ safe_sql_insert(orig,LOGSQL_TABLE_SCORE,"score_board",score_query_update); ++ } + } return OK; } } -@@ -1171,6 +1219,18 @@ +@@ -1171,6 +1232,18 @@ (void *)APR_OFFSETOF(logsql_state, cookie_table_name), RSRC_CONF, "The database table that holds the cookie info") , diff --git a/www/mod_log_sql2-dtc/files/patch-mod_log_sql.h b/www/mod_log_sql2-dtc/files/patch-mod_log_sql.h index 29960604dc15..4e5d5b6d9ecf 100644 --- a/www/mod_log_sql2-dtc/files/patch-mod_log_sql.h +++ b/www/mod_log_sql2-dtc/files/patch-mod_log_sql.h @@ -1,5 +1,5 @@ ---- mod_log_sql.h.orig Thu Feb 16 05:32:07 2006 -+++ mod_log_sql.h Thu Feb 16 05:32:33 2006 +--- ./mod_log_sql.h.orig 2007-08-06 00:03:47.000000000 +0800 ++++ ./mod_log_sql.h 2007-08-06 00:52:49.000000000 +0800 @@ -67,7 +67,8 @@ LOGSQL_TABLE_NOTES, LOGSQL_TABLE_HEADERSOUT, @@ -10,3 +10,12 @@ } logsql_tabletype; /* All Tables */ +@@ -96,6 +97,8 @@ + /* create a SQL table named table_name of table_type */ + logsql_table_ret (*create_table)(request_rec *r, logsql_dbconnection *db, + logsql_tabletype table_type, const char *table_name); ++ /* enclose an insert query with parameters to make it an insert ignore */ ++ const char * (*enclose_insert_ignore)(const char* insert_query,request_rec *r); + } logsql_dbdriver; + + LOGSQL_DECLARE(void) log_sql_register_driver(apr_pool_t *p, diff --git a/www/mod_log_sql2-dtc/files/patch-mod_log_sql_mysql.c b/www/mod_log_sql2-dtc/files/patch-mod_log_sql_mysql.c new file mode 100644 index 000000000000..cdeccda5dd2e --- /dev/null +++ b/www/mod_log_sql2-dtc/files/patch-mod_log_sql_mysql.c @@ -0,0 +1,23 @@ +--- ./mod_log_sql_mysql.c.orig 2007-08-06 00:55:32.000000000 +0800 ++++ ./mod_log_sql_mysql.c 2007-08-06 00:52:59.000000000 +0800 +@@ -250,6 +250,10 @@ + return LOGSQL_TABLE_SUCCESS; + } + ++static char *make_mysql_ignore_insert(char * insert_query, request_rec *r) { ++ return apr_psprintf(r->pool, "insert ignore into %s ;",insert_query); ++} ++ + static const char *supported_drivers[] = {"mysql",NULL}; + static logsql_dbdriver mysql_driver = { + "mysql", +@@ -258,7 +262,8 @@ + log_sql_mysql_close, /* close DB connection */ + log_sql_mysql_escape, /* escape query */ + log_sql_mysql_query, /* insert query */ +- log_sql_mysql_create /* create table */ ++ log_sql_mysql_create, /* create table */ ++ make_mysql_ignore_insert /* insert ignore */ + }; + + LOGSQL_REGISTER(mysql) { diff --git a/www/mod_log_sql2-dtc/files/patch-mod_log_sql_pgsql.c b/www/mod_log_sql2-dtc/files/patch-mod_log_sql_pgsql.c new file mode 100644 index 000000000000..421b535524e6 --- /dev/null +++ b/www/mod_log_sql2-dtc/files/patch-mod_log_sql_pgsql.c @@ -0,0 +1,23 @@ +--- ./mod_log_sql_pgsql.c.orig 2007-08-06 00:55:44.000000000 +0800 ++++ ./mod_log_sql_pgsql.c 2007-08-06 00:52:55.000000000 +0800 +@@ -235,6 +235,10 @@ + return LOGSQL_TABLE_SUCCESS; + } + ++static char *make_pgsql_ignore_insert(char * insert_query, request_rec *r) { ++ return apr_psprintf(r->pool, "begin ; insert into %s ; commit ;",insert_query); ++} ++ + static char *supported_drivers[] = {"pgsql",NULL}; + static logsql_dbdriver pgsql_driver = { + supported_drivers, +@@ -242,7 +246,8 @@ + log_sql_pgsql_close, /* close DB connection */ + log_sql_pgsql_escape, /* escape query */ + log_sql_pgsql_query, /* insert query */ +- log_sql_pgsql_create /* create table */ ++ log_sql_pgsql_create, /* create table */ ++ make_pgsql_ignore_insert /* insert ignore statement */ + }; + + LOGSQL_REGISTER(pgsql) { |