From: <svn...@op...> - 2009-03-17 15:01:00
|
Author: bellmich Date: Tue Mar 17 16:00:49 2009 New Revision: 983 URL: http://libsyncml.opensync.org/changeset/983 Log: added timeout in the while loop of the client Modified: trunk/tests/check_libsoup.c trunk/tests/support.c trunk/tests/support.h Modified: trunk/tests/check_libsoup.c ============================================================================== --- trunk/tests/check_libsoup.c Tue Mar 17 14:04:24 2009 (r982) +++ trunk/tests/check_libsoup.c Tue Mar 17 16:00:49 2009 (r983) @@ -150,9 +150,13 @@ /* wait until message was received by server */ - while (server_messages < 1 && server_errors < 1) + int64_t sleep_max = 5000000000; + int64_t sleep_interval = 50000000; + int64_t sleep_total = 0; + while (server_messages < 1 && server_errors < 1 && sleep_total < sleep_max) { - usleep(50); + sml_sleep(sleep_interval); + sleep_total += sleep_interval; } /* check counter */ Modified: trunk/tests/support.c ============================================================================== --- trunk/tests/support.c Tue Mar 17 14:04:24 2009 (r982) +++ trunk/tests/support.c Tue Mar 17 16:00:49 2009 (r983) @@ -145,3 +145,13 @@ return parser; } + +int sml_sleep(int64_t nanoseconds) +{ + long seconds = nanoseconds / 1000000000; + nanoseconds = nanoseconds % 1000000000; + struct timespec timestr; + timestr.tv_sec = seconds; + timestr.tv_nsec = nanoseconds; + return nanosleep(×tr, NULL); +} Modified: trunk/tests/support.h ============================================================================== --- trunk/tests/support.h Tue Mar 17 14:04:24 2009 (r982) +++ trunk/tests/support.h Tue Mar 17 16:00:49 2009 (r983) @@ -28,6 +28,7 @@ void destroy_testbed(char *path); void create_case(Suite *s, const char *name, TFun function); SmlParser *start_parser(const char *data, SmlError **error); +int sml_sleep(int64_t nanoseconds); #ifdef THREAD_SAFE_CHECK |