aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2004-01-03 07:46:40 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-01-03 07:46:40 +0800
commitb554670684a2a45f46b681e9dfbb27f3e0f199c7 (patch)
treeea22b436da2c46ab9b21de158dad48060f24923e /camel
parent8baeb6bb0ab1eb49493ad95238f6c02a11254144 (diff)
downloadgsoc2013-evolution-b554670684a2a45f46b681e9dfbb27f3e0f199c7.tar.gz
gsoc2013-evolution-b554670684a2a45f46b681e9dfbb27f3e0f199c7.tar.zst
gsoc2013-evolution-b554670684a2a45f46b681e9dfbb27f3e0f199c7.zip
Save errno and check the return of the socket() call.
2003-12-27 Jeffrey Stedfast <fejj@ximian.com> * camel-tcp-stream-raw.c (socket_connect): Save errno and check the return of the socket() call. svn path=/trunk/; revision=24028
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog9
-rw-r--r--camel/camel-tcp-stream-raw.c16
2 files changed, 18 insertions, 7 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index c351ea614e..8df67af2bc 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,8 @@
+2003-12-27 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-tcp-stream-raw.c (socket_connect): Save errno and check
+ the return of the socket() call.
+
2003-12-24 Rodrigo Moya <rodrigo@ximian.com>
* providers/groupwise/camel-groupwise-provider.c
@@ -9,8 +14,8 @@
* providers/groupwise/camel-groupwise-provider.c: removed useless
configuration options, and added other options from the IMAP
provider.
- (camel_provider_module_init): register a SMTP transport object also, and
- removed SASL registration, since we don't support it.
+ (camel_provider_module_init): register a SMTP transport object
+ also, and removed SASL registration, since we don't support it.
2003-12-19 Sivaiah Nallagatla <snallagatla@novell.com>
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index 819647cff6..d2cee82c0a 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -277,6 +277,7 @@ socket_connect (struct hostent *h, int port)
struct timeval tv;
socklen_t len;
int cancel_fd;
+ int errnosav;
int ret, fd;
/* see if we're cancelled yet */
@@ -304,13 +305,15 @@ socket_connect (struct hostent *h, int port)
}
#endif
- fd = socket (h->h_addrtype, SOCK_STREAM, 0);
+ if ((fd = socket (h->h_addrtype, SOCK_STREAM, 0) == -1))
+ return -1;
cancel_fd = camel_operation_cancel_fd (NULL);
if (cancel_fd == -1) {
- ret = connect (fd, saddr, len);
- if (ret == -1) {
+ if (connect (fd, saddr, len) == -1) {
+ errnosav = errno;
close (fd);
+ errno = errnosav;
return -1;
}
@@ -322,14 +325,15 @@ socket_connect (struct hostent *h, int port)
flags = fcntl (fd, F_GETFL);
fcntl (fd, F_SETFL, flags | O_NONBLOCK);
- ret = connect (fd, saddr, len);
- if (ret == 0) {
+ if (connect (fd, saddr, len) == 0) {
fcntl (fd, F_SETFL, flags);
return fd;
}
if (errno != EINPROGRESS) {
+ errnosav = errno;
close (fd);
+ errno = errnosav;
return -1;
}
@@ -359,7 +363,9 @@ socket_connect (struct hostent *h, int port)
len = sizeof (int);
if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &len) == -1) {
+ errnosav = errno;
close (fd);
+ errno = errnosav;
return -1;
}