aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-08-12 04:15:45 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-08-12 04:15:45 +0800
commit04d98f3c4ed6f176d4308b37b1db8e902874ce20 (patch)
tree05fd4d1ddc0beb3a784681f48638a78dd8e54b72 /e-util
parent6ccafb45ae1b0469fea2ebf5e74548f9fa0d1f33 (diff)
downloadgsoc2013-evolution-04d98f3c4ed6f176d4308b37b1db8e902874ce20.tar
gsoc2013-evolution-04d98f3c4ed6f176d4308b37b1db8e902874ce20.tar.gz
gsoc2013-evolution-04d98f3c4ed6f176d4308b37b1db8e902874ce20.tar.bz2
gsoc2013-evolution-04d98f3c4ed6f176d4308b37b1db8e902874ce20.tar.lz
gsoc2013-evolution-04d98f3c4ed6f176d4308b37b1db8e902874ce20.tar.xz
gsoc2013-evolution-04d98f3c4ed6f176d4308b37b1db8e902874ce20.tar.zst
gsoc2013-evolution-04d98f3c4ed6f176d4308b37b1db8e902874ce20.zip
check pthread_create return code properly. (e_mutex_lock): check pthread*
2003-08-11 Not Zed <NotZed@Ximian.com> * e-msgport.c (e_thread_put): check pthread_create return code properly. (e_mutex_lock): check pthread* return codes properly. (e_mutex_unlock): Same here. (e_mutex_cond_wait): and here. svn path=/trunk/; revision=22177
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog8
-rw-r--r--e-util/e-msgport.c28
2 files changed, 24 insertions, 12 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 131bbf4cba..8c40628977 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,11 @@
+2003-08-11 Not Zed <NotZed@Ximian.com>
+
+ * e-msgport.c (e_thread_put): check pthread_create return code
+ properly.
+ (e_mutex_lock): check pthread* return codes properly.
+ (e_mutex_unlock): Same here.
+ (e_mutex_cond_wait): and here.
+
2003-08-05 Dan Winship <danw@ximian.com>
* e-html-utils.c (special_chars): add a flag for non-url chars
diff --git a/e-util/e-msgport.c b/e-util/e-msgport.c
index 03c12c8847..36ea6cfe8d 100644
--- a/e-util/e-msgport.c
+++ b/e-util/e-msgport.c
@@ -766,8 +766,10 @@ void e_thread_put(EThread *e, EMsg *msg)
/* create the thread, if there is none to receive it yet */
if (e->id == E_THREAD_NONE) {
- if (pthread_create(&e->id, NULL, thread_dispatch, e) == -1) {
- g_warning("Could not create dispatcher thread, message queued?: %s", strerror(errno));
+ int err;
+
+ if ((err = pthread_create(&e->id, NULL, thread_dispatch, e)) != 0) {
+ g_warning("Could not create dispatcher thread, message queued?: %s", strerror(err));
e->id = E_THREAD_NONE;
}
}
@@ -845,14 +847,15 @@ int e_mutex_destroy(EMutex *m)
int e_mutex_lock(EMutex *m)
{
pthread_t id;
+ int err;
switch (m->type) {
case E_MUTEX_SIMPLE:
return pthread_mutex_lock(&m->mutex);
case E_MUTEX_REC:
id = pthread_self();
- if (pthread_mutex_lock(&m->mutex) == -1)
- return -1;
+ if ((err = pthread_mutex_lock(&m->mutex)) != 0)
+ return err;
while (1) {
if (m->owner == E_THREAD_NONE) {
m->owner = id;
@@ -863,26 +866,27 @@ int e_mutex_lock(EMutex *m)
break;
} else {
m->waiters++;
- if (pthread_cond_wait(&m->cond, &m->mutex) == -1)
- return -1;
+ if ((err = pthread_cond_wait(&m->cond, &m->mutex)) != 0)
+ return err;
m->waiters--;
}
}
return pthread_mutex_unlock(&m->mutex);
}
- errno = EINVAL;
- return -1;
+ return EINVAL;
}
int e_mutex_unlock(EMutex *m)
{
+ int err;
+
switch (m->type) {
case E_MUTEX_SIMPLE:
return pthread_mutex_unlock(&m->mutex);
case E_MUTEX_REC:
- if (pthread_mutex_lock(&m->mutex) == -1)
- return -1;
+ if ((err = pthread_mutex_lock(&m->mutex)) != 0)
+ return err;
g_assert(m->owner == pthread_self());
m->depth--;
@@ -915,8 +919,8 @@ int e_mutex_cond_wait(void *vcond, EMutex *m)
case E_MUTEX_SIMPLE:
return pthread_cond_wait(cond, &m->mutex);
case E_MUTEX_REC:
- if (pthread_mutex_lock(&m->mutex) == -1)
- return -1;
+ if ((ret = pthread_mutex_lock(&m->mutex)) != 0)
+ return ret;
g_assert(m->owner == pthread_self());
ret = pthread_cond_wait(cond, &m->mutex);
g_assert(m->owner == pthread_self());