aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog17
-rw-r--r--camel/camel-stream-fs.c6
-rw-r--r--camel/camel-tcp-stream-raw.c17
-rw-r--r--camel/camel-tcp-stream-ssl.c15
-rw-r--r--camel/camel-tcp-stream.c27
-rw-r--r--camel/camel-tcp-stream.h2
6 files changed, 34 insertions, 50 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index b0766558b1..85e4ddef27 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,22 @@
2001-01-15 Jeffrey Stedfast <fejj@ximian.com>
+ * camel-stream-fs.c (stream_close): If the close() is successful,
+ set the fd to -1.
+
+ * camel-tcp-stream-raw.c: Removed the disconnect() method.
+ (stream_close): If the close() is successful, set the sockfd to
+ -1.
+
+ * camel-tcp-stream-ssl.c: Removed the disconnect() method.
+ (stream_close): If the close() is successful, set the sockfd to
+ NULL.
+
+ * camel-tcp-stream.c (camel_tcp_stream_disconnect): Removed,
+ easier to just use the close() method as it did the same thing
+ anyway.
+
+2001-01-15 Jeffrey Stedfast <fejj@ximian.com>
+
* camel-tcp-stream-raw.c (stream_getsockopt): Updated to be able
to get the CAMEL_SOCKOPT_NONBLOCKING socket opt.
(stream_setsockopt): Updated to be able to set the
diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c
index 9f05b2fd8c..7047670832 100644
--- a/camel/camel-stream-fs.c
+++ b/camel/camel-stream-fs.c
@@ -313,7 +313,11 @@ stream_flush (CamelStream *stream)
static int
stream_close (CamelStream *stream)
{
- return close(((CamelStreamFs *)stream)->fd);
+ if (close (((CamelStreamFs *)stream)->fd) == -1)
+ return -1;
+
+ ((CamelStreamFs *)stream)->fd= -1;
+ return 0;
}
static off_t
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index 53722034de..5886a30663 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -41,7 +41,6 @@ static int stream_flush (CamelStream *stream);
static int stream_close (CamelStream *stream);
static int stream_connect (CamelTcpStream *stream, struct hostent *host, int port);
-static int stream_disconnect (CamelTcpStream *stream);
static int stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data);
static int stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);
@@ -62,7 +61,6 @@ camel_tcp_stream_raw_class_init (CamelTcpStreamRawClass *camel_tcp_stream_raw_cl
camel_stream_class->close = stream_close;
camel_tcp_stream_class->connect = stream_connect;
- camel_tcp_stream_class->disconnect = stream_disconnect;
camel_tcp_stream_class->getsockopt = stream_getsockopt;
camel_tcp_stream_class->setsockopt = stream_setsockopt;
}
@@ -160,8 +158,11 @@ stream_flush (CamelStream *stream)
static int
stream_close (CamelStream *stream)
{
- g_warning ("CamelTcpStreamRaw::close: Better to call ::disconnect.\n");
- return close (((CamelTcpStreamRaw *)stream)->sockfd);
+ if (close (((CamelTcpStreamRaw *)stream)->sockfd) == -1)
+ return -1;
+
+ ((CamelTcpStreamRaw *)stream)->sockfd = -1;
+ return 0;
}
@@ -193,12 +194,6 @@ stream_connect (CamelTcpStream *stream, struct hostent *host, int port)
return 0;
}
-static int
-stream_disconnect (CamelTcpStream *stream)
-{
- return close (((CamelTcpStreamRaw *)stream)->sockfd);
-}
-
static int
get_sockopt_level (const CamelSockOptData *data)
@@ -268,7 +263,7 @@ stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
static int
stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data)
{
- int optname, optlen;
+ int optname;
if ((optname = get_sockopt_optname (data)) == -1)
return -1;
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index b346a02c61..42255562bc 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -41,7 +41,6 @@ static int stream_flush (CamelStream *stream);
static int stream_close (CamelStream *stream);
static int stream_connect (CamelTcpStream *stream, struct hostent *host, int port);
-static int stream_disconnect (CamelTcpStream *stream);
static int stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data);
static int stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);
@@ -62,7 +61,6 @@ camel_tcp_stream_ssl_class_init (CamelTcpStreamSSLClass *camel_tcp_stream_ssl_cl
camel_stream_class->close = stream_close;
camel_tcp_stream_class->connect = stream_connect;
- camel_tcp_stream_class->disconnect = stream_disconnect;
camel_tcp_stream_class->getsockopt = stream_getsockopt;
camel_tcp_stream_class->setsockopt = stream_setsockopt;
}
@@ -160,8 +158,12 @@ stream_flush (CamelStream *stream)
static int
stream_close (CamelStream *stream)
{
- g_warning ("CamelTcpStreamSSL::close called on a stream where ::disconnect is preferred\n");
- return PR_Close (((CamelTcpStreamSSL *)stream)->sockfd);
+ if (PR_Close (((CamelTcpStreamSSL *)stream)->sockfd) == PR_Failure)
+ return -1;
+
+ ((CamelTcpStreamSSL *)stream)->sockfd = NULL;
+
+ return 0;
}
@@ -196,11 +198,6 @@ stream_connect (CamelTcpStream *stream, struct hostent *host, int port)
return 0;
}
-static int
-stream_disconnect (CamelTcpStream *stream)
-{
- return PR_Close (((CamelTcpStreamSSL *)stream)->sockfd);
-}
static int
stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
diff --git a/camel/camel-tcp-stream.c b/camel/camel-tcp-stream.c
index d335cc7393..6edd545a1f 100644
--- a/camel/camel-tcp-stream.c
+++ b/camel/camel-tcp-stream.c
@@ -31,7 +31,6 @@ static CamelStreamClass *parent_class = NULL;
#define CTS_CLASS(so) CAMEL_TCP_STREAM_CLASS (CAMEL_OBJECT_GET_CLASS(so))
static int tcp_connect (CamelTcpStream *stream, struct hostent *host, int port);
-static int tcp_disconnect (CamelTcpStream *stream);
static int tcp_getsockopt (CamelTcpStream *stream, CamelSockOptData *data);
static int tcp_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);
@@ -45,7 +44,6 @@ camel_tcp_stream_class_init (CamelTcpStreamClass *camel_tcp_stream_class)
/* tcp stream methods */
camel_tcp_stream_class->connect = tcp_connect;
- camel_tcp_stream_class->disconnect = tcp_disconnect;
camel_tcp_stream_class->getsockopt = tcp_getsockopt;
camel_tcp_stream_class->setsockopt = tcp_setsockopt;
}
@@ -103,31 +101,6 @@ camel_tcp_stream_connect (CamelTcpStream *stream, struct hostent *host, int port
static int
-tcp_disconnect (CamelTcpStream *stream)
-{
- g_warning ("CamelTcpStream::disconnect called on default implementation\n");
- return -1;
-}
-
-
-/**
- * camel_tcp_stream_disconnect:
- * @stream: tcp stream object
- *
- * Disconnect the tcp stream and properly close the socket.
- *
- * Return value: zero on success or -1 on fail.
- **/
-int
-camel_tcp_stream_disconnect (CamelTcpStream *stream)
-{
- g_return_val_if_fail (CAMEL_IS_TCP_STREAM (stream), -1);
-
- return CTS_CLASS (stream)->disconnect (stream);
-}
-
-
-static int
tcp_getsockopt (CamelTcpStream *stream, CamelSockOptData *data)
{
g_warning ("CamelTcpStream::getsockopt called on default implementation\n");
diff --git a/camel/camel-tcp-stream.h b/camel/camel-tcp-stream.h
index 63ad6e7ec4..56afa7a1fd 100644
--- a/camel/camel-tcp-stream.h
+++ b/camel/camel-tcp-stream.h
@@ -97,7 +97,6 @@ typedef struct {
/* Virtual methods */
int (*connect) (CamelTcpStream *stream, struct hostent *host, int port);
- int (*disconnect) (CamelTcpStream *stream);
int (*getsockopt) (CamelTcpStream *stream, CamelSockOptData *data);
int (*setsockopt) (CamelTcpStream *stream, const CamelSockOptData *data);
@@ -108,7 +107,6 @@ CamelType camel_tcp_stream_get_type (void);
/* public methods */
int camel_tcp_stream_connect (CamelTcpStream *stream, struct hostent *host, int port);
-int camel_tcp_stream_disconnect (CamelTcpStream *stream);
int camel_tcp_stream_getsockopt (CamelTcpStream *stream, CamelSockOptData *data);
int camel_tcp_stream_setsockopt (CamelTcpStream *stream, const CamelSockOptData *data);