diff --git a/phoned/main.c b/phoned/main.c index 859b9c7..e4c9a5b 100644 --- a/phoned/main.c +++ b/phoned/main.c @@ -49,6 +49,7 @@ int main(argc, argv) usage(strdup(*argv)); return -2; } + cf.modem_tm = 0; cf.loglevels = LL_ALL; pthread_mutex_unlock(&cfmx); initialize(); diff --git a/phoned/modem.c b/phoned/modem.c index b18110a..fba0a99 100644 --- a/phoned/modem.c +++ b/phoned/modem.c @@ -53,9 +53,11 @@ int modemfd; unsigned int cou = 0; char buffer[512]; short doing_cid = 0; +extern struct conf cf; pthread_t modemth; pthread_mutex_t modemmx = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t buffermx = PTHREAD_MUTEX_INITIALIZER; +extern pthread_mutex_t cfmx; void stmod(const char* str) { pthread_mutex_lock(&modemmx); @@ -174,15 +176,19 @@ void *modem_io(k) fd_set fds; struct timeval tv; char cbuf[1]; + short dotm = 0; k = 0; *cbuf = '\0'; cbuf[1] = '\0'; pthread_mutex_lock(&modemmx); for(;;) { + pthread_mutex_lock(&cfmx); + dotm = cf.modem_tm; + pthread_mutex_unlock(&cfmx); FD_ZERO(&fds); FD_SET(modemfd, &fds); tv.tv_sec = 2; /* tunable */ tv.tv_usec = 0; - switch(select(modemfd + 1, &fds, NULL, NULL, &tv)) { + switch(select(modemfd + 1, &fds, NULL, NULL, dotm ? &tv : NULL)) { case -1: lprintf(error, "select on modem: %s", strerror(errno)); pthread_mutex_unlock(&modemmx);