[evolution-patches] related to 45505, error checking pthread* calls



code was doing the wrong checking, i think the logic still failed when
it could (the e_mutex_lock stuff can't really fail), but could report
spurious errors.

? e-util/a.out
? e-util/bag.c
? e-util/bag.ps
? e-util/e-msgport.c.new
? e-util/e-trie.c.fixed
? e-util/mutex.c
? e-util/mutex.ps
? e-util/test.c
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1836.2.6
diff -u -3 -r1.1836.2.6 ChangeLog
--- camel/ChangeLog	29 Jul 2003 13:53:28 -0000	1.1836.2.6
+++ camel/ChangeLog	11 Aug 2003 18:59:42 -0000
@@ -1,3 +1,29 @@
+2003-08-11  Not Zed  <NotZed Ximian com>
+
+	** See bug #45505.
+
+	* camel-service.c (camel_gethostbyname): duh, pthread_create
+	returns the error code directly, not via errno.
+	(camel_gethostbyaddr): Same, also properly handle the failure
+	case.
+
+2003-08-01  Not Zed  <NotZed Ximian com>
+
+	** See bug #47208.
+
+	* camel-filter-search.c (match_all): match-all with no arguments	
+	should always return TRUE.
+
+	* camel-folder-search.c (camel_folder_search_execute_expression):
+	print a warning when we get an invalid result type & fixed a leak
+	for that case.
+	
+2003-07-30  Not Zed  <NotZed Ximian com>
+
+	* providers/imap/camel-imap-provider.c: Added offline_sync, to
+	automatically sync offline folders.  Currently used by the mailer,
+	but will move here eventually.
+
 2003-07-25  Jeffrey Stedfast  <fejj ximian com>
 
 	* camel-mime-utils.c (header_decode_word): Revert NotZed's fix for
Index: camel/camel-service.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-service.c,v
retrieving revision 1.83
diff -u -3 -r1.83 camel-service.c
--- camel/camel-service.c	25 Jun 2003 15:43:46 -0000	1.83
+++ camel/camel-service.c	11 Aug 2003 18:59:42 -0000
@@ -765,10 +765,11 @@
 		EMsgPort *reply_port;
 		pthread_t id;
 		fd_set rdset;
+		int err;
 
 		reply_port = msg->msg.reply_port = e_msgport_new();
 		fd = e_msgport_fd(msg->msg.reply_port);
-		if (pthread_create(&id, NULL, get_hostbyname, msg) == 0) {
+		if ((err = pthread_create(&id, NULL, get_hostbyname, msg)) == 0) {
 			d(printf("waiting for name return/cancellation in main process\n"));
 			do {
 				FD_ZERO(&rdset);
@@ -801,7 +802,7 @@
 				d(printf("child done\n"));
 			}
 		} else {
-			camel_exception_setv(&ex, CAMEL_EXCEPTION_SYSTEM, _("Host lookup failed: cannot create thread: %s"), g_strerror(errno));
+			camel_exception_setv(&ex, CAMEL_EXCEPTION_SYSTEM, _("Host lookup failed: cannot create thread: %s"), g_strerror(err));
 		}
 		e_msgport_destroy(reply_port);
 	}
@@ -897,10 +898,11 @@
 		EMsgPort *reply_port;
 		pthread_t id;
 		fd_set rdset;
-		
+		int err;
+
 		reply_port = msg->msg.reply_port = e_msgport_new ();
 		fd = e_msgport_fd (msg->msg.reply_port);
-		if (pthread_create (&id, NULL, get_hostbyaddr, msg) == 0) {
+		if ((err = pthread_create (&id, NULL, get_hostbyaddr, msg)) == 0) {
 			d(printf("waiting for name return/cancellation in main process\n"));
 			do {
 				FD_ZERO(&rdset);
@@ -932,7 +934,10 @@
 				pthread_join(id, NULL);
 				d(printf("child done\n"));
 			}
+		} else {
+			camel_exception_setv(&ex, CAMEL_EXCEPTION_SYSTEM, _("Host lookup failed: cannot create thread: %s"), g_strerror(err));
 		}
+
 		
 		e_msgport_destroy (reply_port);
 	}
Index: e-util/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
retrieving revision 1.398.2.2
diff -u -3 -r1.398.2.2 ChangeLog
--- e-util/ChangeLog	30 Jul 2003 12:58:32 -0000	1.398.2.2
+++ e-util/ChangeLog	11 Aug 2003 18:59:42 -0000
@@ -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-07-29  Dan Winship  <danw ximian com>
 
 	* e-gui-utils.c (e_icon_for_mime_type): New function to return an
Index: e-util/e-msgport.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-msgport.c,v
retrieving revision 1.19
diff -u -3 -r1.19 e-msgport.c
--- e-util/e-msgport.c	5 Feb 2003 21:58:38 -0000	1.19
+++ e-util/e-msgport.c	11 Aug 2003 18:59:42 -0000
@@ -766,8 +766,10 @@
 
 	/* 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_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 @@
 				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 @@
 	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());


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]