]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
(closes issue #9660)
authorRussell Bryant <russell@russellbryant.com>
Fri, 13 Jul 2007 19:10:00 +0000 (19:10 +0000)
committerRussell Bryant <russell@russellbryant.com>
Fri, 13 Jul 2007 19:10:00 +0000 (19:10 +0000)
Reported by: mmacvicar
Patches submitted by: bbryant, russell
Tested by: mmacvicar, marco, arcivanov, jmhunter, explidous

When using a TDM400P (and probably other analog cards) there was a chance that
you could hang up and pick the phone back up where it has been long enough to
be not considered a flash hook, but too soon such that the device reports that
it is busy and the person on the phone will only hear silence.  This patch
makes chan_zap more tolerant of this and gives the device a couple of seconds
to succeed so the person on the phone happily gets their dialtone.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@75052 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_zap.c

index e66e171db9b7c78dfab32e2ad0547104a31ae946..695684ce8baa826695e916f13eaa562a33d6b699 100644 (file)
@@ -1726,14 +1726,23 @@ static int restore_gains(struct zt_pvt *p)
 
 static inline int zt_set_hook(int fd, int hs)
 {
-       int x, res;
+       int x, res, count = 0;
+
        x = hs;
        res = ioctl(fd, ZT_HOOK, &x);
-       if (res < 0) 
-       {
+
+       while (res < 0 && count < 20) {
+               usleep(100000); /* 1/10 sec. */
+               x = hs;
+               res = ioctl(fd, ZT_HOOK, &x);
+               count++;
+       }
+
+       if (res < 0) {
                if (errno == EINPROGRESS) return 0;
                ast_log(LOG_WARNING, "zt hook failed: %s\n", strerror(errno));
        }
+
        return res;
 }