in locks/unix/proc_mutex.c [1355:1526]
static apr_status_t proc_mutex_choose_method(apr_proc_mutex_t *new_mutex,
apr_lockmech_e mech,
apr_os_proc_mutex_t *ospmutex)
{
#if APR_HAS_PROC_PTHREAD_SERIALIZE
new_mutex->os.pthread_interproc = NULL;
#endif
#if APR_HAS_POSIXSEM_SERIALIZE
new_mutex->os.psem_interproc = NULL;
#endif
#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
new_mutex->os.crossproc = -1;
#if APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
new_mutex->interproc = NULL;
new_mutex->interproc_closing = 0;
#endif
#endif
switch (mech) {
case APR_LOCK_FCNTL:
#if APR_HAS_FCNTL_SERIALIZE
new_mutex->meth = &mutex_fcntl_methods;
if (ospmutex) {
if (ospmutex->crossproc == -1) {
return APR_EINVAL;
}
new_mutex->os.crossproc = ospmutex->crossproc;
}
#else
return APR_ENOTIMPL;
#endif
break;
case APR_LOCK_FLOCK:
#if APR_HAS_FLOCK_SERIALIZE
new_mutex->meth = &mutex_flock_methods;
if (ospmutex) {
if (ospmutex->crossproc == -1) {
return APR_EINVAL;
}
new_mutex->os.crossproc = ospmutex->crossproc;
}
#else
return APR_ENOTIMPL;
#endif
break;
case APR_LOCK_SYSVSEM:
#if APR_HAS_SYSVSEM_SERIALIZE
new_mutex->meth = &mutex_sysv_methods;
if (ospmutex) {
if (ospmutex->crossproc == -1) {
return APR_EINVAL;
}
new_mutex->os.crossproc = ospmutex->crossproc;
}
#else
return APR_ENOTIMPL;
#endif
break;
case APR_LOCK_POSIXSEM:
#if APR_HAS_POSIXSEM_SERIALIZE
new_mutex->meth = &mutex_posixsem_methods;
if (ospmutex) {
if (ospmutex->psem_interproc == NULL) {
return APR_EINVAL;
}
new_mutex->os.psem_interproc = ospmutex->psem_interproc;
}
#else
return APR_ENOTIMPL;
#endif
break;
case APR_LOCK_PROC_PTHREAD:
#if APR_HAS_PROC_PTHREAD_SERIALIZE
new_mutex->meth = &mutex_proc_pthread_methods;
if (ospmutex) {
if (ospmutex->pthread_interproc == NULL) {
return APR_EINVAL;
}
new_mutex->os.pthread_interproc = ospmutex->pthread_interproc;
}
#else
return APR_ENOTIMPL;
#endif
break;
case APR_LOCK_DEFAULT_TIMED:
#if APR_HAS_PROC_PTHREAD_SERIALIZE \
&& (APR_USE_PROC_PTHREAD_MUTEX_COND \
|| defined(HAVE_PTHREAD_MUTEX_TIMEDLOCK)) \
&& defined(HAVE_PTHREAD_MUTEX_ROBUST)
#if APR_USE_PROC_PTHREAD_MUTEX_COND
new_mutex->meth = &mutex_proc_pthread_cond_methods;
#else
new_mutex->meth = &mutex_proc_pthread_methods;
#endif
if (ospmutex) {
if (ospmutex->pthread_interproc == NULL) {
return APR_EINVAL;
}
new_mutex->os.pthread_interproc = ospmutex->pthread_interproc;
}
break;
#elif APR_HAS_SYSVSEM_SERIALIZE && defined(HAVE_SEMTIMEDOP)
new_mutex->meth = &mutex_sysv_methods;
if (ospmutex) {
if (ospmutex->crossproc == -1) {
return APR_EINVAL;
}
new_mutex->os.crossproc = ospmutex->crossproc;
}
break;
#elif APR_HAS_POSIXSEM_SERIALIZE && defined(HAVE_SEM_TIMEDWAIT)
new_mutex->meth = &mutex_posixsem_methods;
if (ospmutex) {
if (ospmutex->psem_interproc == NULL) {
return APR_EINVAL;
}
new_mutex->os.psem_interproc = ospmutex->psem_interproc;
}
break;
#endif
/* fall trough */
case APR_LOCK_DEFAULT:
#if APR_USE_FLOCK_SERIALIZE
new_mutex->meth = &mutex_flock_methods;
if (ospmutex) {
if (ospmutex->crossproc == -1) {
return APR_EINVAL;
}
new_mutex->os.crossproc = ospmutex->crossproc;
}
#elif APR_USE_SYSVSEM_SERIALIZE
new_mutex->meth = &mutex_sysv_methods;
if (ospmutex) {
if (ospmutex->crossproc == -1) {
return APR_EINVAL;
}
new_mutex->os.crossproc = ospmutex->crossproc;
}
#elif APR_USE_FCNTL_SERIALIZE
new_mutex->meth = &mutex_fcntl_methods;
if (ospmutex) {
if (ospmutex->crossproc == -1) {
return APR_EINVAL;
}
new_mutex->os.crossproc = ospmutex->crossproc;
}
#elif APR_USE_PROC_PTHREAD_SERIALIZE
new_mutex->meth = &mutex_proc_pthread_methods;
if (ospmutex) {
if (ospmutex->pthread_interproc == NULL) {
return APR_EINVAL;
}
new_mutex->os.pthread_interproc = ospmutex->pthread_interproc;
}
#elif APR_USE_POSIXSEM_SERIALIZE
new_mutex->meth = &mutex_posixsem_methods;
if (ospmutex) {
if (ospmutex->psem_interproc == NULL) {
return APR_EINVAL;
}
new_mutex->os.psem_interproc = ospmutex->psem_interproc;
}
#else
return APR_ENOTIMPL;
#endif
break;
default:
return APR_ENOTIMPL;
}
return APR_SUCCESS;
}