keywords: ip pbx voip gateway gsm gateway

×

Notice

The forum is in read only mode.
× Questions about Failover Box FA Series/FD Serise

res_failover.so usleep() problem

11 years 1 month ago #8646 by aser76
Hi,

I'm posting this message because we faced a strange problem using res_failover module on asterisk 1.4.42 on a Centos 6.3.

The problem is that for some reason (maybe thread related), the usleep() call most of the times returns -1 (error).
Since that call is used also in the kick loop this causes the module to send the "running" message without any delay, consuming system resources.

Now, I don't know why usleep() is not working correctly, but I found out that if you call usleep() a second time it works correctly, so i patched the loop like this:

/* kick loop */

while (1) {
write(dev->tty.fd, FAILOVER_DEV_RUNNING, 7);
sts = usleep(dev->kick_time_interval * 1000); //fix bug usleep
if(sts){
usleep(dev->kick_time_interval * 1000);
sprintf(message,"%s: %d, usleep=%d",FAILOVER_EVENT_RUNNING,dev->kick_time_interval,sts); //just for debugging purposes
failover_event_run(dev, message);
} else {
sprintf(message,"%s: %d, usleep=%d",FAILOVER_EVENT_RUNNING,dev->kick_time_interval,sts);
failover_event_run(dev, message);
}

Hope this helps someone who's facing the same issue.

Regards.
Time to create page: 0.033 seconds
Powered by Kunena Forum