[evolution-data-server/gnome-2-28] Bug #600449 - segfault in camel_msgport_destroy
- From: Milan Crha <mcrha src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-2-28] Bug #600449 - segfault in camel_msgport_destroy
- Date: Fri, 27 Nov 2009 12:16:24 +0000 (UTC)
commit e6a636063229df480215f5f56e0c78815edd44fe
Author: Milan Crha <mcrha redhat com>
Date: Fri Nov 27 13:15:43 2009 +0100
Bug #600449 - segfault in camel_msgport_destroy
camel/camel-net-utils.c | 34 +++++++++++++++-------------------
1 files changed, 15 insertions(+), 19 deletions(-)
---
diff --git a/camel/camel-net-utils.c b/camel/camel-net-utils.c
index e7ba45e..d447e41 100644
--- a/camel/camel-net-utils.c
+++ b/camel/camel-net-utils.c
@@ -503,12 +503,11 @@ cs_waitinfo(gpointer (worker)(gpointer), struct _addrinfo_msg *msg, const gchar
camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Canceled"));
/* We cancel so if the thread impl is decent it causes immediate exit.
- We detach so we dont need to wait for it to exit if it isn't.
We check the reply port incase we had a reply in the mean time, which we free later */
d(printf("Canceling lookup thread and leaving it\n"));
msg->cancelled = 1;
- pthread_detach(id);
pthread_cancel(id);
+ pthread_join (id, NULL);
cancel = 1;
} else {
struct _addrinfo_msg *reply = (struct _addrinfo_msg *)camel_msgport_try_pop(reply_port);
@@ -546,6 +545,8 @@ cs_getaddrinfo(gpointer data)
msg->hostbufmem = g_realloc(msg->hostbufmem, msg->hostbuflen);
}
+ pthread_testcancel ();
+
/* If we got cancelled, dont reply, just free it */
if (msg->cancelled)
goto cancel;
@@ -598,6 +599,8 @@ cs_getaddrinfo(gpointer data)
}
}
+ pthread_testcancel ();
+
for (i=0;h.h_addr_list[i];i++) {
res = g_malloc0(sizeof(*res));
if (msg->hints) {
@@ -628,9 +631,7 @@ cs_getaddrinfo(gpointer data)
}
reply:
camel_msgport_reply((CamelMsg *)msg);
- return NULL;
cancel:
- cs_freeinfo(msg);
return NULL;
}
#else
@@ -650,11 +651,10 @@ cs_getaddrinfo(gpointer data)
info->result = getaddrinfo(info->name, "443", info->hints, info->res);
}
- if (info->cancelled) {
- cs_freeinfo(info);
- } else {
+ pthread_testcancel ();
+
+ if (!info->cancelled)
camel_msgport_reply((CamelMsg *)info);
- }
return NULL;
}
@@ -702,11 +702,10 @@ camel_getaddrinfo(const gchar *name, const gchar *service, const struct addrinfo
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Host lookup failed: %s: %s"),
name, gai_strerror (msg->result));
}
-
- cs_freeinfo(msg);
} else
res = NULL;
+ cs_freeinfo (msg);
camel_operation_end(NULL);
return res;
@@ -756,6 +755,8 @@ cs_getnameinfo(gpointer data)
if (msg->cancelled)
goto cancel;
+ pthread_testcancel ();
+
if (msg->host) {
g_free(msg->host);
if (msg->result == 0 && h.h_name && h.h_name[0]) {
@@ -773,9 +774,7 @@ cs_getnameinfo(gpointer data)
sprintf(msg->serv, "%d", sin->sin_port);
camel_msgport_reply((CamelMsg *)msg);
- return NULL;
cancel:
- cs_freeinfo(msg);
return NULL;
}
#else
@@ -787,9 +786,9 @@ cs_getnameinfo(gpointer data)
/* there doens't appear to be a return code which says host or serv buffers are too short, lengthen them */
msg->result = getnameinfo(msg->addr, msg->addrlen, msg->host, msg->hostlen, msg->serv, msg->servlen, msg->flags);
- if (msg->cancelled)
- cs_freeinfo(msg);
- else
+ pthread_testcancel ();
+
+ if (!msg->cancelled)
camel_msgport_reply((CamelMsg *)msg);
return NULL;
@@ -839,10 +838,7 @@ camel_getnameinfo(const struct sockaddr *sa, socklen_t salen, gchar **host, gcha
*serv = g_strdup(msg->serv);
}
- g_free(msg->host);
- g_free(msg->serv);
- g_free(msg);
-
+ cs_freeinfo (msg);
camel_operation_end(NULL);
return result;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]