From: Antony Dovgal Date: Thu, 15 Jul 2004 11:00:14 +0000 (+0000) Subject: fix #29012 (Potential race during first connection) thanks to cjbj at hotmail dot com X-Git-Tag: php-5.0.0~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f6eb507b2c25eb6f52f2eb7b8c4b1587382cc24c;p=php fix #29012 (Potential race during first connection) thanks to cjbj at hotmail dot com --- diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 04f697950e..597b177a49 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -2673,13 +2673,13 @@ static oci_session *_oci_open_session(oci_server* server,char *username,char *pa smart_str_0(&hashed_details); if (!exclusive) { + mutex_lock(mx_lock); if (zend_ts_hash_find(persistent_sessions, hashed_details.c, hashed_details.len+1, (void **) &session_list) != SUCCESS) { zend_llist tmp; /* first session, set up a session list */ zend_llist_init(&tmp, sizeof(oci_session), (llist_dtor_func_t) _session_pcleanup, 1); zend_ts_hash_update(persistent_sessions, hashed_details.c, hashed_details.len+1, &tmp, sizeof(zend_llist), (void **) &session_list); } else { - mutex_lock(mx_lock); /* session list found, search for an idle session or an already opened session by the current thread */ session = zend_llist_get_first(session_list); @@ -2692,7 +2692,6 @@ static oci_session *_oci_open_session(oci_server* server,char *username,char *pa session->thread = thread_id(); } - mutex_unlock(mx_lock); } if (session) { @@ -2707,6 +2706,7 @@ static oci_session *_oci_open_session(oci_server* server,char *username,char *pa /* breakthru to open */ } } + mutex_unlock(mx_lock); } session = ecalloc(1,sizeof(oci_session));