diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2002-05-03 02:19:57 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2002-05-03 02:19:57 +0800 |
commit | e7432164869e777b21aee021e23033bbdf747cac (patch) | |
tree | 189a31d7a107ae40935a591a88fea09e2db551d1 /camel | |
parent | c61f26fa581964ff51e1f335840a61078f80cf29 (diff) | |
download | gsoc2013-evolution-e7432164869e777b21aee021e23033bbdf747cac.tar.gz 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')
-rw-r--r-- | camel/ChangeLog | 15 | ||||
-rw-r--r-- | camel/camel-pgp-context.c | 13 | ||||
-rw-r--r-- | camel/camel-service.c | 34 |
3 files changed, 42 insertions, 20 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index a4d7dc2b69..e3d981d6e5 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,18 @@ +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. + +2002-04-29 Jeffrey Stedfast <fejj@ximian.com> + + * camel-provider.c (camel_provider_auto_detect): Now takes a + CamelURL argument rather than a GHashTable *settings argument. + 2002-04-29 Not Zed <NotZed@Ximian.com> * providers/local/camel-spool-store.c (get_folder_info): We want diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c index 29a948e881..e6ef1a7820 100644 --- a/camel/camel-pgp-context.c +++ b/camel/camel-pgp-context.c @@ -422,21 +422,20 @@ crypto_exec_with_passwd (const char *path, char *argv[], const char *input, int select_result = select (max + 1, &fdset, &write_fdset, NULL, &timeout); - if (cancel_fd != -1 && FD_ISSET (cancel_fd, &fdset)) { - /* user-cancelled */ - break; - } - if (select_result < 0) { if (errno == EINTR) continue; break; - } - if (select_result == 0) { + } else if (select_result == 0) { /* timeout */ break; } + if (cancel_fd != -1 && FD_ISSET (cancel_fd, &fdset)) { + /* user-cancelled */ + break; + } + if (FD_ISSET (op_fds[0], &fdset)) { /* More output is available. */ 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")); |