aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-06-20 11:53:35 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-06-20 11:53:35 +0800
commitff2a889221767f30f3fefd166a675ce8d33de77e (patch)
tree3957eae2c306c60985ab86d058c5d147c89b3e1e
parent17bea8af3b8edee968d7ce8d3a4bc1cfb669289f (diff)
downloadgsoc2013-evolution-ff2a889221767f30f3fefd166a675ce8d33de77e.tar
gsoc2013-evolution-ff2a889221767f30f3fefd166a675ce8d33de77e.tar.gz
gsoc2013-evolution-ff2a889221767f30f3fefd166a675ce8d33de77e.tar.bz2
gsoc2013-evolution-ff2a889221767f30f3fefd166a675ce8d33de77e.tar.lz
gsoc2013-evolution-ff2a889221767f30f3fefd166a675ce8d33de77e.tar.xz
gsoc2013-evolution-ff2a889221767f30f3fefd166a675ce8d33de77e.tar.zst
gsoc2013-evolution-ff2a889221767f30f3fefd166a675ce8d33de77e.zip
if we got cancelled, the message is floating, so free it. (struct
2003-06-18 Not Zed <NotZed@Ximian.com> * camel-service.c (get_hostbyaddr, get_hostbyname): if we got cancelled, the message is floating, so free it. (struct _lookup_msg): Add a cancelled tag. (camel_gethostbyname, camel_gethostbyaddr): if we get a failure/cancel, cancel the lookup thread and detach, so we dont have to wait for it to return. cleanup changed to handle the case where we didn't get a reply message. svn path=/trunk/; revision=21489
-rw-r--r--camel/ChangeLog18
-rw-r--r--camel/camel-service.c148
2 files changed, 105 insertions, 61 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 396697c96a..439f411cfa 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,13 @@
+2003-06-18 Not Zed <NotZed@Ximian.com>
+
+ * camel-service.c (get_hostbyaddr, get_hostbyname): if we got
+ cancelled, the message is floating, so free it.
+ (struct _lookup_msg): Add a cancelled tag.
+ (camel_gethostbyname, camel_gethostbyaddr): if we get a
+ failure/cancel, cancel the lookup thread and detach, so we dont
+ have to wait for it to return. cleanup changed to handle the case
+ where we didn't get a reply message.
+
2003-06-13 Jeffrey Stedfast <fejj@ximian.com>
* providers/pop3/camel-pop3-folder.c (pop3_finalize): Made static
@@ -22,6 +32,14 @@
2003-06-16 Not Zed <NotZed@Ximian.com>
+ ** See bug #31745
+
+ * providers/imap/camel-imap-store-summary.c
+ (camel_imap_store_summary_namespace_new): Workaround a shell bug -
+ if the namespace has '#' in it, then strip it.
+
+2003-06-16 Not Zed <NotZed@Ximian.com>
+
** See bug #44322
* providers/imap/camel-imap-command.c (imap_command_strdup_vprintf):
diff --git a/camel/camel-service.c b/camel/camel-service.c
index f3d2a43572..78c9fe5da6 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -691,6 +691,7 @@ struct _lookup_msg {
#ifdef ENABLE_THREADS
EMsg msg;
#endif
+ unsigned int cancelled:1;
const char *name;
int len;
int type;
@@ -718,7 +719,13 @@ get_hostbyname(void *data)
d(printf("gethostbyname ok?\n"));
#ifdef ENABLE_THREADS
- e_msgport_reply((EMsg *)info);
+ /* If we got cancelled, dont reply, just free it */
+ if (info->cancelled) {
+ g_free(info->hostbufmem);
+ g_free(info);
+ } else {
+ e_msgport_reply((EMsg *)info);
+ }
#endif
return NULL;
}
@@ -766,27 +773,33 @@ camel_gethostbyname (const char *name, CamelException *ex)
FD_SET(cancel_fd, &rdset);
FD_SET(fd, &rdset);
fdmax = MAX(fd, cancel_fd) + 1;
- status = select (fdmax, &rdset, NULL, 0, NULL);
+ status = select(fdmax, &rdset, NULL, 0, NULL);
} while (status == -1 && errno == EINTR);
-
- if (status == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failure in name lookup: %s"),
- g_strerror (errno));
- d(printf("Cancelling lookup thread\n"));
- pthread_cancel(id);
- } else if (FD_ISSET(cancel_fd, &rdset)) {
- d(printf("Cancelling lookup thread\n"));
- camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
+
+ if (status == -1 || FD_ISSET(cancel_fd, &rdset)) {
+ if (status == -1)
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Failure in name lookup: %s"), g_strerror(errno));
+ else
+ camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
+
+ /* 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("Cancelling lookup thread and leaving it\n"));
+ msg->cancelled = 1;
+ pthread_detach(id);
pthread_cancel(id);
+ msg = (struct _lookup_msg *)e_msgport_get(reply_port);
} else {
struct _lookup_msg *reply = (struct _lookup_msg *)e_msgport_get(reply_port);
g_assert(reply == msg);
+ d(printf("waiting for child to exit\n"));
+ pthread_join(id, NULL);
+ d(printf("child done\n"));
}
- d(printf("waiting for child to exit\n"));
- 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(errno));
}
e_msgport_destroy(reply_port);
}
@@ -794,23 +807,25 @@ camel_gethostbyname (const char *name, CamelException *ex)
camel_operation_end(NULL);
- if (msg->result != 0) {
- if (!camel_exception_is_set(ex)) {
- if (msg->herr == HOST_NOT_FOUND || msg->herr == NO_DATA)
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Host lookup failed: %s: host not found"), name);
- else
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Host lookup failed: %s: unknown reason"), name);
- }
+ if (!camel_exception_is_set(ex)) {
+ if (msg->result == 0)
+ return &msg->hostbuf;
+
+ if (msg->herr == HOST_NOT_FOUND || msg->herr == NO_DATA)
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Host lookup failed: %s: host not found"), name);
+ else
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Host lookup failed: %s: unknown reason"), name);
+ }
+
+ if (msg) {
g_free(msg->hostbufmem);
g_free(msg);
- return NULL;
- } else {
- return &msg->hostbuf;
}
-}
+ return NULL;
+}
static void *
get_hostbyaddr (void *data)
@@ -830,7 +845,12 @@ get_hostbyaddr (void *data)
d(printf ("gethostbyaddr ok?\n"));
#ifdef ENABLE_THREADS
- e_msgport_reply ((EMsg *) info);
+ if (info->cancelled) {
+ g_free(info->hostbufmem);
+ g_free(info);
+ } else {
+ e_msgport_reply((EMsg *)info);
+ }
#endif
return NULL;
}
@@ -884,24 +904,28 @@ camel_gethostbyaddr (const char *addr, int len, int type, CamelException *ex)
status = select (fdmax, &rdset, NULL, 0, NULL);
} while (status == -1 && errno == EINTR);
- if (status == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Failure in name lookup: %s"), g_strerror (errno));
- d(printf ("Cancelling lookup thread\n"));
- pthread_cancel (id);
- } else if (FD_ISSET(cancel_fd, &rdset)) {
- d(printf ("Cancelling lookup thread\n"));
- camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
- pthread_cancel (id);
+ if (status == -1 || FD_ISSET(cancel_fd, &rdset)) {
+ if (status == -1)
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Failure in name lookup: %s"), g_strerror(errno));
+ else
+ camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
+
+ /* 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("Cancelling lookup thread and leaving it\n"));
+ msg->cancelled = 1;
+ pthread_detach(id);
+ pthread_cancel(id);
+ msg = (struct _lookup_msg *)e_msgport_get(reply_port);
} else {
- struct _lookup_msg *reply = (struct _lookup_msg *) e_msgport_get (reply_port);
-
- g_assert (reply == msg);
+ struct _lookup_msg *reply = (struct _lookup_msg *)e_msgport_get(reply_port);
+
+ g_assert(reply == msg);
+ d(printf("waiting for child to exit\n"));
+ pthread_join(id, NULL);
+ d(printf("child done\n"));
}
-
- d(printf ("waiting for child to exit\n"));
- pthread_join (id, NULL);
- d(printf ("child done\n"));
}
e_msgport_destroy (reply_port);
@@ -909,23 +933,25 @@ camel_gethostbyaddr (const char *addr, int len, int type, CamelException *ex)
#endif
camel_operation_end (NULL);
-
- if (msg->result != 0) {
- if (!camel_exception_is_set (ex)) {
- if (msg->herr == HOST_NOT_FOUND || msg->herr == NO_DATA)
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Host lookup failed: host not found"));
- else
- camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM,
- _("Host lookup failed: unknown reason"));
- }
-
- g_free (msg->hostbufmem);
- g_free (msg);
- return NULL;
- } else {
- return &msg->hostbuf;
+
+ if (!camel_exception_is_set(ex)) {
+ if (msg->result == 0)
+ return &msg->hostbuf;
+
+ if (msg->herr == HOST_NOT_FOUND || msg->herr == NO_DATA)
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Host lookup failed: host not found"));
+ else
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
+ _("Host lookup failed: unknown reason"));
}
+
+ if (msg) {
+ g_free(msg->hostbufmem);
+ g_free(msg);
+ }
+
+ return NULL;
}
void camel_free_host(struct hostent *h)