mirror of
https://github.com/sheumann/AFPBridge.git
synced 2026-04-20 09:17:19 +00:00
Flag an error if we are expecting to receive data and don't get any for 30 seconds.
This prevents the system from hanging indefinitely if the network suddenly disconnects in the middle of an AFP operation.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma noroot
|
||||
|
||||
#include <AppleTalk.h>
|
||||
#include <misctool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "session.h"
|
||||
@@ -48,6 +49,8 @@ LongWord DispatchASPCommand(SPCommandRec *commandRec) {
|
||||
Session *sess;
|
||||
unsigned int i;
|
||||
Word stateReg;
|
||||
LongWord lastActivityTime;
|
||||
LongWord lastReadCount;
|
||||
|
||||
stateReg = ForceRomIn();
|
||||
|
||||
@@ -164,8 +167,22 @@ LongWord DispatchASPCommand(SPCommandRec *commandRec) {
|
||||
memset(&sess->reply, 0, sizeof(sess->reply));
|
||||
FinishASPCommand(sess);
|
||||
} else {
|
||||
lastActivityTime = GetTick();
|
||||
lastReadCount = sess->readCount;
|
||||
i = 0;
|
||||
while (sess->commandPending) {
|
||||
PollForData(sess);
|
||||
if (sess->readCount != lastReadCount) {
|
||||
lastReadCount = sess->readCount;
|
||||
lastActivityTime = GetTick();
|
||||
i = 0;
|
||||
} else if (GetTick() - lastActivityTime > 30*60) {
|
||||
if (i < 5) {
|
||||
i++;
|
||||
} else {
|
||||
FlagFatalError(sess, aspNoRespErr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user