[evolution-data-server/camel-socks-proxy] Make the SSL stream's stream_write() reusable internally
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/camel-socks-proxy] Make the SSL stream's stream_write() reusable internally
- Date: Thu, 27 May 2010 01:24:45 +0000 (UTC)
commit faa3201f0d454a619d0bf9eb7e401e12ca40373e
Author: Federico Mena Quintero <federico novell com>
Date: Wed May 26 19:51:00 2010 -0500
Make the SSL stream's stream_write() reusable internally
We need to write to a PRFileDesc* from the initial step that
connects to a SOCKS4 proxy, so we need that function to
be reusable for generic write() operations.
Signed-off-by: Federico Mena Quintero <federico novell com>
camel/camel-tcp-stream-ssl.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index ef5d6a8..3d3e1a8 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -410,9 +410,8 @@ stream_read (CamelStream *stream, gchar *buffer, gsize n)
}
static gssize
-stream_write (CamelStream *stream, const gchar *buffer, gsize n)
+write_to_prfd (PRFileDesc *fd, const gchar *buffer, gsize n)
{
- CamelTcpStreamSSL *tcp_stream_ssl = CAMEL_TCP_STREAM_SSL (stream);
gssize w, written = 0;
PRFileDesc *cancel_fd;
@@ -425,7 +424,7 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
if (cancel_fd == NULL) {
do {
do {
- w = PR_Write (tcp_stream_ssl->priv->sockfd, buffer + written, n - written);
+ w = PR_Write (fd, buffer + written, n - written);
if (w == -1)
set_errno (PR_GetError ());
} while (w == -1 && (PR_GetError () == PR_PENDING_INTERRUPT_ERROR ||
@@ -443,13 +442,13 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
/* get O_NONBLOCK options */
sockopts.option = PR_SockOpt_Nonblocking;
- PR_GetSocketOption (tcp_stream_ssl->priv->sockfd, &sockopts);
+ PR_GetSocketOption (fd, &sockopts);
sockopts.option = PR_SockOpt_Nonblocking;
nonblock = sockopts.value.non_blocking;
sockopts.value.non_blocking = TRUE;
- PR_SetSocketOption (tcp_stream_ssl->priv->sockfd, &sockopts);
+ PR_SetSocketOption (fd, &sockopts);
- pollfds[0].fd = tcp_stream_ssl->priv->sockfd;
+ pollfds[0].fd = fd;
pollfds[0].in_flags = PR_POLL_WRITE;
pollfds[1].fd = cancel_fd;
pollfds[1].in_flags = PR_POLL_READ;
@@ -476,7 +475,7 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
errno = EINTR;
} else {
do {
- w = PR_Write (tcp_stream_ssl->priv->sockfd, buffer + written, n - written);
+ w = PR_Write (fd, buffer + written, n - written);
if (w == -1)
set_errno (PR_GetError ());
} while (w == -1 && PR_GetError () == PR_PENDING_INTERRUPT_ERROR);
@@ -494,7 +493,7 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
error = errno;
sockopts.option = PR_SockOpt_Nonblocking;
sockopts.value.non_blocking = nonblock;
- PR_SetSocketOption (tcp_stream_ssl->priv->sockfd, &sockopts);
+ PR_SetSocketOption (fd, &sockopts);
errno = error;
}
@@ -504,6 +503,14 @@ stream_write (CamelStream *stream, const gchar *buffer, gsize n)
return written;
}
+static gssize
+stream_write (CamelStream *stream, const gchar *buffer, gsize n)
+{
+ CamelTcpStreamSSL *ssl = CAMEL_TCP_STREAM_SSL (stream);
+
+ return write_to_prfd (ssl->priv->sockfd, buffer, n);
+}
+
static gint
stream_flush (CamelStream *stream)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]