diff options
author | sobomax <sobomax@FreeBSD.org> | 2008-08-16 02:36:25 +0800 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2008-08-16 02:36:25 +0800 |
commit | 1b7b28572bf45fb905512c3fd7a3bb3fb0f9c8ac (patch) | |
tree | 147a88f6384ea10079bd2117f5ac761334890265 /misc/zaptel | |
parent | dc269e173a8d0647aaac7821aba3ebe0002f03e8 (diff) | |
download | freebsd-ports-gnome-1b7b28572bf45fb905512c3fd7a3bb3fb0f9c8ac.tar.gz freebsd-ports-gnome-1b7b28572bf45fb905512c3fd7a3bb3fb0f9c8ac.tar.zst freebsd-ports-gnome-1b7b28572bf45fb905512c3fd7a3bb3fb0f9c8ac.zip |
Fix drifting problem that happens particularly with asterisk's meetme
application. Bump PORTREVISION.
PR: ports/115059
Submitted by: Corey Smith <corsmith@gmail.com>
Diffstat (limited to 'misc/zaptel')
-rw-r--r-- | misc/zaptel/Makefile | 2 | ||||
-rw-r--r-- | misc/zaptel/files/patch-ztdummy::ztdummy.c | 112 |
2 files changed, 113 insertions, 1 deletions
diff --git a/misc/zaptel/Makefile b/misc/zaptel/Makefile index 6e427f551ab9..287fe2e53d05 100644 --- a/misc/zaptel/Makefile +++ b/misc/zaptel/Makefile @@ -7,7 +7,7 @@ PORTNAME= zaptel PORTVERSION= 1.4.6 -PORTREVISION= 5 +PORTREVISION= 6 CATEGORIES= misc kld MASTER_SITES= http://www.pbxpress.com/~gonzo/ DISTNAME= ${PORTNAME}-bsd-${PORTVERSION} diff --git a/misc/zaptel/files/patch-ztdummy::ztdummy.c b/misc/zaptel/files/patch-ztdummy::ztdummy.c new file mode 100644 index 000000000000..908b8cdb4650 --- /dev/null +++ b/misc/zaptel/files/patch-ztdummy::ztdummy.c @@ -0,0 +1,112 @@ +--- ztdummy/ztdummy.c.orig Mon Jul 30 15:11:25 2007 ++++ ztdummy/ztdummy.c Mon Jul 30 15:11:32 2007 +@@ -22,6 +22,10 @@ + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * ++ * Rewritten to use the time of day clock (which should be ntp synced ++ * for this to work perfectly) by David G. Lawrence <dg@dglawrence.com>. ++ * July 27th, 2007. ++ * + */ + + #include <sys/cdefs.h> +@@ -45,26 +49,82 @@ + + MALLOC_DEFINE(M_ZTD, "ztdummy", "ztdummy interface data structures"); + ++#ifndef timersub ++#define timersub(tvp, uvp, vvp) \ ++ do { \ ++ (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ ++ (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ ++ if ((vvp)->tv_usec < 0) { \ ++ (vvp)->tv_sec--; \ ++ (vvp)->tv_usec += 1000000; \ ++ } \ ++ } while (0) ++#endif + + static struct callout_handle ztdummy_timer_handle = CALLOUT_HANDLE_INITIALIZER(&ztdummy_timer_handle); + + static struct ztdummy *ztd; + + static int debug = 0; ++static struct timeval basetime, curtime, sleeptime; + + static __inline void ztdummy_timer(void* arg ) + { +- int i,j; ++ int i, ticks; + +- j = max(1, 1000/hz); +- +- for(i=0; i < j; i++) { ++loop: ++ for (i = 0; i < hz / 100; i++) { + zt_receive(&ztd->span); + zt_transmit(&ztd->span); + } +- +- ztdummy_timer_handle = timeout(ztdummy_timer, NULL, hz/1000); + ++fixtime: ++ microtime(&curtime); ++ ++ /* ++ * Sleep until the next 10ms boundry. ++ */ ++ basetime.tv_usec += 10000; ++ if (basetime.tv_usec >= 1000000) { ++ basetime.tv_sec++; ++ basetime.tv_usec -= 1000000; ++ } ++ timersub(&basetime, &curtime, &sleeptime); ++ ++ /* ++ * Detect if we've gotten behind and need to start our processing ++ * immediately. ++ */ ++ if (sleeptime.tv_sec < 0 || sleeptime.tv_usec == 0) { ++ /* ++ * Limit how far we can get behind to something reasonable (1 sec) ++ * so that we don't go nuts when something (ntp or admin) sets the ++ * clock forward by a large amount. ++ */ ++ if (sleeptime.tv_sec < -1) { ++ basetime.tv_sec = curtime.tv_sec; ++ basetime.tv_usec = curtime.tv_usec; ++ goto fixtime; ++ } ++ goto loop; ++ } ++ /* ++ * Detect if something is messing with the system clock by ++ * checking that the sleep time is no more than 20ms and ++ * resetting our base time if it is. This case will occur if ++ * the system clock has been reset to an earlier time. ++ */ ++ if (sleeptime.tv_sec > 0 || sleeptime.tv_usec > 20000) { ++ basetime.tv_sec = curtime.tv_sec; ++ basetime.tv_usec = curtime.tv_usec; ++ goto fixtime; ++ } ++ ++ ticks = sleeptime.tv_usec * hz / 1000000; ++ if (ticks == 0) ++ goto loop; ++ ++ ztdummy_timer_handle = timeout(ztdummy_timer, NULL, ticks); + } + + static int ztdummy_initialize(struct ztdummy *ztd) +@@ -102,7 +162,8 @@ + return -ENODEV; + } + +- ztdummy_timer_handle = timeout(ztdummy_timer, NULL, hz/1000); ++ microtime(&basetime); ++ ztdummy_timer_handle = timeout(ztdummy_timer, NULL, 1); + + if (debug) + printf("ztdummy: init() finished\n"); |