aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-06-11 07:22:39 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-06-11 07:22:39 +0000
commit78d92947e3a35fe3ac0d31f64374a247ccc78e6b (patch)
tree96190dde011c98db8ffccecc66dc06ab284430cd
parentb14cba8ad5b13bccb3eff9e114407d542bc20409 (diff)
fixes stall of SMTP when sending via dialup connection.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1757 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.ja7
-rw-r--r--libsylph/session.c22
-rw-r--r--libsylph/socket.c17
-rw-r--r--libsylph/socket.h2
5 files changed, 52 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2077d0c5..d2f6926b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-06-11
+
+ * libsylph/socket.[ch]: added sock_add_watch_poll().
+ * libsylph/session.c: win32: use blocking socket while sending data
+ (fixes stall of SMTP when sending via dialup connection).
+
2007-06-08
* src/compose.c: compose_get_signature_str(): supported UTF-8 with
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 12addf86..3d2e8c5c 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,10 @@
+2007-06-11
+
+ * libsylph/socket.[ch]: sock_add_watch_poll() を追加。
+ * libsylph/session.c: win32: データの送信中はブロッキングソケットを
+ 使用するようにした(ダイアルアップ接続で送信中にSMTPが停止する問題
+ を修正)。
+
2007-06-08
* src/compose.c: compose_get_signature_str(): BOM 付き UTF-8 に対応。
diff --git a/libsylph/session.c b/libsylph/session.c
index 433ee539..1d8bc0d4 100644
--- a/libsylph/session.c
+++ b/libsylph/session.c
@@ -471,12 +471,22 @@ gint session_send_data(Session *session, FILE *data_fp, guint size)
session->write_data_len = size;
g_get_current_time(&session->tv_prev);
+#ifdef G_OS_WIN32
+ sock_set_nonblocking_mode(session->sock, FALSE);
+#endif
+
ret = session_write_data_cb(session->sock, G_IO_OUT, session);
if (ret == TRUE)
+#ifdef G_OS_WIN32
+ session->io_tag = sock_add_watch_poll(session->sock, G_IO_OUT,
+ session_write_data_cb,
+ session);
+#else
session->io_tag = sock_add_watch(session->sock, G_IO_OUT,
session_write_data_cb,
session);
+#endif
else if (session->state == SESSION_ERROR)
return -1;
@@ -993,7 +1003,7 @@ static gint session_write_buf(Session *session)
#define WRITE_DATA_BUFFSIZE 8192
-static gint session_write_data(Session *session)
+static gint session_write_data(Session *session, gint *nwritten)
{
gchar buf[WRITE_DATA_BUFFSIZE];
gint write_len;
@@ -1021,10 +1031,13 @@ static gint session_write_data(Session *session)
default:
g_warning("sock_write: %s\n", g_strerror(errno));
session->state = SESSION_ERROR;
+ *nwritten = write_len;
return -1;
}
}
+ *nwritten = write_len;
+
/* incomplete write */
if (session->write_data_pos + write_len < session->write_data_len) {
session->write_data_pos += write_len;
@@ -1080,6 +1093,7 @@ static gboolean session_write_data_cb(SockInfo *source,
{
Session *session = SESSION(data);
guint write_data_len;
+ gint write_len;
gint ret;
g_return_val_if_fail(condition == G_IO_OUT, FALSE);
@@ -1089,7 +1103,7 @@ static gboolean session_write_data_cb(SockInfo *source,
write_data_len = session->write_data_len;
- ret = session_write_data(session);
+ ret = session_write_data(session, &write_len);
if (ret < 0) {
session->state = SESSION_ERROR;
@@ -1124,5 +1138,9 @@ static gboolean session_write_data_cb(SockInfo *source,
session->send_data_notify(session, write_data_len,
session->send_data_notify_data);
+#ifdef G_OS_WIN32
+ sock_set_nonblocking_mode(session->sock, session->nonblocking);
+#endif
+
return FALSE;
}
diff --git a/libsylph/socket.c b/libsylph/socket.c
index abf5671f..a1600381 100644
--- a/libsylph/socket.c
+++ b/libsylph/socket.c
@@ -568,6 +568,23 @@ guint sock_add_watch(SockInfo *sock, GIOCondition condition, SockFunc func,
return g_io_add_watch(sock->sock_ch, condition, sock_watch_cb, sock);
}
+guint sock_add_watch_poll(SockInfo *sock, GIOCondition condition, SockFunc func,
+ gpointer data)
+{
+ GSource *source;
+
+ sock->callback = func;
+ sock->condition = condition;
+ sock->data = data;
+
+ source = g_source_new(&sock_watch_funcs, sizeof(SockSource));
+ ((SockSource *)source)->sock = sock;
+ g_source_set_priority(source, G_PRIORITY_DEFAULT);
+ g_source_set_can_recurse(source, FALSE);
+
+ return g_source_attach(source, NULL);
+}
+
static gint fd_check_io(gint fd, GIOCondition cond)
{
struct timeval timeout;
diff --git a/libsylph/socket.h b/libsylph/socket.h
index 384f61a4..0ad2010f 100644
--- a/libsylph/socket.h
+++ b/libsylph/socket.h
@@ -93,6 +93,8 @@ gboolean sock_has_read_data (SockInfo *sock);
guint sock_add_watch (SockInfo *sock, GIOCondition condition,
SockFunc func, gpointer data);
+guint sock_add_watch_poll (SockInfo *sock, GIOCondition condition,
+ SockFunc func, gpointer data);
struct hostent *my_gethostbyname (const gchar *hostname);