From: Darren Nickerson Date: Mon, 21 May 2001 05:14:45 +0000 (+0000) Subject: [Bug 131] some error handling bugfixes... X-Git-Tag: HYLAFAX-4_1RC1~19 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=ecbbe1f32d7f70639488e84ac508aff13dab2b88;p=thirdparty%2FHylaFAX.git [Bug 131] some error handling bugfixes... Another -devel community effort. Awesome! --- diff --git a/faxd/Class1.c++ b/faxd/Class1.c++ index 8473d0b3..967fd80c 100644 --- a/faxd/Class1.c++ +++ b/faxd/Class1.c++ @@ -421,6 +421,18 @@ Class1Modem::recvRawFrame(HDLCFrame& frame) */ do { c = getModemChar(0); + if (c == DLE) { + c = getModemChar(0); + if (c == ETX) { + protoTrace("--> ...+DLE+ETX"); + break; + } + } + if (c == '\n') { + protoTrace("--> ...+LF"); + break; + } + } while (c != EOF && c != 0xff); if (c == 0xff) { // address field received do { @@ -433,11 +445,12 @@ Class1Modem::recvRawFrame(HDLCFrame& frame) } while ((c = getModemChar(0)) != EOF); } stopTimeout("receiving HDLC frame data"); + if (frame.getLength() > 0) + traceHDLCFrame("-->", frame); if (wasTimeout()) { abortReceive(); return (false); } - traceHDLCFrame("-->", frame); /* * Now collect the "OK", "ERROR", or "FCERROR" * response telling whether or not the FCS was @@ -694,8 +707,16 @@ Class1Modem::recvTCF(int br, HDLCFrame& buf, const u_char* bitrev, long ms) gotData = true; break; } + if (c == EOF) { + break; + } } buf.put(bitrev[c]); + if (buf.getLength() > 10000) { + setTimeout(true); + break; + } + } while ((c = getModemChar(0)) != EOF); } } diff --git a/faxd/Class1Recv.c++ b/faxd/Class1Recv.c++ index 7579da15..e0c86090 100644 --- a/faxd/Class1Recv.c++ +++ b/faxd/Class1Recv.c++ @@ -392,21 +392,32 @@ top: (void) setXONXOFF(FLOW_NONE, FLOW_NONE, ACT_DRAIN); setInputBuffering(false); if (!messageReceived && rmResponse != AT_FCERROR) { - /* - * One of many things may have happened: - * o if we lost carrier, then some modems will return - * AT_NOCARRIER or AT_EMPTYLINE in response to the - * AT+FRM request. - * o otherwise, there may have been a timeout receiving - * the message data, or there was a timeout waiting - * for the carrier to drop. Anything unexpected causes - * us abort the receive to avoid looping. - * The only case that we don't abort on is that we found - * the wrong carrier, which means that there is an HDLC - * frame waiting for us--in which case it should get - * picked up below. - */ - break; + if (rmResponse != AT_ERROR) { + /* + * One of many things may have happened: + * o if we lost carrier, then some modems will return + * AT_NOCARRIER or AT_EMPTYLINE in response to the + * AT+FRM request. + * o otherwise, there may have been a timeout receiving + * the message data, or there was a timeout waiting + * for the carrier to drop. Anything unexpected causes + * us abort the receive to avoid looping. + * The only case that we don't abort on is that we found + * the wrong carrier, which means that there is an HDLC + * frame waiting for us--in which case it should get + * picked up below. + */ + if (wasTimeout()) { + abortReceive(); // return to command state + } + break; + } else { + /* + * Some modems respond ERROR instead +FCERROR on wrong carrier + * and not return to command state. + */ + abortReceive(); // return to command state + } } } /*