]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
PollLockPokeModem: check on modem when lock file is polled
authorAidan Van Dyk <aidan@ifax.com>
Mon, 28 Apr 2008 20:36:28 +0000 (20:36 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Mon, 28 Apr 2008 20:36:28 +0000 (20:36 +0000)
From Lee:
| commit 78114b9300badd714f44f8b25a919b09605f3ac6
| Author: Lee Howard <faxguy@howardsilvan.com>
| Date:   Thu Dec 6 18:19:28 2007 +0000
|
|     Adds PollLockPokeModem
|
|     When polling for the presence/removal of a UUCP lockfile, also test to make
|     sure the modem is still reachable.  This is useful for scenarios where the
|     modem is apt to become disconnected while the modem is idle, such as an
|     external modem that may lose power, where the administrator wants notification
|     of this (as a ‘‘wedged’’ condition).

faxd/ClassModem.c++
faxd/ClassModem.h
faxd/ModemServer.c++
faxd/ServerConfig.c++
faxd/ServerConfig.h
man/hylafax-config.4f

index 9a3f6dcfd8ea661da548970f1126ce7a73423233..ef47160ed96175c9f1b0bda8768791655a9a9feb 100644 (file)
@@ -1394,6 +1394,12 @@ ClassModem::hangup()
     atCmd(conf.onHookCmd, AT_OK, 5000);
 }
 
+bool
+ClassModem::poke()
+{
+    return atCmd("AT", AT_OK, 5000);
+}
+
 bool
 ClassModem::waitForRings(u_short rings, CallType& type, CallID& callid)
 {
index f06590bc9163a822ae91478a8023ae32b9aa15a6..39db3753e46f656079b76fb1a4518db4fa334442 100644 (file)
@@ -278,6 +278,7 @@ public:
     void       resetBlock();
     void       startTimeout(long ms);
     void       stopTimeout(const char* whichdir);
+    bool       poke();
 // host-modem protocol parsing support
     virtual ATResponse atResponse(char* buf, long ms = 30*1000);
     bool       waitFor(ATResponse wanted, long ms = 30*1000);
index e27213e8e106b8e5503ec4f608c6c7b5ff18dee0..f7f653227c5dd95285557691c5da105bcec90be4 100644 (file)
@@ -746,7 +746,20 @@ ModemServer::timerExpired(long, long)
         * If a lockfile exists, go to LOCKWAIT
         */
        if (canLockModem()) {
-           Dispatcher::instance().startTimer(pollLockWait, 0, this);
+           bool ok = true;
+           if (pollLockPokeModem) {
+               /*
+                * Poke the modem to make sure it's still there.
+                * If not, then mark it to be reset.
+                */
+               lockModem();
+               ok = modem->poke();
+               unlockModem();
+           }
+           if (ok)
+               Dispatcher::instance().startTimer(pollLockWait, 0, this);
+           else
+               changeState(MODEMWAIT, pollModemWait);
        } else {
            changeState(LOCKWAIT, pollLockWait);
        }
index f4f7b8a39aef0dc445e3c0836fb4892b02b1af25..410147252863d0c21415a65a30fd5d0883a7a71b 100644 (file)
@@ -79,6 +79,7 @@ ServerConfig::configTrace(const char* fmt, ...)
 
 ServerConfig::S_booltag ServerConfig::bools[] = {
 { "batchlogs",         &ServerConfig::batchLogs,       true },
+{ "polllockpokemodem", &ServerConfig::pollLockPokeModem, false },
 };
 
 ServerConfig::S_stringtag ServerConfig::strings[] = {
index 888cb3991ab2e814708ab36106f6205df683c36a..1c8f62f0f4edfdebc758a2653aad01cec92f8170 100644 (file)
@@ -119,6 +119,7 @@ public:
     u_int      retryOther;             // number of retries after other problem
     u_int      pollModemWait;          // polling interval in modem wait state
     u_int      pollLockWait;           // polling interval in lock wait state
+    bool       pollLockPokeModem;      // poke modem after polling lock
     u_int      maxRecvPages;           // max pages to accept on receive
     u_int      maxConsecutiveBadCalls; // max consecutive bad phone calls
     fxStr      localIdentifier;        // to use in place of FAXNumber
index 52d54cc8bade8d9cd225994ba742b614ac444a3d..00575f5445b597f718c248825aa09635ba719f31 100644 (file)
@@ -187,6 +187,7 @@ PageChop\(S1        string  \s-1last\s+1    control automatic truncation of trailing whites
 PageChopThreshold\(S1  float   \s-13.0\s+1     whitespace truncation threshold (inches)
 PCL2FaxCmd\(S1 string  \s-1bin/pcl2fax\s+1     PCL \s-1RIP\s+1 command script
 PercentGoodLines       integer \s-195\s+1      percentage of good rows for \s-1OK\s+1 page quality
+PollLockPokeModem      boolean \s-1false\s+1   check on modem every time the lock is polled
 PollLockWait\(S2       integer \s-130\s+1      polling interval for lockfile presence/removal (secs)
 PollModemWait  integer \s-130\s+1      polling interval when in ``modem wait'' state (secs)
 PollRcvdCmd    string  \s-1bin/pollrcvd\s+1    delivery script for facsimile received by polling
@@ -1289,6 +1290,15 @@ checking performed.
 See also
 .BR MaxConsecutiveBadLines .
 .TP
+.B PollLockPokeModem
+When polling for the presence/removal of a
+.SM UUCP
+lockfile, also test to make sure the modem is still reachable.
+This is useful for scenarios where the modem is apt to become
+disconnected while the modem is idle, such as an external modem
+that may lose power, where the administrator wants notification
+of this (as a ``wedged'' condition).
+.TP
 .B PollLockWait
 When polling for the presence/removal of a 
 .SM UUCP