sync with sylpheed 0.7.4cvs3
authorPaul Mangan <paul@claws-mail.org>
Fri, 15 Mar 2002 08:26:13 +0000 (08:26 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 15 Mar 2002 08:26:13 +0000 (08:26 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.in
src/socket.c

index 91662d1c8c8d5e7d25fd99950441877f80ceadf8..fde425091a6f046b1442a47ff92184e07934c577 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-03-14
+
+       * src/socket.c: implemented timeout for DNS lookup and connect().
+         sock_connect_by_hostname(): timeout support and code cleanup.
+         sock_connect_with_timeout(): new.
+         sock_peek(): implemented SSL peek.
+
 2002-03-13
 
        * src/messageview.c: messageview_show(): display single-part
index 3a4e753fbe0550add2558c59ea661389f4e3f93e..58b270fb523f3c7aa472e89dd86e891abbeb1204 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-15 [paul]      0.7.4claws7
+
+       * sync with sylpheed 0.7.4cvs3
+               see ChangeLog entry 2002-03-14
+
 2002-03-14 [paul]      0.7.4claws7
 
        * src/compose.c
index e8b606a45465e87b8321a8280b42ef6feed94b88..365add5f0bdd5194cef365f8cbebe216d7e88f12 100644 (file)
@@ -1,7 +1,44 @@
+2002-03-14
+
+       * src/socket.c: DNS lookup ¤È connect() ¤Î¥¿¥¤¥à¥¢¥¦¥È¤ò¼ÂÁõ¡£
+         sock_connect_by_hostname(): ¥¿¥¤¥à¥¢¥¦¥ÈÂбþ¤È¥³¡¼¥É¤ÎÀ°Íý¡£
+         sock_connect_with_timeout(): ¿·µ¬¡£
+         sock_peek(): SSL peek ¤ò¼ÂÁõ¡£
+
 2002-03-13
 
        * src/messageview.c: messageview_show(): ¥·¥ó¥°¥ë¥Ñ¡¼¥È¤Î text/html
          ¥á¥Ã¥»¡¼¥¸¤òÄ̾ï¤Î¥Æ¥­¥¹¥È¥Ó¥å¡¼¤Çɽ¼¨¡£
+       * src/account.c
+         src/addrbook.c
+         src/addrindex.c
+         src/compose.c
+         src/imap.c
+         src/inc.c
+         src/jpilot.c
+         src/ldif.c
+         src/mbox.c
+         src/mimeview.c
+         src/news.c
+         src/prefs.c
+         src/prefs_common.c
+         src/prefs_customheader.c
+         src/prefs_display_header.c
+         src/prefs_filter.c
+         src/procheader.c
+         src/procmime.c
+         src/procmsg.c
+         src/recv.c
+         src/rfc2015.c
+         src/send.c
+         src/sourcewindow.c
+         src/summaryview.c
+         src/template.c
+         src/textview.c
+         src/unmime.c
+         src/utils.c
+         src/vcard.c
+         src/xml.c: added 'b' to the option of all fopen().
 
 2002-03-09
 
index 89c9af41644fcfd203cc8d72a77bb397ce58508f..d9c0489dcf4d33fc532e1a4804f355345f130231 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=4
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws7
+EXTRA_VERSION=claws8
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index fa2d026a02971e4aa08e4d8d436f8ecd67b4b944..86c95be08bff8ac11406c5c5efd84fbb123ea7b8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-#include <signal.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <signal.h>
+#include <setjmp.h>
 
 #include "socket.h"
 #include "utils.h"
 
 #define BUFFSIZE       8192
 
+static gint sock_connect_with_timeout  (gint                    sock,
+                                        const struct sockaddr  *serv_addr,
+                                        gint                    addrlen,
+                                        guint                   timeout_secs);
+
 #ifndef INET6
 static gint sock_connect_by_hostname   (gint            sock,
                                         const gchar    *hostname,
@@ -172,41 +178,96 @@ gboolean sock_is_nonblocking_mode(SockInfo *sock)
        return is_nonblocking_mode(sock->sock);
 }
 
+static sigjmp_buf jmpenv;
+
+static void timeout_handler(gint sig)
+{
+       siglongjmp(jmpenv, 1);
+}
+
+static gint sock_connect_with_timeout(gint sock,
+                                     const struct sockaddr *serv_addr,
+                                     gint addrlen,
+                                     guint timeout_secs)
+{
+       gint ret;
+       void (*prev_handler)(gint);
+
+       alarm(0);
+       prev_handler = signal(SIGALRM, timeout_handler);
+       if (sigsetjmp(jmpenv, 1)) {
+               alarm(0);
+               signal(SIGALRM, prev_handler);
+               errno = ETIMEDOUT;
+               return -1;
+       }
+       alarm(timeout_secs);
+
+       ret = connect(sock, serv_addr, addrlen);
+
+       alarm(0);
+       signal(SIGALRM, prev_handler);
+
+       return ret;
+}
 
 #ifndef INET6
-static gint sock_connect_by_hostname(gint sock, const gchar *hostname,
-                                    gushort port)
+static gint my_inet_aton(const gchar *hostname, struct in_addr *inp)
 {
-       struct hostent *hp;
-       struct sockaddr_in ad;
-#ifndef HAVE_INET_ATON
+#if HAVE_INET_ATON
+       return inet_aton(hostname, inp);
+#else
 #if HAVE_INET_ADDR
        guint32 inaddr;
+
+       inaddr = inet_addr(hostname);
+       if (inaddr != -1) {
+               memcpy(inp, &inaddr, sizeof(inaddr));
+               return 1;
+       } else
+               return 0;
+#else
+       return 0;
 #endif
 #endif /* HAVE_INET_ATON */
+}
+
+static gint sock_connect_by_hostname(gint sock, const gchar *hostname,
+                                    gushort port)
+{
+       struct hostent *hp;
+       struct sockaddr_in ad;
+       guint timeout_secs = 30;
 
        memset(&ad, 0, sizeof(ad));
        ad.sin_family = AF_INET;
        ad.sin_port = htons(port);
 
-#if HAVE_INET_ATON
-       if (!inet_aton(hostname, &ad.sin_addr)) {
-#else
-#if HAVE_INET_ADDR
-       inaddr = inet_addr(hostname);
-       if (inaddr != -1)
-               memcpy(&ad.sin_addr, &inaddr, sizeof(inaddr));
-       else {
-#else
-       {
-#endif
-#endif /* HAVE_INET_ATON */
+       if (!my_inet_aton(hostname, &ad.sin_addr)) {
+               void (*prev_handler)(gint);
+
+               alarm(0);
+               prev_handler = signal(SIGALRM, timeout_handler);
+               if (sigsetjmp(jmpenv, 1)) {
+                       alarm(0);
+                       signal(SIGALRM, prev_handler);
+                       fprintf(stderr, "%s: host lookup timed out.\n", hostname);
+                       errno = 0;
+                       return -1;
+               }
+               alarm(timeout_secs);
+
                if ((hp = gethostbyname(hostname)) == NULL) {
+                       alarm(0);
+                       signal(SIGALRM, prev_handler);
                        fprintf(stderr, "%s: unknown host.\n", hostname);
                        errno = 0;
                        return -1;
                }
 
+               alarm(0);
+               signal(SIGALRM, prev_handler);
+
                if (hp->h_length != 4 && hp->h_length != 8) {
                        fprintf(stderr, "illegal address length received for host %s\n", hostname);
                        errno = 0;
@@ -216,7 +277,8 @@ static gint sock_connect_by_hostname(gint sock, const gchar *hostname,
                memcpy(&ad.sin_addr, hp->h_addr, hp->h_length);
        }
 
-       return connect(sock, (struct sockaddr *)&ad, sizeof(ad));
+       return sock_connect_with_timeout(sock, (struct sockaddr *)&ad,
+                                        sizeof(ad), timeout_secs);
 }
 
 #else /* INET6 */
@@ -224,6 +286,7 @@ static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort      port)
 {
        gint sock = -1, gai_error;
        struct addrinfo hints, *res, *ai;
+       guint timeout_secs = 30;
        gchar port_str[6];
 
        memset(&hints, 0, sizeof(hints));
@@ -246,7 +309,8 @@ static gint sock_connect_by_getaddrinfo(const gchar *hostname, gushort      port)
                if (sock < 0)
                        continue;
 
-               if (connect(sock, ai->ai_addr, ai->ai_addrlen) == 0)
+               if (sock_connect_with_timeout
+                       (sock, ai->ai_addr, ai->ai_addrlen, timeout_secs) == 0)
                        break;
 
                close(sock);
@@ -553,6 +617,14 @@ gint sock_peek(SockInfo *sock)
 
        g_return_val_if_fail(sock != NULL, -1);
 
+#if USE_SSL
+       if (sock->ssl) {
+               if ((n = SSL_peek(sock->ssl, &ch, 1)) < 0)
+                       return -1;
+               else
+                       return ch;
+       }
+#endif
        if ((n = recv(sock->sock, &ch, 1, MSG_PEEK)) < 0)
                return -1;
        else