aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-service.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-03-30 09:08:28 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-03-30 09:08:28 +0800
commit55c3dea8392096c85ab4bfcd7872b44bb1a3e16c (patch)
treea8f4c76c6324735df629171e507c50a45134bd03 /camel/camel-service.c
parent554de99b229180451331f81adc3f6195bf525878 (diff)
downloadgsoc2013-evolution-55c3dea8392096c85ab4bfcd7872b44bb1a3e16c.tar.gz
gsoc2013-evolution-55c3dea8392096c85ab4bfcd7872b44bb1a3e16c.tar.zst
gsoc2013-evolution-55c3dea8392096c85ab4bfcd7872b44bb1a3e16c.zip
Dont overwrite an exception if we got one already. Added camel_operation
2001-03-30 Not Zed <NotZed@Ximian.com> * camel-service.c (camel_get_host_byname): Dont overwrite an exception if we got one already. Added camel_operation status to it, and comment out some debug. svn path=/trunk/; revision=9034
Diffstat (limited to 'camel/camel-service.c')
-rw-r--r--camel/camel-service.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 5f6d983435..1380cca4bb 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -44,6 +44,8 @@
#include "camel-operation.h"
#include "camel-private.h"
+#define d(x)
+
static CamelObjectClass *parent_class = NULL;
/* Returns the class for a CamelService */
@@ -513,7 +515,7 @@ get_host(void *data)
struct _lookup_msg *info = data;
while ((info->result = gethostbyname_r(info->name, &info->hostbuf, info->hostbufmem, info->hostbuflen, &info->hp, &info->herr)) == ERANGE) {
- printf("gethostbyname fialed?\n");
+ d(printf("gethostbyname fialed?\n"));
#ifdef ENABLE_THREADS
pthread_testcancel();
#endif
@@ -521,7 +523,7 @@ get_host(void *data)
info->hostbufmem = g_realloc(info->hostbufmem, info->hostbuflen);
}
- printf("gethostbyname ok?\n");
+ d(printf("gethostbyname ok?\n"));
#ifdef ENABLE_THREADS
e_msgport_reply((EMsg *)info);
@@ -543,6 +545,8 @@ struct hostent *camel_get_host_byname(const char *name, CamelException *ex)
return NULL;
}
+ camel_operation_start(NULL, _("Resolving: %s"), name);
+
msg = g_malloc0(sizeof(*msg));
msg->hostbuflen = 1024;
msg->hostbufmem = g_malloc(msg->hostbuflen);
@@ -566,13 +570,13 @@ struct hostent *camel_get_host_byname(const char *name, CamelException *ex)
FD_SET(cancel_fd, &rdset);
FD_SET(fd, &rdset);
fdmax = MAX(fd, cancel_fd) + 1;
- printf("waiting for name return/cancellation in main process\n");
+ d(printf("waiting for name return/cancellation in main process\n"));
if (select(fdmax, &rdset, NULL, 0, NULL) == -1) {
camel_exception_setv(ex, 1, _("Failure in name lookup: %s"), strerror(errno));
- printf("Cancelling lookup thread\n");
+ d(printf("Cancelling lookup thread\n"));
pthread_cancel(id);
} else if (FD_ISSET(cancel_fd, &rdset)) {
- printf("Cancelling lookup thread\n");
+ d(printf("Cancelling lookup thread\n"));
camel_exception_setv(ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cancelled"));
pthread_cancel(id);
} else {
@@ -580,18 +584,23 @@ struct hostent *camel_get_host_byname(const char *name, CamelException *ex)
g_assert(reply == msg);
}
- printf("waiting for child to exit\n");
+ d(printf("waiting for child to exit\n"));
pthread_join(id, NULL);
+ d(printf("child done\n"));
}
e_msgport_destroy(reply_port);
}
#endif
+ camel_operation_end(NULL);
+
if (msg->hp == NULL) {
- if (msg->herr == HOST_NOT_FOUND || msg->herr == NO_DATA)
- camel_exception_setv(ex, 1, _("Host lookup failed: %s: host not found"), name);
- else
- camel_exception_setv(ex, 1, _("Host lookup failed: %s: unknown reason"), name);
+ if (!camel_exception_is_set(ex)) {
+ if (msg->herr == HOST_NOT_FOUND || msg->herr == NO_DATA)
+ camel_exception_setv(ex, 1, _("Host lookup failed: %s: host not found"), name);
+ else
+ camel_exception_setv(ex, 1, _("Host lookup failed: %s: unknown reason"), name);
+ }
g_free(msg->hostbufmem);
g_free(msg);
return NULL;