From b69245f8e3b20efbecaac2d6a03e35e453cd6700 Mon Sep 17 00:00:00 2001 From: Russell Bryant <russell@russellbryant.com> Date: Thu, 25 Mar 2010 20:40:48 +0000 Subject: [PATCH] Fix chan_ooh323 so it works on Mac OS X, as well. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@254799 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- addons/Makefile | 1 - addons/ooh323c/src/ooh323.c | 6 ++++-- addons/ooh323c/src/ooq931.c | 13 +++++++++---- addons/ooh323c/src/ootrace.c | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/addons/Makefile b/addons/Makefile index 3faa9ccf52..af23c726ba 100644 --- a/addons/Makefile +++ b/addons/Makefile @@ -47,6 +47,5 @@ $(if $(filter format_mp3,$(EMBEDDED_MODS)),modules.link,format_mp3.so): mp3/comm chan_ooh323.o: _ASTCFLAGS+=$(H323CFLAGS) $(if $(filter chan_ooh323,$(EMBEDDED_MODS)),modules.link,chan_ooh323.so): _ASTCFLAGS+=$(H323CFLAGS) -$(if $(filter chan_ooh323,$(EMBEDDED_MODS)),modules.link,chan_ooh323.so): _ASTLDFLAGS+=-lrt $(if $(filter chan_ooh323,$(EMBEDDED_MODS)),modules.link,chan_ooh323.so): $(addprefix ooh323c/src/,$(H323OBJS)) chan_ooh323.o ooh323cDriver.o $(addprefix ooh323c/src/,$(H323OBJS)) chan_ooh323.o ooh323cDriver.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_ooh323) diff --git a/addons/ooh323c/src/ooh323.c b/addons/ooh323c/src/ooh323.c index 104e0bf0d0..21eab1fa32 100644 --- a/addons/ooh323c/src/ooh323.c +++ b/addons/ooh323c/src/ooh323.c @@ -1557,6 +1557,7 @@ int ooHandleH2250Message(OOH323CallData *call, Q931Message *q931Msg) DListNode *pNode = NULL; OOTimer *pTimer=NULL; int type = q931Msg->messageType; + struct timeval tv; struct timespec ts; /* checking of message validity for first/next messages of calls */ @@ -1600,8 +1601,9 @@ int ooHandleH2250Message(OOH323CallData *call, Q931Message *q931Msg) ast_mutex_lock(&call->Lock); ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, call, FALSE); - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec += 24; + tv = ast_tvnow(); + ts.tv_sec = tv.tv_sec + 24; + ts.tv_nsec = tv.tv_usec * 1000; ast_cond_timedwait(&call->gkWait, &call->Lock, &ts); if (call->callState == OO_CALL_WAITING_ADMISSION) call->callState = OO_CALL_CLEAR; diff --git a/addons/ooh323c/src/ooq931.c b/addons/ooh323c/src/ooq931.c index 3f25885db8..307aba5a68 100644 --- a/addons/ooh323c/src/ooq931.c +++ b/addons/ooh323c/src/ooq931.c @@ -16,6 +16,7 @@ #include <asterisk.h> #include <asterisk/lock.h> +#include "asterisk/utils.h" #include <time.h> #include "ooq931.h" @@ -2017,6 +2018,7 @@ int ooH323HandleCallFwdRequest(OOH323CallData *call) OOCTXT *pctxt; ooAliases *pNewAlias=NULL, *alias=NULL; struct timespec ts; + struct timeval tv; int i=0, irand=0, ret = OO_OK; /* Note: We keep same callToken, for new call which is going to replace an existing call, thus treating it as a single call.*/ @@ -2072,8 +2074,9 @@ int ooH323HandleCallFwdRequest(OOH323CallData *call) ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, fwdedCall, FALSE); fwdedCall->callState = OO_CALL_WAITING_ADMISSION; ast_mutex_lock(&fwdedCall->Lock); - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec += 24; + tv = ast_tvnow(); + ts.tv_sec += tv.tv_sec + 24; + ts.tv_nsec = tv.tv_usec * 1000; ast_cond_timedwait(&fwdedCall->gkWait, &fwdedCall->Lock, &ts); if (fwdedCall->callState == OO_CALL_WAITING_ADMISSION) /* GK is not responding */ fwdedCall->callState = OO_CALL_CLEAR; @@ -2114,6 +2117,7 @@ int ooH323MakeCall(char *dest, char *callToken, ooCallOptions *opts) int ret=0, i=0, irand=0; char tmp[30]="\0"; char *ip=NULL, *port = NULL; + struct timeval tv; struct timespec ts; if(!dest) @@ -2195,8 +2199,9 @@ int ooH323MakeCall(char *dest, char *callToken, ooCallOptions *opts) call->callState = OO_CALL_WAITING_ADMISSION; ast_mutex_lock(&call->Lock); ret = ooGkClientSendAdmissionRequest(gH323ep.gkClient, call, FALSE); - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec += 24; + tv = ast_tvnow(); + ts.tv_sec = tv.tv_sec + 24; + ts.tv_nsec = tv.tv_usec * 1000; ast_cond_timedwait(&call->gkWait, &call->Lock, &ts); if (call->callState == OO_CALL_WAITING_ADMISSION) call->callState = OO_CALL_CLEAR; diff --git a/addons/ooh323c/src/ootrace.c b/addons/ooh323c/src/ootrace.c index ac71a3078b..a688a390c2 100644 --- a/addons/ooh323c/src/ootrace.c +++ b/addons/ooh323c/src/ootrace.c @@ -111,7 +111,7 @@ void ooTraceLogMessage(const char * logMessage) struct timeval systemTime; gettimeofday(&systemTime, NULL); fprintf(gH323ep.fptraceFile, "%s:%03ld %s", timeString, - systemTime.tv_usec/1000, logMessage); + (long) systemTime.tv_usec/1000, logMessage); } else fprintf(gH323ep.fptraceFile, "%s", logMessage); -- GitLab