Hi,
these two patches fix the bug that only let the first tcp connection
succeed and lead to ECONNREFUSED for further attempts to connect:
Patch 1 -- "Simgear/simgear/io/sg_socket.cxx":
- store server handle in msgsock on accept(); sock = connection handle
- don't close the server socket on lost connection
- restore server socket on close(), so that another close() call
can close the server (-> fgIOShutdownAll())
- mark connection closed by setting msgsock = INVALID_SOCKET
Patch 2 -- "Flightgear/src/Network/props.cxx":
- return after "quit" (don't write to the closed connection!)
- don't let close() disable the channel
The changes were only done in tcp/SOCK_STREAM context and tested
with telnet sessions. The integrity of udp/SOCK_DGRAM was tested with
Atlas sessions.
m.
===================================================================
Patch 1:
diff -u -3 -p -r1.11 sg_socket.cxx
--- sg_socket.cxx 23 Oct 2001 20:22:12 -0000 1.11
+++ sg_socket.cxx 28 Jan 2002 08:24:24 -0000
@@ -339,9 +339,8 @@ int SGSocket::readline( char *buf, int l
// cout << "sock_stream\n";
if ( msgsock == INVALID_SOCKET ) {
// cout << "msgsock == invalid\n";
- msgsock = accept(sock, 0, 0);
- closesocket(sock);
- sock = msgsock;
+ msgsock = sock;
+ sock = accept(msgsock, 0, 0);
} else {
// cout << "ready to read\n";
char *buf_ptr = save_buf + save_len;
@@ -361,8 +360,7 @@ int SGSocket::readline( char *buf, int l
if ( result == 0 && save_len == 0 && first_read == true ) {
SG_LOG( SG_IO, SG_ALERT,
"Connection closed by foreign host." );
- closesocket(sock);
- open( get_dir() );
+ close();
}
}
} else {
@@ -494,6 +492,10 @@ bool SGSocket::close() {
}
closesocket( sock );
+ if ( sock_style == SOCK_STREAM && msgsock != INVALID_SOCKET ) {
+ sock = msgsock;
+ msgsock = INVALID_SOCKET;
+ }
return true;
}
===================================================================
Patch 2:
diff -u -3 -p -r1.13 props.cxx
--- props.cxx 27 Jul 2001 20:00:48 -0000 1.13
+++ props.cxx 28 Jan 2002 08:22:57 -0000
@@ -206,6 +206,7 @@ bool FGProps::process_command( const cha
}
} else if ( command == "quit" ) {
close();
+ return true;
} else {
io->writestring( "\n" );
io->writestring( "Valid commands are:\n" );
@@ -257,8 +258,6 @@ bool FGProps::process() {
// close the channel
bool FGProps::close() {
SGIOChannel *io = get_io_channel();
-
- set_enabled( false );
if ( ! io->close() ) {
return false;
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel