The STRDUP macro in NSAPI ends up invoking pthread_get_specific each
time. Since the PHP NSAPI plugin has access to the pool member of the
Session variable, it can use pool_strdup instead of STRDUP.
Please review the attached patch that uses pool_strdup instead of
STRDUP thereby reducing the number of times pthread_getspecific is
invoked when the PHP engine is executing within Sun Web Server.
thanks,
arvi
diff -r 4a4f761ac6eb sapi/nsapi/nsapi.c
--- a/sapi/nsapi/nsapi.c Thu Sep 10 17:46:34 2009 +0530
+++ b/sapi/nsapi/nsapi.c Thu Sep 10 17:59:44 2009 +0530
@@ -123,14 +123,6 @@
/* this parameters to "Service"/"Error" are NSAPI ones which should not be
php.ini keys and are excluded */
static char *nsapi_exclude_from_ini_entries[] = { "fn", "type", "method",
"directive", "code", "reason", "script", "bucket", NULL };
-
-static char *nsapi_strdup(char *str)
-{
- if (str != NULL) {
- return STRDUP(str);
- }
- return NULL;
-}
static void nsapi_free(void *addr)
{
@@ -491,7 +483,7 @@
nsapi_request_context *rc = (nsapi_request_context *)SG(server_context);
/* copy the header, because NSAPI needs reformatting and we do not want
to change the parameter */
- header_name = nsapi_strdup(sapi_header->header);
+ header_name = pool_strdup(rc->sn->pool, sapi_header->header);
/* extract name, this works, if only the header without ':' is given,
too */
if (p = strchr(header_name, ':')) {
@@ -505,7 +497,7 @@
/* remove the header */
param_free(pblock_remove(header_name, rc->rq->srvhdrs));
- nsapi_free(header_name);
+ pool_free(rc->sn->pool, header_name);
return ZEND_HASH_APPLY_KEEP;
}
@@ -529,7 +521,7 @@
case SAPI_HEADER_ADD:
case SAPI_HEADER_REPLACE:
/* copy the header, because NSAPI needs reformatting
and we do not want to change the parameter */
- header_name = nsapi_strdup(sapi_header->header);
+ header_name = pool_strdup(rc->sn->pool,
sapi_header->header);
/* split header and align pointer for content */
header_content = strchr(header_name, ':');
@@ -552,7 +544,7 @@
pblock_nvinsert(header_name, header_content,
rc->rq->srvhdrs);
}
- nsapi_free(header_name);
+ pool_free(rc->sn->pool, header_name);
return SAPI_HEADER_ADD;
default:
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php