On 03/06/2016 01:19 AM, yla...@apache.org wrote: > Author: ylavic > Date: Sun Mar 6 00:19:51 2016 > New Revision: 1733775 > > URL: http://svn.apache.org/viewvc?rev=1733775&view=rev > Log: > apr_proc/global_mutex: Fix API regarding the native OS mutexes > accessors from/to available APR mechanisms, adding the new functions > apr_os_proc_mutex_get_ex() and apr_os_proc_mutex_set_ex() which give > control to the user over the selected mechanisms, including the missing > POSIX semaphores (sem_t) on platforms supporting them. > > For POSIX sems, this moves the "sem_t *psem_interproc;" member from struct > apr_proc_mutex_t to apr_os_proc_mutex_t (now complete) so that we can avoid > members duplication between the two structs, and hence replace all the > doublons > in apr_os_proc_mutex_t with an apr_os_proc_mutex_t member, called "os", to be > used for runtime. > > This first commit aims to be backportable to 1.6.x, thus does not address the > Netware case which requires an incompatible change of the apr_proc_mutex_t to > a pointer type (the implementation is here since very similar to other changes > is this commit, but it is commented out for now, a simple follow up is coming > with the type change for trunk only...). > > > Modified: > apr/apr/trunk/CHANGES > apr/apr/trunk/include/apr_global_mutex.h > apr/apr/trunk/include/apr_portable.h > apr/apr/trunk/include/apr_proc_mutex.h > apr/apr/trunk/include/arch/unix/apr_arch_proc_mutex.h > apr/apr/trunk/locks/beos/proc_mutex.c > apr/apr/trunk/locks/netware/proc_mutex.c > apr/apr/trunk/locks/os2/proc_mutex.c > apr/apr/trunk/locks/unix/global_mutex.c > apr/apr/trunk/locks/unix/proc_mutex.c > apr/apr/trunk/locks/win32/proc_mutex.c >
> Modified: apr/apr/trunk/locks/netware/proc_mutex.c > URL: > http://svn.apache.org/viewvc/apr/apr/trunk/locks/netware/proc_mutex.c?rev=1733775&r1=1733774&r2=1733775&view=diff > ============================================================================== > --- apr/apr/trunk/locks/netware/proc_mutex.c (original) > +++ apr/apr/trunk/locks/netware/proc_mutex.c Sun Mar 6 00:19:51 2016 > @@ -121,18 +126,65 @@ APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) > > /* Implement OS-specific accessors defined in apr_portable.h */ > > -apr_status_t apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex, > - apr_proc_mutex_t *pmutex) > +APR_DECLARE(apr_status_t) apr_os_proc_mutex_get_ex(apr_os_proc_mutex_t > *ospmutex, > + apr_proc_mutex_t *pmutex, > + apr_lockmech_e *mech) > +{ > +#if 1 > + /* We need to change apr_os_proc_mutex_t to a pointer type > + * to be able to implement this function. > + */ > + return APR_ENOTIMPL; > +#else > + if (!pmutex->mutex) { > + return APR_ENOLOCK; > + } > + *ospmutex = pmutex->mutex->mutex; > + if (mech) { > + *mech = APR_LOCK_DEFAULT; > + } > + return APR_SUCCESS; > +#endif > +} > + > +APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t > *ospmutex, > + apr_proc_mutex_t *pmutex) > { > - if (pmutex) > - ospmutex = pmutex->mutex->mutex; > - return APR_ENOLOCK; > + return apr_os_proc_mutex_get_ex(ospmutex, pmutex, NULL); > } Previously we always returned APR_ENOLOCK now we return always APR_ENOTIMPL and ospmutex will not be set. Is this correct? > Modified: apr/apr/trunk/locks/unix/proc_mutex.c > URL: > http://svn.apache.org/viewvc/apr/apr/trunk/locks/unix/proc_mutex.c?rev=1733775&r1=1733774&r2=1733775&view=diff > ============================================================================== > --- apr/apr/trunk/locks/unix/proc_mutex.c (original) > +++ apr/apr/trunk/locks/unix/proc_mutex.c Sun Mar 6 00:19:51 2016 > @@ -488,16 +504,16 @@ static apr_status_t proc_mutex_proc_pthr > return errno; > } > > - new_mutex->pthread_interproc = (pthread_mutex_t *)mmap( > - (caddr_t) 0, > - sizeof(proc_pthread_mutex_t), > - PROT_READ | PROT_WRITE, MAP_SHARED, > - fd, 0); > - if (new_mutex->pthread_interproc == (pthread_mutex_t *) (caddr_t) -1) { > + new_mutex->os.pthread_interproc = mmap(NULL, > sizeof(proc_pthread_mutex_t), > + PROT_READ | PROT_WRITE, > MAP_SHARED, > + fd, 0); > + if (new_mutex->os.pthread_interproc == MAP_FAILED) { > + new_mutex->os.pthread_interproc = NULL; > + rv = errno; > close(fd); > - return errno; > + return rv; > } > - close(fd); Why don't we close the fd any longer? > + new_mutex->pthread_refcounting = 1; > > new_mutex->curr_locked = -1; /* until the mutex has been created */ > Regards RĂ¼diger