aboutsummaryrefslogtreecommitdiffstats
path: root/ncpd
diff options
context:
space:
mode:
authorFritz Elfert <felfert@to.com>2001-04-08 19:04:24 +0000
committerFritz Elfert <felfert@to.com>2001-04-08 19:04:24 +0000
commitf7d131f1eb3c950e1c0315854f10da89d57353de (patch)
tree4fae865b24944e7b82ee5459bf142b61acb54c7e /ncpd
parent04b269100ef9a0ea09ab6557095b18ccdf168074 (diff)
downloadplptools-f7d131f1eb3c950e1c0315854f10da89d57353de.tar.gz
plptools-f7d131f1eb3c950e1c0315854f10da89d57353de.tar.bz2
plptools-f7d131f1eb3c950e1c0315854f10da89d57353de.zip
Handle client connections which are closed immediately after connect coorectly.
Diffstat (limited to 'ncpd')
-rw-r--r--ncpd/socketchan.cc83
1 files changed, 46 insertions, 37 deletions
diff --git a/ncpd/socketchan.cc b/ncpd/socketchan.cc
index 36dd8b5..dea883a 100644
--- a/ncpd/socketchan.cc
+++ b/ncpd/socketchan.cc
@@ -156,48 +156,57 @@ ncpConnectNak()
void socketChan::
socketPoll()
{
+ int res;
+
if (connectName == 0) {
bufferStore a;
- if (skt->getBufferStore(a, false) == 1) {
- // A client has connected, and is announcing who it
- // is... e.g. "SYS$RFSV.*"
- //
- // An NCP Channel can be in 'Control' or 'Data' mode.
- // Initially, it is in 'Control' mode, and can accept
- // certain commands.
- //
- // When a command is received that ncpd does not
- // understand, this is assumed to be a request to
- // connect to the remote service of that name, and enter
- // 'data' mode.
- //
- // Later, there might be an explicit command to enter
- // 'data' mode, and also a challenge-response protocol
- // before any connection can be made.
- //
- // All commands begin with "NCP$".
-
- // There is a magic process name called "NCP$INFO.*"
- // which is announced by the rfsvfactory. This causes a
- // response to be issued containing the NCP version
- // number. The rfsvfactory will create the correct type
- // of RFSV protocol handler, which will then announce
- // itself. So, first time in here, we might get the
- // NCP$INFO.*
- if (a.getLen() > 8 && !strncmp(a.getString(), "NCP$", 4)) {
- if (!ncpCommand(a))
- cerr << "ncpd: command " << a << " unrecognized." << endl;
- return;
- }
-
- // This isn't a command, it's a remote process. Connect.
- connectName = strdup(a.getString());
- connectTry++;
- ncpConnect();
+ res = skt->getBufferStore(a, false);
+ switch (res) {
+ case 1:
+ // A client has connected, and is announcing who it
+ // is... e.g. "SYS$RFSV.*"
+ //
+ // An NCP Channel can be in 'Control' or 'Data' mode.
+ // Initially, it is in 'Control' mode, and can accept
+ // certain commands.
+ //
+ // When a command is received that ncpd does not
+ // understand, this is assumed to be a request to
+ // connect to the remote service of that name, and enter
+ // 'data' mode.
+ //
+ // Later, there might be an explicit command to enter
+ // 'data' mode, and also a challenge-response protocol
+ // before any connection can be made.
+ //
+ // All commands begin with "NCP$".
+
+ // There is a magic process name called "NCP$INFO.*"
+ // which is announced by the rfsvfactory. This causes a
+ // response to be issued containing the NCP version
+ // number. The rfsvfactory will create the correct type
+ // of RFSV protocol handler, which will then announce
+ // itself. So, first time in here, we might get the
+ // NCP$INFO.*
+ if (a.getLen() > 8 && !strncmp(a.getString(), "NCP$", 4)) {
+ if (!ncpCommand(a))
+ cerr << "ncpd: command " << a << " unrecognized."
+ << endl;
+ return;
+ }
+
+ // This isn't a command, it's a remote process. Connect.
+ connectName = strdup(a.getString());
+ connectTry++;
+ ncpConnect();
+ break;
+ case -1:
+ ncpConnectTerminate();
+ break;
}
} else if (connected) {
bufferStore a;
- int res = skt->getBufferStore(a, false);
+ res = skt->getBufferStore(a, false);
if (res == -1) {
ncpDisconnect();
skt->closeSocket();