aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-09-26 06:28:16 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-09-26 06:28:16 +0000
commitb94e6a1d8c18513d022cd1ff57a1924de7be1b84 (patch)
tree619b42b806910f8ffb770377ffb97c42b8660dc2
parent760a2b226de7779daf433cccf1128f0ae4cbb51b (diff)
made workaround for state machine freeze problem in Win32.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1188 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.ja7
-rw-r--r--libsylph/session.c38
-rw-r--r--libsylph/session.h4
4 files changed, 52 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index bb902874..a23a90cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-26
+
+ * libsylph/session.[ch]: win32: made workaround for state machine
+ freeze problem in GLib >= 2.8.x.
+ session_read_data_as_file_cb(): reset Session::read_buf_len to
+ prevent the unexpected call of idle functions.
+
2006-09-22
* version 2.2.9
diff --git a/ChangeLog.ja b/ChangeLog.ja
index cac6358e..7288c0f2 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,10 @@
+2006-09-26
+
+ * libsylph/session.[ch]: win32: GLib >= 2.8.x でステートマシンが
+ フリーズする問題に対処。
+ session_read_data_as_file_cb(): 予期せず idle 関数が呼ばれるのを
+ 防ぐために Session::read_buf_len をリセットするようにした。
+
2006-09-22
* version 2.2.9
diff --git a/libsylph/session.c b/libsylph/session.c
index b8b77aff..1d1300e5 100644
--- a/libsylph/session.c
+++ b/libsylph/session.c
@@ -41,6 +41,10 @@ static gint session_close (Session *session);
static gboolean session_timeout_cb (gpointer data);
+#ifdef G_OS_WIN32
+static gboolean session_ping_cb (gpointer data);
+#endif
+
static gboolean session_recv_msg_idle_cb (gpointer data);
static gboolean session_recv_data_idle_cb (gpointer data);
@@ -107,6 +111,8 @@ void session_init(Session *session)
session->timeout_tag = 0;
session->timeout_interval = 0;
+ session->ping_tag = 0;
+
session->data = NULL;
}
@@ -176,6 +182,10 @@ static gint session_connect_cb(SockInfo *sock, gpointer data)
session_read_msg_cb,
session);
+#ifdef G_OS_WIN32
+ session->ping_tag = g_timeout_add(1000, session_ping_cb, session);
+#endif
+
return 0;
}
@@ -247,6 +257,20 @@ static gboolean session_timeout_cb(gpointer data)
return FALSE;
}
+#ifdef G_OS_WIN32
+/* hack for state machine freeze problem in GLib >= 2.8.x */
+static gboolean session_ping_cb(gpointer data)
+{
+ Session *session = SESSION(data);
+ SockInfo *sock = session->sock;
+
+ if (session->io_tag > 0 && sock && sock->callback)
+ sock->callback(sock, sock->condition, sock->data);
+
+ return TRUE;
+}
+#endif
+
void session_set_recv_message_notify(Session *session,
RecvMsgNotify notify_func, gpointer data)
{
@@ -300,6 +324,13 @@ static gint session_close(Session *session)
session_set_timeout(session, 0);
+#ifdef G_OS_WIN32
+ if (session->ping_tag > 0) {
+ g_source_remove(session->ping_tag);
+ session->ping_tag = 0;
+ }
+#endif
+
if (session->io_tag > 0) {
g_source_remove(session->io_tag);
session->io_tag = 0;
@@ -848,6 +879,10 @@ static gboolean session_read_data_as_file_cb(SockInfo *source,
}
rewind(session->read_data_fp);
+ session->preread_len = 0;
+ session->read_buf_len = 0;
+ session->read_buf_p = session->read_buf;
+
/* callback */
ret = session->recv_data_as_file_finished
(session, session->read_data_fp, session->read_data_pos);
@@ -859,9 +894,6 @@ static gboolean session_read_data_as_file_cb(SockInfo *source,
session->recv_data_notify_data);
session->read_data_pos = 0;
- session->preread_len = 0;
- session->read_buf_len = 0;
- session->read_buf_p = session->read_buf;
if (ret < 0)
session->state = SESSION_ERROR;
diff --git a/libsylph/session.h b/libsylph/session.h
index de39f2dd..e1d5fee6 100644
--- a/libsylph/session.h
+++ b/libsylph/session.h
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2005 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2006 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -137,6 +137,8 @@ struct _Session
guint timeout_tag;
guint timeout_interval;
+ guint ping_tag;
+
gpointer data;
/* virtual methods to parse server responses */