]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
[Bug 131] some error handling bugfixes...
authorDarren Nickerson <darren.nickerson@ifax.com>
Mon, 21 May 2001 05:14:45 +0000 (05:14 +0000)
committerDarren Nickerson <darren.nickerson@ifax.com>
Mon, 21 May 2001 05:14:45 +0000 (05:14 +0000)
Another -devel community effort. Awesome!

faxd/Class1.c++
faxd/Class1Recv.c++

index 8473d0b31e6902ae165036152096b1a0d54c8385..967fd80c63fd304e54587f89c082831abaa446a0 100644 (file)
@@ -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);
        }
     }
index 7579da159ddcc295079e394a04ce974159f34255..e0c8609034e6875b5163335543bede71f953d1dc 100644 (file)
@@ -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
+               }
            }
        }
        /*