sync with 0.9.2cvs10
authorPaul Mangan <paul@claws-mail.org>
Tue, 1 Jul 2003 10:33:14 +0000 (10:33 +0000)
committerPaul Mangan <paul@claws-mail.org>
Tue, 1 Jul 2003 10:33:14 +0000 (10:33 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
configure.ac
src/common/session.c
src/common/socket.c
src/common/socket.h

index a01ecc6..605999e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-07-01
+
+       * src/socket.[ch]: added sock_has_pending_data() which returns TRUE
+         if socket has pending data.
+       * src/session.c: session_recv_msg(), session_recv_data(): check if
+         socket has pending data and call the callbacks immediately in that
+         case (fixes the hang at ESMTP EHLO on SSL).
+
 2003-06-30
 
        * src/socket.c: check return value in SSL functions.
index 95da3a5..7681cbe 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-01 [paul]      0.9.0claws70
+
+       * sync with 0.9.2cvs10
+               see ChangeLog 2003-07-01
+
 2003-06-30 [paul]      0.9.0claws69
 
        * sync with 0.9.2cvs9
index 51332d2..6ac7742 100644 (file)
@@ -1,3 +1,11 @@
+2003-07-01
+
+       * src/socket.[ch]: ¥½¥±¥Ã¥È¤Ë̤½èÍý¤Î¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¾ì¹ç TRUE ¤ò
+         ÊÖ¤¹ sock_has_pending_data() ¤òÄɲá£
+       * src/session.c: session_recv_msg(), session_recv_data(): ¥½¥±¥Ã¥È¤Ë
+         Ì¤½èÍý¤Î¥Ç¡¼¥¿¤¬¤¢¤ë¤«¤É¤¦¤«¤òÄ´¤Ù¡¢¤¢¤ë¾ì¹ç¤Ï¥³¡¼¥ë¥Ð¥Ã¥¯¤ò¤¹¤°¤Ë
+         ¸Æ¤Ö¤è¤¦¤Ë¤·¤¿(SSL ¤Ç¤Î ESMTP EHLO »þ¤Ë¸Ç¤Þ¤ë¤Î¤ò½¤Àµ)¡£
+
 2003-06-30
 
        * src/socket.c: SSL ´Ø¿ô¤ÇÌá¤êÃͤò¥Á¥§¥Ã¥¯¡£
index c178a04..a973fec 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws69
+EXTRA_VERSION=claws70
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index fdd5e37..9b4a638 100644 (file)
@@ -42,6 +42,9 @@ static gint session_connect_cb                (SockInfo       *sock,
                                         gpointer        data);
 static gint session_close              (Session        *session);
 
+static gboolean session_read_msg_idle_cb       (gpointer        data);
+static gboolean session_read_data_idle_cb      (gpointer        data);
+
 static gboolean session_read_msg_cb    (GIOChannel     *source,
                                         GIOCondition    condition,
                                         gpointer        data);
@@ -313,12 +316,29 @@ gint session_recv_msg(Session *session)
 
        session->state = SESSION_RECV;
 
-       session->io_tag = g_io_add_watch(session->sock_ch, G_IO_IN,
-                                        session_read_msg_cb, session);
+       if (sock_has_pending_data(session->sock))
+               g_idle_add(session_read_msg_idle_cb, session);
+       else
+               session->io_tag = g_io_add_watch(session->sock_ch, G_IO_IN,
+                                                session_read_msg_cb, session);
 
        return 0;
 }
 
+static gboolean session_read_msg_idle_cb(gpointer data)
+{
+       Session *session = SESSION(data);
+       gboolean ret;
+
+       ret = session_read_msg_cb(session->sock_ch, G_IO_IN, data);
+
+       if (ret == TRUE)
+               session->io_tag = g_io_add_watch(session->sock_ch, G_IO_IN,
+                                                session_read_msg_cb, session);
+
+       return FALSE;
+}
+
 /*!
  *\brief       parent (child?): send data to other process
  *
@@ -367,12 +387,29 @@ gint session_recv_data(Session *session, guint size, const gchar *terminator)
        session->read_data_terminator = g_strdup(terminator);
        gettimeofday(&session->tv_prev, NULL);
 
-       session->io_tag = g_io_add_watch(session->sock_ch, G_IO_IN,
-                                        session_read_data_cb, session);
+       if (sock_has_pending_data(session->sock))
+               g_idle_add(session_read_data_idle_cb, session);
+       else
+               session->io_tag = g_io_add_watch(session->sock_ch, G_IO_IN,
+                                                session_read_data_cb, session);
 
        return 0;
 }
 
+static gboolean session_read_data_idle_cb(gpointer data)
+{
+       Session *session = SESSION(data);
+       gboolean ret;
+
+       ret = session_read_data_cb(session->sock_ch, G_IO_IN, data);
+
+       if (ret == TRUE)
+               session->io_tag = g_io_add_watch(session->sock_ch, G_IO_IN,
+                                                session_read_data_cb, session);
+
+       return FALSE;
+}
+
 static gboolean session_read_msg_cb(GIOChannel *source, GIOCondition condition,
                                    gpointer data)
 {
@@ -478,6 +515,8 @@ static gboolean session_read_data_cb(GIOChannel     *source, GIOCondition condition,
                }
        }
 
+       g_print("session_read_data_cb(): read %d bytes\n", read_len);
+
        data_buf = session->read_data_buf;
 
        g_byte_array_append(data_buf, buf, read_len);
index 0b9764f..4367470 100644 (file)
@@ -251,6 +251,31 @@ gboolean sock_is_nonblocking_mode(SockInfo *sock)
        return is_nonblocking_mode(sock->sock);
 }
 
+gboolean sock_has_pending_data(SockInfo *sock)
+{
+       struct timeval timeout = {0, 0};
+       fd_set fds;
+
+#if USE_OPENSSL
+       if (sock->ssl) {
+               if (SSL_pending(sock->ssl) > 0)
+                       g_print("socket has pending data\n");
+
+               return SSL_pending(sock->ssl) > 0;
+       }
+#endif
+
+       FD_ZERO(&fds);
+       FD_SET(sock->sock, &fds);
+
+       select(sock->sock + 1, &fds, NULL, NULL, &timeout);
+
+       if (FD_ISSET(sock->sock, &fds))
+               g_print("socket has pending data\n");
+
+       return FD_ISSET(sock->sock, &fds);
+}
+
 static gint fd_check_io(gint fd, GIOCondition cond)
 {
        struct timeval timeout;
index 2660cda..735a7b7 100644 (file)
@@ -69,6 +69,8 @@ gint sock_set_io_timeout              (guint sec);
 gint sock_set_nonblocking_mode         (SockInfo *sock, gboolean nonblock);
 gboolean sock_is_nonblocking_mode      (SockInfo *sock);
 
+gboolean sock_has_pending_data         (SockInfo *sock);
+
 struct hostent *my_gethostbyname       (const gchar *hostname);
 
 SockInfo *sock_connect                 (const gchar *hostname, gushort port);