diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2010-05-13 05:37:31 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2010-05-13 05:37:31 +0000 |
commit | 8d6ee962c7644fdfc47f56b8df7ed570435c8a27 (patch) | |
tree | 9d4eb039249b19afa0243f1406142d0958f96481 /tests/test_time.c | |
parent | 7d53dc86d6c120b1846ff06cec2b7c4dcc2a723b (diff) |
Add kqueue(2) implementation to Asterisk in various places.
This will save a considerable amount of CPU on the BSDs, including Mac OS X,
as it eliminates several places in the code that we previously used a busy
loop. Additionally, this adds a res_timing interface, using kqueue timers.
Review: https://reviewboard.asterisk.org/r/543/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@262852 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests/test_time.c')
-rw-r--r-- | tests/test_time.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/tests/test_time.c b/tests/test_time.c index 21e4f3836..61a201498 100644 --- a/tests/test_time.c +++ b/tests/test_time.c @@ -1,7 +1,7 @@ /* * Asterisk -- An open source telephony toolkit. * - * Copyright (C) 2009, Digium, Inc. + * Copyright (C) 2010, Digium, Inc. * * Tilghman Lesher <tlesher AT digium DOT com> * @@ -48,10 +48,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") AST_TEST_DEFINE(test_timezone_watch) { - const char *zones[2] = { "America/Chicago", "America/New_York" }; + const char *zones[] = { "America/Chicago", "America/New_York" }; int type, i, res = AST_TEST_PASS; struct timeval tv = ast_tvnow(); - struct ast_tm atm[2]; + struct ast_tm atm[ARRAY_LEN(zones)]; char tmpdir[] = "/tmp/timezone.XXXXXX"; char tzfile[50], syscmd[256]; @@ -73,15 +73,12 @@ AST_TEST_DEFINE(test_timezone_watch) } snprintf(tzfile, sizeof(tzfile), "%s/test", tmpdir); - /* Allow system(3) to function correctly */ - ast_replace_sigchld(); - for (type = 0; type < 2; type++) { ast_test_status_update(test, "Executing %s test...\n", type == 0 ? "deletion" : "symlink"); for (i = 0; i < ARRAY_LEN(zones); i++) { int system_res; snprintf(syscmd, sizeof(syscmd), "%s " TZDIR "/%s %s", type == 0 ? "cp" : "ln -sf", zones[i], tzfile); - if ((system_res = system(syscmd))) { + if ((system_res = ast_safe_system(syscmd))) { ast_log(LOG_WARNING, "system(%s) returned non-zero: %d\n", syscmd, system_res); } ast_localtime_wakeup_monitor(); @@ -93,19 +90,18 @@ AST_TEST_DEFINE(test_timezone_watch) } } - /* stat(2) only has resolution to 1 second - must wait, or the mtime is the same */ - usleep(1100000); + if (i + 1 != ARRAY_LEN(zones)) { + /* stat(2) only has resolution to 1 second - must wait, or the mtime is the same */ + usleep(1100000); + } } } snprintf(syscmd, sizeof(syscmd), "rm -rf %s", tmpdir); - if (system(syscmd)) { + if (ast_safe_system(syscmd)) { ast_log(LOG_WARNING, "system(%s) returned non-zero.\n", syscmd); } - /* Restore SIGCHLD handler */ - ast_unreplace_sigchld(); - return res; } |