The authorization using DBD/PGSQL is broken at least in version 2.2.3. Debugging the code I foigured out, that in dbd_setup_lock a failure return code is generated if srv->mutex contains the NULL value. This is incorrect, because the NULL value may also be assigned in success cases if no mutexes are required (see: dbd_setup_init in the same source file). I've created the following patch which works fine for me: *** ./modules/database/mod_dbd.c.fcs Sun Dec 10 12:19:47 2006 --- ./modules/database/mod_dbd.c Sun Dec 10 12:22:01 2006 *************** *** 388,416 **** /* several threads could be here at the same time, all trying to * initialize the reslist because dbd_setup_init failed to do so */ ! if (!svr->mutex) { ! /* we already logged an error when the mutex couldn't be created */ ! return APR_EGENERAL; } - rv = apr_thread_mutex_lock(svr->mutex); - if (rv != APR_SUCCESS) { - ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool, - "DBD: Failed to acquire thread mutex"); - return rv; - } - if (!svr->dbpool) { rv2 = dbd_setup(s->process->pool, svr); } ! rv = apr_thread_mutex_unlock(svr->mutex); ! if (rv != APR_SUCCESS) { ! ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool, ! "DBD: Failed to release thread mutex"); ! if (rv2 == APR_SUCCESS) { ! rv2 = rv; ! } } return rv2; } --- 388,415 ---- /* several threads could be here at the same time, all trying to * initialize the reslist because dbd_setup_init failed to do so */ ! if (svr->mutex) { ! rv = apr_thread_mutex_lock(svr->mutex); ! if (rv != APR_SUCCESS) { ! ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool, ! "DBD: Failed to acquire thread mutex"); ! return rv; ! } } if (!svr->dbpool) { rv2 = dbd_setup(s->process->pool, svr); } ! if (svr->mutex) { ! rv = apr_thread_mutex_unlock(svr->mutex); ! if (rv != APR_SUCCESS) { ! ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool, ! "DBD: Failed to release thread mutex"); ! if (rv2 == APR_SUCCESS) { ! rv2 = rv; ! } ! } } return rv2; }
dbd_setup_lock is only ever called if dbd_setup_init failed at server initialisation. That's basically so it can recover if the database was down at apache startup time. Can you explain how a problem arises for you? Is it after the database has gone down and been restarted? BTW, there may be a bug, but your patch is definitely broken, as it's not thread-safe.
Hi, psql authentication is working properly in apache 2.2.2. Because of difficulties with php 5.2.0 - they finally boiled down to another apache problem issue 41142 - I upgraded to version 2.2.3. It turned out, that in version 2.2.3 apache was not able any more to authenticate against the PostgreSQL database. Using a debugger I figured out, that dbd_setup_init did *not* fail. dbd_setup returns APR_SUCESS. This return value is returned by dbd_setup_init in the second if statement. Therefor srv->mutex was still NULL dbd_setup_lock was called afterwards. It failed because of srv->mutex. The postgres database was setup when apache 2.2.2 was running. It was not modified since then. After applying my patch, apache including the authentication seemd ok for me again. I had another look at the code right now. I turns out, that dbd_setup_lock is called if svr->dbpool is NULL. However db_setup returns APR_SUCCESS, thus apr_reslist_create obviously returns APR_SUCCESS. The later function for my understanding should setup svr->dbpool. And it does so. So at the moment I'm stucked ... the only explanation would be some side effect overriding svr->dbpool ... Jens
Ah, OK. I think this is probably a side-effect of the fact that inheritance between the main server config and <VirtualHost>s isn't working correctly. Can you test-drive it with mod_dbd from /trunk/ ? That would be useful.
(In reply to comment #3) > Ah, OK. I think this is probably a side-effect of the fact that inheritance > between the main server config and <VirtualHost>s isn't working correctly. > > Can you test-drive it with mod_dbd from /trunk/ ? That would be useful. I may try that. Could you please point me to the trunk download page or send the according files via mail to me? I had a look at the apache home page but did not find any link to the development zone ... maybe I'm too blind to see it ;-)
As you only need to exchange the file mod_dbd.c http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/database/mod_dbd.c?view=co should be of sufficient help. For more please have a look at the "Source Repository Information" section of http://httpd.apache.org/dev/.
Hi, I've tried the patch from issue 39985 and the mod_dbd.c trunk verion now. Both do not work. The development tree and all information about how I built and configured apache are on one of my public servers now. There's also a compiler and debugger installed. I may grant access to the server to you to have a look at the situation ... if this would be an approach pls. contact me personally by mail for the login data. Jens
2.2.6 has some major mod_dbd fixes. Does it fix this problem for you?
No response since Comment 7; assuming fixed.