aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authordhubbard <dhubbard@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-03 23:57:44 +0000
committerdhubbard <dhubbard@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-03 23:57:44 +0000
commitcd98e1b9ae957bc6a1258fc5764ac5f3b9219828 (patch)
tree8bf54da140f1fbdae4728be74c14c7f67dc26906 /main
parent89d6dfb83d1f008c9372fcfc831e2ddd8a3e8175 (diff)
add a Zaptel timer check to verify the timer is responding when Zaptel support is compiled into Asterisk and Zaptel drivers are loaded. This will help people not waste their valuable time debugging side effects.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@112689 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/asterisk.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index b4eeedb5c..512314ef0 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -124,6 +124,7 @@ int daemon(int, int); /* defined in libresolv of all places */
#include "asterisk/linkedlists.h"
#include "asterisk/devicestate.h"
#include "asterisk/module.h"
+#include "asterisk/zapata.h"
#include "asterisk/doxyref.h" /* Doxygen documentation */
@@ -2892,7 +2893,34 @@ int main(int argc, char *argv[])
printf(term_quit());
exit(1);
}
-
+#ifdef HAVE_ZAPTEL
+ {
+ int fd;
+ int x = 160;
+ fd = open("/dev/zap/timer", O_RDWR);
+ if (fd >= 0) {
+ if (ioctl(fd, ZT_TIMERCONFIG, &x)) {
+ ast_log(LOG_ERROR, "You have Zaptel built and drivers loaded, but the Zaptel timer test failed to set ZT_TIMERCONFIG to %d.\n", x);
+ exit(1);
+ }
+ if ((x = ast_wait_for_input(fd, 300)) < 0) {
+ ast_log(LOG_ERROR, "You have Zaptel built and drivers loaded, but the Zaptel timer could not be polled during the Zaptel timer test.\n");
+ exit(1);
+ }
+ if (!x) {
+ const char zaptel_timer_error[] = {
+ "Asterisk has detected a problem with your Zaptel configuration and will shutdown for your protection. You have options:"
+ "\n\t1. You only have to compile Zaptel support into Asterisk if you need it. One option is to recompile without Zaptel support."
+ "\n\t2. You only have to load Zaptel drivers if you want to take advantage of Zaptel services. One option is to unload zaptel modules if you don't need them."
+ "\n\t3. If you need Zaptel services, you must correctly configure Zaptel."
+ };
+ ast_log(LOG_ERROR, "%s\n", zaptel_timer_error);
+ exit(1);
+ }
+ close(fd);
+ }
+ }
+#endif
threadstorage_init();
astobj2_init();