aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-service.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-05-03 02:19:57 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-05-03 02:19:57 +0800
commite7432164869e777b21aee021e23033bbdf747cac (patch)
tree189a31d7a107ae40935a591a88fea09e2db551d1 /camel/camel-service.c
parentc61f26fa581964ff51e1f335840a61078f80cf29 (diff)
downloadgsoc2013-evolution-e7432164869e777b21aee021e23033bbdf747cac.tar
gsoc2013-evolution-e7432164869e777b21aee021e23033bbdf747cac.tar.gz
gsoc2013-evolution-e7432164869e777b21aee021e23033bbdf747cac.tar.bz2
gsoc2013-evolution-e7432164869e777b21aee021e23033bbdf747cac.tar.lz
gsoc2013-evolution-e7432164869e777b21aee021e23033bbdf747cac.tar.xz
gsoc2013-evolution-e7432164869e777b21aee021e23033bbdf747cac.tar.zst
gsoc2013-evolution-e7432164869e777b21aee021e23033bbdf747cac.zip
Change the order of some code so that we check if the select() failed
2002-05-02 Jeffrey Stedfast <fejj@ximian.com> * camel-pgp-context.c (crypto_exec_with_passwd): Change the order of some code so that we check if the select() failed before we check for user-cancellation. * camel-service.c (camel_gethostbyname): Check for EINTR when select()ing. (camel_gethostbyaddr): Same. svn path=/trunk/; revision=16666
Diffstat (limited to 'camel/camel-service.c')
-rw-r--r--camel/camel-service.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 502da90c5a..19c058f970 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -600,10 +600,10 @@ get_hostbyname(void *data)
}
struct hostent *
-camel_gethostbyname(const char *name, CamelException *ex)
+camel_gethostbyname (const char *name, CamelException *ex)
{
#ifdef ENABLE_THREADS
- int fdmax, fd, cancel_fd;
+ int fdmax, status, fd, cancel_fd;
#endif
struct _lookup_msg *msg;
@@ -635,12 +635,16 @@ camel_gethostbyname(const char *name, CamelException *ex)
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) {
- FD_ZERO(&rdset);
- FD_SET(cancel_fd, &rdset);
- FD_SET(fd, &rdset);
- fdmax = MAX(fd, cancel_fd) + 1;
d(printf("waiting for name return/cancellation in main process\n"));
- if (select(fdmax, &rdset, NULL, 0, NULL) == -1) {
+ do {
+ FD_ZERO(&rdset);
+ FD_SET(cancel_fd, &rdset);
+ FD_SET(fd, &rdset);
+ fdmax = MAX(fd, cancel_fd) + 1;
+ status = select (fdmax, &rdset, NULL, 0, NULL);
+ } while (status == -1 && errno == EINTR);
+
+ if (status == -1) {
camel_exception_setv(ex, 1, _("Failure in name lookup: %s"), strerror(errno));
d(printf("Cancelling lookup thread\n"));
pthread_cancel(id);
@@ -707,7 +711,7 @@ struct hostent *
camel_gethostbyaddr (const char *addr, int len, int type, CamelException *ex)
{
#ifdef ENABLE_THREADS
- int fdmax, fd, cancel_fd;
+ int fdmax, status, fd, cancel_fd;
#endif
struct _lookup_msg *msg;
@@ -741,12 +745,16 @@ camel_gethostbyaddr (const char *addr, int len, int type, CamelException *ex)
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) {
- FD_ZERO(&rdset);
- FD_SET(cancel_fd, &rdset);
- FD_SET(fd, &rdset);
- fdmax = MAX(fd, cancel_fd) + 1;
d(printf("waiting for name return/cancellation in main process\n"));
- if (select (fdmax, &rdset, NULL, 0, NULL) == -1) {
+ do {
+ FD_ZERO(&rdset);
+ FD_SET(cancel_fd, &rdset);
+ FD_SET(fd, &rdset);
+ fdmax = MAX(fd, cancel_fd) + 1;
+ 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"));