| 713 | |
| 714 | #if APR_HAS_THREADS |
| 715 | static apr_status_t dbd_setup_lock(server_rec *s, dbd_group_t *group) |
| 716 | { |
| 717 | apr_status_t rv = APR_SUCCESS, rv2; |
| 718 | |
| 719 | /* several threads could be here at the same time, all trying to |
| 720 | * initialize the reslist because dbd_setup_init failed to do so |
| 721 | */ |
| 722 | if (!group->mutex) { |
| 723 | /* we already logged an error when the mutex couldn't be created */ |
| 724 | return APR_EGENERAL; |
| 725 | } |
| 726 | |
| 727 | rv2 = apr_thread_mutex_lock(group->mutex); |
| 728 | if (rv2 != APR_SUCCESS) { |
| 729 | ap_log_error(APLOG_MARK, APLOG_ERR, rv2, s, APLOGNO(00637) |
| 730 | "Failed to acquire thread mutex"); |
| 731 | return rv2; |
| 732 | } |
| 733 | |
| 734 | if (!group->reslist) { |
| 735 | rv = dbd_setup(s, group); |
| 736 | } |
| 737 | |
| 738 | rv2 = apr_thread_mutex_unlock(group->mutex); |
| 739 | if (rv2 != APR_SUCCESS) { |
| 740 | ap_log_error(APLOG_MARK, APLOG_ERR, rv2, s, APLOGNO(00638) |
| 741 | "Failed to release thread mutex"); |
| 742 | if (rv == APR_SUCCESS) { |
| 743 | rv = rv2; |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | return rv; |
| 748 | } |
| 749 | #endif |
| 750 | |
| 751 | /* Functions we export for modules to use: |
no test coverage detected