aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ChangeLog.ja6
-rw-r--r--libsylph/session.c35
-rw-r--r--libsylph/session.h3
4 files changed, 44 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index ea5ad70a..bf02a824 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-04-17
+
+ * libsylph/session.[ch]: remove idle callback on close, and check
+ GSource in the callback (possibly fixes crashes on cancellation).
+
2007-04-16
* manual/ja/sylpheed.sgml
diff --git a/ChangeLog.ja b/ChangeLog.ja
index c192f7fd..08410396 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,9 @@
+2007-04-17
+
+ * libsylph/session.[ch]: クローズ時に idle コールバックを削除する
+ ようにし、コールバック中で GSource をチェックするようにした
+ (キャンセル時のクラッシュを恐らく修正)。
+
2007-04-16
* manual/ja/sylpheed.sgml
diff --git a/libsylph/session.c b/libsylph/session.c
index 2252b65b..9e0006d3 100644
--- a/libsylph/session.c
+++ b/libsylph/session.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -111,6 +111,7 @@ void session_init(Session *session)
session->timeout_tag = 0;
session->timeout_interval = 0;
+ session->idle_tag = 0;
session->ping_tag = 0;
session->data = NULL;
@@ -343,6 +344,11 @@ static gint session_close(Session *session)
session_set_timeout(session, 0);
+ if (session->idle_tag > 0) {
+ g_source_remove(session->idle_tag);
+ session->idle_tag = 0;
+ }
+
#ifdef G_OS_WIN32
if (session->ping_tag > 0) {
g_source_remove(session->ping_tag);
@@ -418,7 +424,8 @@ gint session_recv_msg(Session *session)
session->state = SESSION_RECV;
if (session->read_buf_len > 0)
- g_idle_add(session_recv_msg_idle_cb, session);
+ session->idle_tag = g_idle_add(session_recv_msg_idle_cb,
+ session);
else
session->io_tag = sock_add_watch(session->sock, G_IO_IN,
session_read_msg_cb, session);
@@ -431,6 +438,12 @@ static gboolean session_recv_msg_idle_cb(gpointer data)
Session *session = SESSION(data);
gboolean ret;
+#if GLIB_CHECK_VERSION(2, 12, 0)
+ if (g_source_is_destroyed(g_main_current_source()))
+ return FALSE;
+#endif
+
+ session->idle_tag = 0;
ret = session_read_msg_cb(session->sock, G_IO_IN, session);
if (ret == TRUE)
@@ -478,7 +491,8 @@ gint session_recv_data(Session *session, guint size, const gchar *terminator)
g_get_current_time(&session->tv_prev);
if (session->read_buf_len > 0)
- g_idle_add(session_recv_data_idle_cb, session);
+ session->idle_tag = g_idle_add(session_recv_data_idle_cb,
+ session);
else
session->io_tag = sock_add_watch(session->sock, G_IO_IN,
session_read_data_cb, session);
@@ -491,6 +505,12 @@ static gboolean session_recv_data_idle_cb(gpointer data)
Session *session = SESSION(data);
gboolean ret;
+#if GLIB_CHECK_VERSION(2, 12, 0)
+ if (g_source_is_destroyed(g_main_current_source()))
+ return FALSE;
+#endif
+
+ session->idle_tag = 0;
ret = session_read_data_cb(session->sock, G_IO_IN, session);
if (ret == TRUE)
@@ -519,7 +539,8 @@ gint session_recv_data_as_file(Session *session, guint size,
}
if (session->read_buf_len > 0)
- g_idle_add(session_recv_data_as_file_idle_cb, session);
+ session->idle_tag =
+ g_idle_add(session_recv_data_as_file_idle_cb, session);
else
session->io_tag = sock_add_watch(session->sock, G_IO_IN,
session_read_data_as_file_cb,
@@ -533,6 +554,12 @@ static gboolean session_recv_data_as_file_idle_cb(gpointer data)
Session *session = SESSION(data);
gboolean ret;
+#if GLIB_CHECK_VERSION(2, 12, 0)
+ if (g_source_is_destroyed(g_main_current_source()))
+ return FALSE;
+#endif
+
+ session->idle_tag = 0;
ret = session_read_data_as_file_cb(session->sock, G_IO_IN, session);
if (ret == TRUE)
diff --git a/libsylph/session.h b/libsylph/session.h
index 5ff12984..b5127c0e 100644
--- a/libsylph/session.h
+++ b/libsylph/session.h
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -142,6 +142,7 @@ struct _Session
guint timeout_tag;
guint timeout_interval;
+ guint idle_tag;
guint ping_tag;
gpointer data;