mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-23 23:59:16 +02:00
Prevent calling into g_cond_wait resp. g_mutex_lock/unlock directly to
2006-05-10 Sebastian Wilhelmi <wilhelmi@google.com> * gthread/gthread-posix.c, gthread/gthread-win32.c: Prevent calling into g_cond_wait resp. g_mutex_lock/unlock directly to avoid recursions into the errorcheking mutex code (and out of principle anyway). (#335198, Chris Wilson)
This commit is contained in:
parent
a194e2e971
commit
685da6b099
@ -1,5 +1,10 @@
|
|||||||
2006-05-10 Sebastian Wilhelmi <wilhelmi@google.com>
|
2006-05-10 Sebastian Wilhelmi <wilhelmi@google.com>
|
||||||
|
|
||||||
|
* gthread/gthread-posix.c, gthread/gthread-win32.c: Prevent
|
||||||
|
calling into g_cond_wait resp. g_mutex_lock/unlock directly to
|
||||||
|
avoid recursions into the errorcheking mutex code (and out of
|
||||||
|
principle anyway). (#335198, Chris Wilson)
|
||||||
|
|
||||||
* tests/errorcheck-mutex-test.c: Adapt to GLib coding standards.
|
* tests/errorcheck-mutex-test.c: Adapt to GLib coding standards.
|
||||||
|
|
||||||
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
|
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
2006-05-10 Sebastian Wilhelmi <wilhelmi@google.com>
|
2006-05-10 Sebastian Wilhelmi <wilhelmi@google.com>
|
||||||
|
|
||||||
|
* gthread/gthread-posix.c, gthread/gthread-win32.c: Prevent
|
||||||
|
calling into g_cond_wait resp. g_mutex_lock/unlock directly to
|
||||||
|
avoid recursions into the errorcheking mutex code (and out of
|
||||||
|
principle anyway). (#335198, Chris Wilson)
|
||||||
|
|
||||||
* tests/errorcheck-mutex-test.c: Adapt to GLib coding standards.
|
* tests/errorcheck-mutex-test.c: Adapt to GLib coding standards.
|
||||||
|
|
||||||
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
|
2006-05-09 Sebastian Wilhelmi <wilhelmi@google.com>
|
||||||
|
@ -199,7 +199,7 @@ g_cond_new_posix_impl (void)
|
|||||||
/* pthread_cond_signal, pthread_cond_broadcast and pthread_cond_wait
|
/* pthread_cond_signal, pthread_cond_broadcast and pthread_cond_wait
|
||||||
can be taken directly, as signature and semantic are right, but
|
can be taken directly, as signature and semantic are right, but
|
||||||
without error check then!!!!, we might want to change this
|
without error check then!!!!, we might want to change this
|
||||||
therfore. */
|
therefore. */
|
||||||
|
|
||||||
#define G_NSEC_PER_SEC 1000000000
|
#define G_NSEC_PER_SEC 1000000000
|
||||||
|
|
||||||
@ -217,27 +217,30 @@ g_cond_timed_wait_posix_impl (GCond * cond,
|
|||||||
|
|
||||||
if (!abs_time)
|
if (!abs_time)
|
||||||
{
|
{
|
||||||
g_cond_wait (cond, entered_mutex);
|
result = pthread_cond_wait ((pthread_cond_t *)cond,
|
||||||
return TRUE;
|
(pthread_mutex_t *) entered_mutex);
|
||||||
|
timed_out = FALSE;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
end_time.tv_sec = abs_time->tv_sec;
|
||||||
|
end_time.tv_nsec = abs_time->tv_usec * (G_NSEC_PER_SEC / G_USEC_PER_SEC);
|
||||||
|
|
||||||
end_time.tv_sec = abs_time->tv_sec;
|
g_return_val_if_fail (end_time.tv_nsec < G_NSEC_PER_SEC, TRUE);
|
||||||
end_time.tv_nsec = abs_time->tv_usec * (G_NSEC_PER_SEC / G_USEC_PER_SEC);
|
|
||||||
|
|
||||||
g_return_val_if_fail (end_time.tv_nsec < G_NSEC_PER_SEC, TRUE);
|
|
||||||
|
|
||||||
result = pthread_cond_timedwait ((pthread_cond_t *) cond,
|
|
||||||
(pthread_mutex_t *) entered_mutex,
|
|
||||||
&end_time);
|
|
||||||
|
|
||||||
|
result = pthread_cond_timedwait ((pthread_cond_t *) cond,
|
||||||
|
(pthread_mutex_t *) entered_mutex,
|
||||||
|
&end_time);
|
||||||
#ifdef G_THREADS_IMPL_POSIX
|
#ifdef G_THREADS_IMPL_POSIX
|
||||||
timed_out = (result == ETIMEDOUT);
|
timed_out = (result == ETIMEDOUT);
|
||||||
#else /* G_THREADS_IMPL_DCE */
|
#else /* G_THREADS_IMPL_DCE */
|
||||||
timed_out = (result == -1) && (errno == EAGAIN);
|
timed_out = (result == -1) && (errno == EAGAIN);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (!timed_out)
|
if (!timed_out)
|
||||||
posix_check_err (posix_error (result), "pthread_cond_timedwait");
|
posix_check_err (posix_error (result), "pthread_cond_timedwait");
|
||||||
|
|
||||||
return !timed_out;
|
return !timed_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,9 @@ static GDestroyNotify g_private_destructors[G_PRIVATE_MAX];
|
|||||||
|
|
||||||
static guint g_private_next = 0;
|
static guint g_private_next = 0;
|
||||||
|
|
||||||
|
/* A "forward" declaration of this structure */
|
||||||
|
static GThreadFunctions g_thread_functions_for_glib_use_default;
|
||||||
|
|
||||||
typedef struct _GThreadData GThreadData;
|
typedef struct _GThreadData GThreadData;
|
||||||
struct _GThreadData
|
struct _GThreadData
|
||||||
{
|
{
|
||||||
@ -236,12 +239,12 @@ g_cond_wait_internal (GCond *cond,
|
|||||||
g_ptr_array_add (cond->array, event);
|
g_ptr_array_add (cond->array, event);
|
||||||
LeaveCriticalSection (&cond->lock);
|
LeaveCriticalSection (&cond->lock);
|
||||||
|
|
||||||
g_mutex_unlock (entered_mutex);
|
g_thread_functions_for_glib_use_default.mutex_unlock (entered_mutex);
|
||||||
|
|
||||||
win32_check_for_error (WAIT_FAILED !=
|
win32_check_for_error (WAIT_FAILED !=
|
||||||
(retval = WaitForSingleObject (event, milliseconds)));
|
(retval = WaitForSingleObject (event, milliseconds)));
|
||||||
|
|
||||||
g_mutex_lock (entered_mutex);
|
g_thread_functions_for_glib_use_default.mutex_lock (entered_mutex);
|
||||||
|
|
||||||
if (retval == WAIT_TIMEOUT)
|
if (retval == WAIT_TIMEOUT)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user