Author: poeml Date: Fri Mar 26 23:58:09 2010 New Revision: 75 URL: http://svn.mirrorbrain.org/viewvc/mod_asn?rev=75&view=rev Log: mod_asn: - bump version (1.5) - For more efficient database connection usage, mod_asn now closes the used connection when its handler quits. Before, a connection with lifetime of the request was acquired; if a long-running handler runs after mod_asn, this could mean that the connection is blocked for other threads until the end of the request. This could occur, for instance, when mod_mirrorbrain ran later, but exited early because a file was supposed to be delivered directly. Modified: trunk/mod_asn.c Modified: trunk/mod_asn.c URL: http://svn.mirrorbrain.org/viewvc/mod_asn/trunk/mod_asn.c?rev=75&r1=74&r2=75&view=diff ============================================================================== --- trunk/mod_asn.c (original) +++ trunk/mod_asn.c Fri Mar 26 23:58:09 2010 _at_@ -46,7 +46,7 @@ #define UNSET (-1) #endif -#define MOD_ASN_VER "1.4" +#define MOD_ASN_VER "1.5" #define VERSION_COMPONENT "mod_asn/"MOD_ASN_VER /* from ssl/ssl_engine_config.c */ _at_@ -80,8 +80,9 @@ -/* optional function - look it up once in post_config */ -static ap_dbd_t *(*asn_dbd_acquire_fn)(request_rec*) = NULL; +/* optional functions - look them up once in post_config */ +static ap_dbd_t *(*asn_dbd_open_fn)(apr_pool_t*, server_rec*) = NULL; +static void (*asn_dbd_close_fn)(server_rec*, ap_dbd_t*) = NULL; static void (*asn_dbd_prepare_fn)(server_rec*, const char*, const char*) = NULL; _at_@ -114,10 +115,11 @@ asn_dbd_prepare_fn = APR_RETRIEVE_OPTIONAL_FN(ap_dbd_prepare); if (asn_dbd_prepare_fn == NULL) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, - "[mod_asn] You must load mod_dbd to enable mod_asn functions"); + "[mod_asn] You must load mod_dbd to enable mod_asn to work"); return HTTP_INTERNAL_SERVER_ERROR; } - asn_dbd_acquire_fn = APR_RETRIEVE_OPTIONAL_FN(ap_dbd_acquire); + asn_dbd_open_fn = APR_RETRIEVE_OPTIONAL_FN(ap_dbd_open); + asn_dbd_close_fn = APR_RETRIEVE_OPTIONAL_FN(ap_dbd_close); } /* prepare DBD SQL statements */ _at_@ -268,7 +270,7 @@ ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[mod_asn] No database query prepared!"); return DECLINED; } - ap_dbd_t *dbd = asn_dbd_acquire_fn(r); + ap_dbd_t *dbd = asn_dbd_open_fn(r->pool, r->server); if (dbd == NULL) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[mod_asn] Error acquiring database connection"); _at_@ -279,6 +281,7 @@ statement = apr_hash_get(dbd->prepared, scfg->query_prep, APR_HASH_KEY_STRING); if (statement == NULL) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[mod_asn] Could not get prepared statement!"); + asn_dbd_close_fn(r->server, dbd); return DECLINED; } _at_@ -294,6 +297,7 @@ if (!clientip) { debugLog(r, cfg, "empty client ip... not doing a lookup"); + asn_dbd_close_fn(r->server, dbd); return DECLINED; } _at_@ -304,6 +308,7 @@ clientip, NULL) != 0) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "[mod_asn] Error looking up %s in database", clientip); + asn_dbd_close_fn(r->server, dbd); return DECLINED; } _at_@ -326,6 +331,7 @@ "[mod_asn] Error retrieving row from database for %s: %s", clientip, (errmsg ? errmsg : "[???]")); } + asn_dbd_close_fn(r->server, dbd); return DECLINED; } _at_@ -344,6 +350,7 @@ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "[mod_asn] found one row too much looking up %s", clientip); + asn_dbd_close_fn(r->server, dbd); return DECLINED; } _at_@ -357,6 +364,7 @@ apr_table_setn(r->err_headers_out, "X-AS", apr_pstrdup(r->pool, as)); } + asn_dbd_close_fn(r->server, dbd); return OK; } _______________________________________________ mirrorbrain-commits mailing list Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/ Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Fri Mar 26 2010 - 22:58:13 GMT
This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT