svn commit: samba r4218 - in trunk/source/lib: .
vlendec at samba.org
vlendec at samba.org
Wed Dec 15 12:09:04 GMT 2004
Author: vlendec
Date: 2004-12-15 12:09:04 +0000 (Wed, 15 Dec 2004)
New Revision: 4218
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4218
Log:
Merge of fixes to open_socket_out from 3_0.
Volker
Modified:
trunk/source/lib/util_sock.c
Changeset:
Modified: trunk/source/lib/util_sock.c
===================================================================
--- trunk/source/lib/util_sock.c 2004-12-15 12:05:48 UTC (rev 4217)
+++ trunk/source/lib/util_sock.c 2004-12-15 12:09:04 UTC (rev 4218)
@@ -903,6 +903,9 @@
for (i=0; i<num_addrs; i++) {
+ if (sockets[i] == -1)
+ continue;
+
if (connect(sockets[i], (struct sockaddr *)&(addrs[i]),
sizeof(*addrs)) == 0) {
/* Rather unlikely as we are non-blocking, but it
@@ -916,6 +919,10 @@
/* These are the error messages that something is
progressing. */
good_connect = True;
+ } else if (errno != 0) {
+ /* There was a direct error */
+ close(sockets[i]);
+ sockets[i] = -1;
}
}
@@ -931,6 +938,8 @@
FD_ZERO(&r_fds);
for (i=0; i<num_addrs; i++) {
+ if (sockets[i] == -1)
+ continue;
FD_SET(sockets[i], &wr_fds);
FD_SET(sockets[i], &r_fds);
if (sockets[i]>maxfd)
@@ -950,14 +959,23 @@
for (i=0; i<num_addrs; i++) {
- if (!FD_ISSET(sockets[i], &wr_fds))
+ if (sockets[i] == -1)
continue;
/* Stevens, Network Programming says that if there's a
* successful connect, the socket is only writable. Upon an
* error, it's both readable and writable. */
- if (!FD_ISSET(sockets[i], &r_fds)) {
+ if (FD_ISSET(sockets[i], &r_fds) &&
+ FD_ISSET(sockets[i], &wr_fds)) {
+ /* readable and writable, so it's an error */
+ close(sockets[i]);
+ sockets[i] = -1;
+ continue;
+ }
+
+ if (!FD_ISSET(sockets[i], &r_fds) &&
+ FD_ISSET(sockets[i], &wr_fds)) {
/* Only writable, so it's connected */
resulting_index = i;
goto done;
More information about the samba-cvs
mailing list