[asterisk-commits] russell: branch group/timing r122362 - in /team/group/timing: main/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 12 14:56:44 CDT 2008
Author: russell
Date: Thu Jun 12 14:56:44 2008
New Revision: 122362
URL: http://svn.digium.com/view/asterisk?view=rev&rev=122362
Log:
Move the dahdi timer sanity check into res_timing_dahdi
Modified:
team/group/timing/main/asterisk.c
team/group/timing/res/res_timing_dahdi.c
Modified: team/group/timing/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/group/timing/main/asterisk.c?view=diff&rev=122362&r1=122361&r2=122362
==============================================================================
--- team/group/timing/main/asterisk.c (original)
+++ team/group/timing/main/asterisk.c Thu Jun 12 14:56:44 2008
@@ -3299,35 +3299,7 @@
printf("%s", term_quit());
exit(1);
}
-#ifdef HAVE_DAHDI
- {
- int fd;
- int x = 160;
- fd = open("/dev/dahdi/timer", O_RDWR);
- if (fd >= 0) {
- if (ioctl(fd, DAHDI_TIMERCONFIG, &x)) {
- ast_log(LOG_ERROR, "You have DAHDI built and drivers loaded, but the DAHDI timer test failed to set DAHDI_TIMERCONFIG to %d.\n", x);
- exit(1);
- }
- if ((x = ast_wait_for_input(fd, 300)) < 0) {
- ast_log(LOG_ERROR, "You have DAHDI built and drivers loaded, but the DAHDI timer could not be polled during the DAHDI timer test.\n");
- exit(1);
- }
- if (!x) {
- const char dahdi_timer_error[] = {
- "Asterisk has detected a problem with your DAHDI configuration and will shutdown for your protection. You have options:"
- "\n\t1. You only have to compile DAHDI support into Asterisk if you need it. One option is to recompile without DAHDI support."
- "\n\t2. You only have to load DAHDI drivers if you want to take advantage of DAHDI services. One option is to unload DAHDI modules if you don't need them."
- "\n\t3. If you need DAHDI services, you must correctly configure DAHDI."
- };
- ast_log(LOG_ERROR, "%s\n", dahdi_timer_error);
- usleep(100);
- exit(1);
- }
- close(fd);
- }
- }
-#endif
+
threadstorage_init();
astobj2_init();
Modified: team/group/timing/res/res_timing_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/group/timing/res/res_timing_dahdi.c?view=diff&rev=122362&r1=122361&r2=122362
==============================================================================
--- team/group/timing/res/res_timing_dahdi.c (original)
+++ team/group/timing/res/res_timing_dahdi.c Thu Jun 12 14:56:44 2008
@@ -31,8 +31,14 @@
ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
#include "asterisk/module.h"
#include "asterisk/timing.h"
+#include "asterisk/dahdi.h"
+#include "asterisk/utils.h"
static void *timing_funcs_handle;
@@ -80,8 +86,53 @@
return 0;
}
+static int dahdi_test_timer(void)
+{
+ int fd;
+ int x = 160;
+
+ fd = open("/dev/dahdi/timer", O_RDWR);
+
+ if (fd < 0) {
+ return -1;
+ }
+
+ if (ioctl(fd, DAHDI_TIMERCONFIG, &x)) {
+ ast_log(LOG_ERROR, "You have DAHDI built and drivers loaded, but the DAHDI timer test failed to set DAHDI_TIMERCONFIG to %d.\n", x);
+ close(fd);
+ return -1;
+ }
+
+ if ((x = ast_wait_for_input(fd, 300)) < 0) {
+ ast_log(LOG_ERROR, "You have DAHDI built and drivers loaded, but the DAHDI timer could not be polled during the DAHDI timer test.\n");
+ close(fd);
+ return -1;
+ }
+
+ if (!x) {
+ const char dahdi_timer_error[] = {
+ "Asterisk has detected a problem with your DAHDI configuration and will shutdown for your protection. You have options:"
+ "\n\t1. You only have to compile DAHDI support into Asterisk if you need it. One option is to recompile without DAHDI support."
+ "\n\t2. You only have to load DAHDI drivers if you want to take advantage of DAHDI services. One option is to unload DAHDI modules if you don't need them."
+ "\n\t3. If you need DAHDI services, you must correctly configure DAHDI."
+ };
+ ast_log(LOG_ERROR, "%s\n", dahdi_timer_error);
+ usleep(100);
+ close(fd);
+ return -1;
+ }
+
+ close(fd);
+
+ return 0;
+}
+
static int load_module(void)
{
+ if (dahdi_test_timer()) {
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
return (timing_funcs_handle = ast_install_timing_functions(&dahdi_timing_functions)) ?
AST_MODULE_LOAD_SUCCESS : AST_MODULE_LOAD_DECLINE;
}
More information about the asterisk-commits
mailing list