mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-02 11:29:48 +00:00
FSCORE-606 (Win) bridge fails because session read lock failure
This commit is contained in:
parent
e15abcf9aa
commit
f8f91362f0
@ -24,6 +24,7 @@ struct apr_thread_rwlock_t {
|
|||||||
HANDLE write_mutex;
|
HANDLE write_mutex;
|
||||||
HANDLE read_event;
|
HANDLE read_event;
|
||||||
LONG readers;
|
LONG readers;
|
||||||
|
CRITICAL_SECTION read_section;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* THREAD_RWLOCK_H */
|
#endif /* THREAD_RWLOCK_H */
|
||||||
|
@ -28,6 +28,8 @@ static apr_status_t thread_rwlock_cleanup(void *data)
|
|||||||
if (! CloseHandle(rwlock->read_event))
|
if (! CloseHandle(rwlock->read_event))
|
||||||
return apr_get_os_error();
|
return apr_get_os_error();
|
||||||
|
|
||||||
|
DeleteCriticalSection(&rwlock->read_section);
|
||||||
|
|
||||||
if (! CloseHandle(rwlock->write_mutex))
|
if (! CloseHandle(rwlock->write_mutex))
|
||||||
return apr_get_os_error();
|
return apr_get_os_error();
|
||||||
|
|
||||||
@ -53,6 +55,8 @@ APR_DECLARE(apr_status_t)apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock,
|
|||||||
return apr_get_os_error();
|
return apr_get_os_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InitializeCriticalSection(&(*rwlock)->read_section);
|
||||||
|
|
||||||
apr_pool_cleanup_register(pool, *rwlock, thread_rwlock_cleanup,
|
apr_pool_cleanup_register(pool, *rwlock, thread_rwlock_cleanup,
|
||||||
apr_pool_cleanup_null);
|
apr_pool_cleanup_null);
|
||||||
|
|
||||||
@ -62,10 +66,14 @@ APR_DECLARE(apr_status_t)apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock,
|
|||||||
static apr_status_t apr_thread_rwlock_rdlock_core(apr_thread_rwlock_t *rwlock,
|
static apr_status_t apr_thread_rwlock_rdlock_core(apr_thread_rwlock_t *rwlock,
|
||||||
DWORD milliseconds)
|
DWORD milliseconds)
|
||||||
{
|
{
|
||||||
DWORD code = WaitForSingleObject(rwlock->write_mutex, milliseconds);
|
DWORD code;
|
||||||
|
EnterCriticalSection(&rwlock->read_section);
|
||||||
|
code = WaitForSingleObject(rwlock->write_mutex, milliseconds);
|
||||||
|
|
||||||
if (code == WAIT_FAILED || code == WAIT_TIMEOUT)
|
if (code == WAIT_FAILED || code == WAIT_TIMEOUT) {
|
||||||
|
LeaveCriticalSection(&rwlock->read_section);
|
||||||
return APR_FROM_OS_ERROR(code);
|
return APR_FROM_OS_ERROR(code);
|
||||||
|
}
|
||||||
|
|
||||||
/* We've successfully acquired the writer mutex, we can't be locked
|
/* We've successfully acquired the writer mutex, we can't be locked
|
||||||
* for write, so it's OK to add the reader lock. The writer mutex
|
* for write, so it's OK to add the reader lock. The writer mutex
|
||||||
@ -73,12 +81,17 @@ static apr_status_t apr_thread_rwlock_rdlock_core(apr_thread_rwlock_t *rwlock,
|
|||||||
*/
|
*/
|
||||||
InterlockedIncrement(&rwlock->readers);
|
InterlockedIncrement(&rwlock->readers);
|
||||||
|
|
||||||
if (! ResetEvent(rwlock->read_event))
|
if (! ResetEvent(rwlock->read_event)) {
|
||||||
|
LeaveCriticalSection(&rwlock->read_section);
|
||||||
return apr_get_os_error();
|
return apr_get_os_error();
|
||||||
|
}
|
||||||
|
|
||||||
if (! ReleaseMutex(rwlock->write_mutex))
|
if (! ReleaseMutex(rwlock->write_mutex)) {
|
||||||
|
LeaveCriticalSection(&rwlock->read_section);
|
||||||
return apr_get_os_error();
|
return apr_get_os_error();
|
||||||
|
}
|
||||||
|
|
||||||
|
LeaveCriticalSection(&rwlock->read_section);
|
||||||
return APR_SUCCESS;
|
return APR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user