[evolution-data-server] Bug 749292 - SMTP connection lost while reading message data
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 749292 - SMTP connection lost while reading message data
- Date: Tue, 26 May 2015 07:17:32 +0000 (UTC)
commit 69835113e131873ea25a6212c0d250727a10ace6
Author: Milan Crha <mcrha redhat com>
Date: Tue May 26 09:16:57 2015 +0200
Bug 749292 - SMTP connection lost while reading message data
camel/camel-network-service.c | 4 ++-
camel/providers/smtp/camel-smtp-transport.c | 31 +++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/camel/camel-network-service.c b/camel/camel-network-service.c
index 5d9741e..9df4265 100644
--- a/camel/camel-network-service.c
+++ b/camel/camel-network-service.c
@@ -562,8 +562,10 @@ network_service_connect_sync (CamelNetworkService *service,
GSocket *socket;
socket = g_socket_connection_get_socket (connection);
- if (socket)
+ if (socket) {
g_socket_set_timeout (socket, 90);
+ g_socket_set_keepalive (socket, TRUE);
+ }
}
return (connection != NULL) ? G_IO_STREAM (connection) : NULL;
diff --git a/camel/providers/smtp/camel-smtp-transport.c b/camel/providers/smtp/camel-smtp-transport.c
index 45f9ecc..4308422 100644
--- a/camel/providers/smtp/camel-smtp-transport.c
+++ b/camel/providers/smtp/camel-smtp-transport.c
@@ -1457,6 +1457,34 @@ smtp_rcpt (CamelSmtpTransport *transport,
return TRUE;
}
+static void
+smtp_maybe_update_socket_timeout (CamelStream *strm,
+ gint timeout_seconds)
+{
+ GIOStream *base_strm = camel_stream_ref_base_stream (strm);
+
+ if (G_IS_TLS_CONNECTION (base_strm)) {
+ GIOStream *base_io_stream = NULL;
+
+ g_object_get (G_OBJECT (base_strm), "base-io-stream", &base_io_stream, NULL);
+
+ g_object_unref (base_strm);
+ base_strm = base_io_stream;
+ }
+
+ if (G_IS_SOCKET_CONNECTION (base_strm)) {
+ GSocket *socket;
+
+ socket = g_socket_connection_get_socket (G_SOCKET_CONNECTION (base_strm));
+ if (socket) {
+ if (timeout_seconds > g_socket_get_timeout (socket))
+ g_socket_set_timeout (socket, timeout_seconds);
+ }
+ }
+
+ g_clear_object (&base_strm);
+}
+
static gboolean
smtp_data (CamelSmtpTransport *transport,
CamelMimeMessage *message,
@@ -1545,6 +1573,9 @@ smtp_data (CamelSmtpTransport *transport,
CAMEL_DATA_WRAPPER (message),
CAMEL_STREAM (null), NULL, NULL);
+ /* Set the upload timeout to an equal of 512 bytes per second */
+ smtp_maybe_update_socket_timeout (transport->ostream, null->written / 512);
+
filtered_stream = camel_stream_filter_new (transport->ostream);
/* setup progress reporting for message sending... */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]