Signed-off-by: Angus Salkeld <asalk...@redhat.com> --- README.devmap | 5 +- exec/Makefile.am | 2 +- exec/apidef.c | 7 +- exec/main.c | 5 - exec/timer.c | 266 +++++------------------------------------ exec/timer.h | 19 +-- exec/tlist.h | 318 ------------------------------------------------- exec/totemconfig.c | 2 +- exec/totemsrp.c | 21 ++-- lib/votequorum.c | 1 + services/pload.c | 7 +- services/votequorum.c | 14 +- 12 files changed, 64 insertions(+), 603 deletions(-) delete mode 100644 exec/tlist.h
diff --git a/README.devmap b/README.devmap index 2300c38..89e4caf 100644 --- a/README.devmap +++ b/README.devmap @@ -289,10 +289,7 @@ exec/sync.{c|h} The synchronization service implementation. exec/timer.{c|h} - Threaded based timer service. - -exec/tlist.h - Timer list used to expire timers. + Threaded based timer service (deprecated - use qb_loop_timer). exec/totemconfig.{c.h} The totem configuration configurator from data parsed with aisparser diff --git a/exec/Makefile.am b/exec/Makefile.am index f877551..d5f71cc 100644 --- a/exec/Makefile.am +++ b/exec/Makefile.am @@ -68,7 +68,7 @@ SHARED_LIBS_SO = $(SHARED_LIBS:%.so.$(SONAME)=%.so) SHARED_LIBS_SO_TWO = $(SHARED_LIBS:%.so.$(SONAME)=%.so.$(SOMAJOR)) noinst_HEADERS = apidef.h crypto.h mainconfig.h main.h tsafe.h \ - quorum.h service.h sync.h timer.h tlist.h totemconfig.h \ + quorum.h service.h sync.h timer.h totemconfig.h \ totemmrp.h totemnet.h totemudp.h totemiba.h totemrrp.h \ totemsrp.h util.h vsf.h wthread.h schedwrk.h \ evil.h syncv2.h fsm.h diff --git a/exec/apidef.c b/exec/apidef.c index e477f2c..c101d4c 100644 --- a/exec/apidef.c +++ b/exec/apidef.c @@ -37,13 +37,16 @@ #include <stdlib.h> #include <string.h> +#include <qb/qbutil.h> +#include <qb/qbloop.h> +#include <qb/qbipcs.h> + #include <corosync/corotypes.h> #include <corosync/lcr/lcr_ifact.h> #include <corosync/totem/totempg.h> #include <corosync/totem/totemip.h> #include <corosync/totem/totem.h> #include <corosync/engine/logsys.h> -#include <qb/qbipcs.h> #include "util.h" #include "timer.h" #include "sync.h" @@ -96,7 +99,7 @@ static struct corosync_api_v1 apidef_corosync_api_v1 = { .timer_add_duration = corosync_timer_add_duration, .timer_add_absolute = corosync_timer_add_absolute, .timer_delete = corosync_timer_delete, - .timer_time_get = corosync_timer_time_get, + .timer_time_get = qb_util_nano_from_epoch_get, .timer_expire_time_get = corosync_timer_expire_time_get, .ipc_source_set = message_source_set, .ipc_source_is_local = message_source_is_local, diff --git a/exec/main.c b/exec/main.c index 00ac197..30d8d0f 100644 --- a/exec/main.c +++ b/exec/main.c @@ -1433,11 +1433,6 @@ int main (int argc, char **argv, char **envp) /* callthis after our fork() */ tsafe_init (envp); - corosync_timer_init ( - serialize_lock, - serialize_unlock, - sched_priority); - corosync_poll_handle = qb_loop_create (); /* diff --git a/exec/timer.c b/exec/timer.c index 1d71f14..92a2241 100644 --- a/exec/timer.c +++ b/exec/timer.c @@ -35,267 +35,57 @@ #include <config.h> -#include <pthread.h> -#include <pwd.h> -#include <grp.h> -#include <sys/types.h> -#include <sys/poll.h> -#include <sys/uio.h> -#include <sys/mman.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <signal.h> -#include <sched.h> -#include <time.h> - -#include <corosync/swab.h> -#include <corosync/corotypes.h> -#include <corosync/list.h> -#include <corosync/lcr/lcr_ifact.h> -#include <qb/qbloop.h> -#include <corosync/totem/totempg.h> -#include <corosync/engine/objdb.h> -#include <corosync/engine/config.h> -#define LOG_SERVICE LOG_SERVICE_IPC -#include <corosync/engine/logsys.h> - -#include "poll.h" -#include "totemsrp.h" -#include "mainconfig.h" -#include "totemconfig.h" -#include "main.h" -#include "sync.h" -#include "tlist.h" -#include "util.h" #include "timer.h" - -#define SERVER_BACKLOG 5 - -static pthread_mutex_t timer_mutex = PTHREAD_MUTEX_INITIALIZER; - -static pthread_t expiry_thread; - -static pthread_attr_t thread_attr; - -static struct timerlist timers_timerlist; - -static int sched_priority = 0; - -static void (*timer_serialize_lock_fn) (void); - -static void (*timer_serialize_unlock_fn) (void); - -static void *prioritized_timer_thread (void *data); - -extern void pthread_exit(void *) __attribute__((noreturn)); - -/* - * This thread runs at the highest priority to run system wide timers - */ -static void *prioritized_timer_thread (void *data) -{ - int fds; - unsigned long long timeout; - -#if defined(HAVE_PTHREAD_SETSCHEDPARAM) && defined(HAVE_SCHED_GET_PRIORITY_MAX) - if (sched_priority != 0) { - struct sched_param sched_param; - - sched_param.sched_priority = sched_priority; - pthread_setschedparam (expiry_thread, SCHED_RR, &sched_param); - } -#endif - - pthread_mutex_unlock (&timer_mutex); - for (;;) { - timer_serialize_lock_fn (); - timeout = timerlist_msec_duration_to_expire (&timers_timerlist); - if (timeout != -1 && timeout > 0xFFFFFFFF) { - timeout = 0xFFFFFFFE; - } - timer_serialize_unlock_fn (); - fds = poll (NULL, 0, timeout); - if (fds < 0 && errno == EINTR) { - continue; - } - if (fds < 0) { - return NULL; - } - pthread_mutex_lock (&timer_mutex); - timer_serialize_lock_fn (); - - timerlist_expire (&timers_timerlist); - - timer_serialize_unlock_fn (); - pthread_mutex_unlock (&timer_mutex); - } -} - -static void sigusr1_handler (int num) { -#ifdef COROSYNC_SOLARIS - /* Rearm the signal facility */ - signal (num, sigusr1_handler); -#endif -} - -int corosync_timer_init ( - void (*serialize_lock_fn) (void), - void (*serialize_unlock_fn) (void), - int sched_priority_in) -{ - int res; - - timer_serialize_lock_fn = serialize_lock_fn; - timer_serialize_unlock_fn = serialize_unlock_fn; - sched_priority = sched_priority_in; - - timerlist_init (&timers_timerlist); - - signal (SIGUSR1, sigusr1_handler); - - pthread_mutex_lock (&timer_mutex); - pthread_attr_init (&thread_attr); - pthread_attr_setstacksize (&thread_attr, 100000); - pthread_attr_setdetachstate (&thread_attr, PTHREAD_CREATE_DETACHED); - res = pthread_create (&expiry_thread, &thread_attr, - prioritized_timer_thread, NULL); - - return (res); -} +#include "main.h" +#include <qb/qbdefs.h> +#include <qb/qbutil.h> int corosync_timer_add_absolute ( - unsigned long long nanosec_from_epoch, - void *data, - void (*timer_fn) (void *data), - timer_handle *handle) + unsigned long long nanosec_from_epoch, + void *data, + void (*timer_fn) (void *data), + corosync_timer_handle *handle) { - int res; - int unlock; - - if (pthread_equal (pthread_self(), expiry_thread) != 0) { - unlock = 0; - } else { - unlock = 1; - pthread_mutex_lock (&timer_mutex); - } - - res = timerlist_add_absolute ( - &timers_timerlist, - timer_fn, - data, - nanosec_from_epoch, - handle); - - if (unlock) { - pthread_mutex_unlock (&timer_mutex); - } - - pthread_kill (expiry_thread, SIGUSR1); - - return (res); + uint64_t expire_time = nanosec_from_epoch - qb_util_nano_current_get(); + return qb_loop_timer_add(corosync_poll_handle_get(), + QB_LOOP_MED, + expire_time / QB_TIME_NS_IN_MSEC, + data, + timer_fn, + handle); } int corosync_timer_add_duration ( unsigned long long nanosec_duration, void *data, void (*timer_fn) (void *data), - timer_handle *handle) + corosync_timer_handle *handle) { - int res; - int unlock; - - if (pthread_equal (pthread_self(), expiry_thread) != 0) { - unlock = 0; - } else { - unlock = 1; - pthread_mutex_lock (&timer_mutex); - } - - res = timerlist_add_duration ( - &timers_timerlist, - timer_fn, - data, - nanosec_duration, - handle); - - if (unlock) { - pthread_mutex_unlock (&timer_mutex); - } - - pthread_kill (expiry_thread, SIGUSR1); - - return (res); + return qb_loop_timer_add(corosync_poll_handle_get(), + QB_LOOP_MED, + nanosec_duration / QB_TIME_NS_IN_MSEC, + data, + timer_fn, + handle); } void corosync_timer_delete ( - timer_handle th) + corosync_timer_handle th) { - int unlock; - - if (th == 0) { - return; - } - - if (pthread_equal (pthread_self(), expiry_thread) != 0) { - unlock = 0; - } else { - unlock = 1; - pthread_mutex_lock (&timer_mutex); - } - - timerlist_del (&timers_timerlist, th); - - if (unlock) { - pthread_mutex_unlock (&timer_mutex); - } -} - -void corosync_timer_lock (void) -{ - pthread_mutex_lock (&timer_mutex); -} - -void corosync_timer_unlock (void) -{ - pthread_mutex_unlock (&timer_mutex); + qb_loop_timer_del(corosync_poll_handle_get(), th); } -unsigned long long corosync_timer_time_get (void) +uint64_t corosync_timer_expire_time_get ( + corosync_timer_handle th) { - return (timerlist_nano_from_epoch()); -} - -unsigned long long corosync_timer_expire_time_get ( - timer_handle th) -{ - int unlock; - unsigned long long expire; + uint64_t expire; if (th == 0) { return (0); } - if (pthread_equal (pthread_self(), expiry_thread) != 0) { - unlock = 0; - } else { - unlock = 1; - pthread_mutex_lock (&timer_mutex); - } - - expire = timerlist_expire_time (&timers_timerlist, th); - - if (unlock) { - pthread_mutex_unlock (&timer_mutex); - } + expire = qb_loop_timer_expire_time_get(corosync_poll_handle_get(), th); return (expire); } + diff --git a/exec/timer.h b/exec/timer.h index 7d6826a..5f0e849 100644 --- a/exec/timer.h +++ b/exec/timer.h @@ -35,12 +35,11 @@ #ifndef TIMER_H_DEFINED #define TIMER_H_DEFINED -typedef void * corosync_timer_handle; +#include <stdint.h> +#include <time.h> +#include <qb/qbloop.h> -extern int corosync_timer_init ( - void (*serialize_lock) (void), - void (*serialize_unlock) (void), - int sched_priority); +typedef qb_loop_timer_handle corosync_timer_handle; extern int corosync_timer_add_duration ( unsigned long long nanosec_duration, @@ -56,14 +55,6 @@ extern int corosync_timer_add_absolute ( extern void corosync_timer_delete (corosync_timer_handle handle); -extern void corosync_timer_delete_data (corosync_timer_handle handle); - -extern void corosync_timer_lock (void); - -extern void corosync_timer_unlock (void); - -extern unsigned long long corosync_timer_time_get (void); - -extern unsigned long long corosync_timer_expire_time_get (corosync_timer_handle handle); +extern uint64_t corosync_timer_expire_time_get (corosync_timer_handle handle); #endif /* TIMER_H_DEFINED */ diff --git a/exec/tlist.h b/exec/tlist.h deleted file mode 100644 index 7b568ee..0000000 --- a/exec/tlist.h +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright (c) 2003-2004 MontaVista Software, Inc. - * Copyright (c) 2006-2007, 2009 Red Hat, Inc. - * - * All rights reserved. - * - * Author: Steven Dake (sd...@redhat.com) - * - * This software licensed under BSD license, the text of which follows: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of the MontaVista Software, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TLIST_H_DEFINED -#define TLIST_H_DEFINED - -#include <sys/time.h> -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <string.h> -#include <sys/param.h> -#include <unistd.h> - -#include <corosync/list.h> - -#ifndef HZ - #define HZ 100 /* 10ms */ -#endif - -#ifndef TIMER_HANDLE -typedef void * timer_handle; -#define TIMER_HANDLE -#endif - -#define TIMERLIST_MS_IN_SEC 1000ULL -#define TIMERLIST_US_IN_SEC 1000000ULL -#define TIMERLIST_NS_IN_SEC 1000000000ULL -#define TIMERLIST_US_IN_MSEC 1000ULL -#define TIMERLIST_NS_IN_MSEC 1000000ULL -#define TIMERLIST_NS_IN_USEC 1000ULL - -struct timerlist { - struct list_head timer_head; - struct list_head *timer_iter; -}; - -struct timerlist_timer { - struct list_head list; - unsigned long long expire_time; - int is_absolute_timer; - void (*timer_fn)(void *data); - void *data; - timer_handle handle_addr; -}; - -static inline void timerlist_init (struct timerlist *timerlist) -{ - list_init (&timerlist->timer_head); -} - -static inline unsigned long long timerlist_nano_from_epoch (void) -{ - unsigned long long nano_from_epoch; - struct timeval time_from_epoch; - gettimeofday (&time_from_epoch, 0); - - nano_from_epoch = ((time_from_epoch.tv_sec * TIMERLIST_NS_IN_SEC) + - (time_from_epoch.tv_usec * TIMERLIST_NS_IN_USEC)); - - return (nano_from_epoch); -} - -#if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0 -static inline unsigned long long timerlist_nano_current_get (void) -{ - unsigned long long nano_monotonic; - struct timespec ts; - - clock_gettime (CLOCK_MONOTONIC, &ts); - - nano_monotonic = (ts.tv_sec * TIMERLIST_NS_IN_SEC) + (unsigned long long )ts.tv_nsec; - return (nano_monotonic); -} - -static inline unsigned long long timerlist_nano_monotonic_hz (void) { - unsigned long long nano_monotonic_hz; - struct timespec ts; - - clock_getres (CLOCK_MONOTONIC, &ts); - - nano_monotonic_hz = TIMERLIST_NS_IN_SEC / ((ts.tv_sec * TIMERLIST_NS_IN_SEC) + ts.tv_nsec); - - return (nano_monotonic_hz); -} -#else -#warning "Your system doesn't support monotonic timer. gettimeofday will be used" -static inline unsigned long long timerlist_nano_current_get (void) -{ - return (timerlist_nano_from_epoch ()); -} - -static inline unsigned long long timerlist_nano_monotonic_hz (void) { - return HZ; -} -#endif - -static inline void timerlist_add (struct timerlist *timerlist, struct timerlist_timer *timer) -{ - struct list_head *timer_list = 0; - struct timerlist_timer *timer_from_list; - int found; - - for (found = 0, timer_list = timerlist->timer_head.next; - timer_list != &timerlist->timer_head; - timer_list = timer_list->next) { - - timer_from_list = list_entry (timer_list, - struct timerlist_timer, list); - - if (timer_from_list->expire_time > timer->expire_time) { - list_add (&timer->list, timer_list->prev); - found = 1; - break; /* for timer iteration */ - } - } - if (found == 0) { - list_add (&timer->list, timerlist->timer_head.prev); - } -} - -static inline int timerlist_add_absolute (struct timerlist *timerlist, - void (*timer_fn) (void *data), - void *data, - unsigned long long nano_from_epoch, - timer_handle *handle) -{ - struct timerlist_timer *timer; - - timer = (struct timerlist_timer *)malloc (sizeof (struct timerlist_timer)); - if (timer == 0) { - errno = ENOMEM; - return (-1); - } - - timer->expire_time = nano_from_epoch; - timer->is_absolute_timer = 1; - timer->data = data; - timer->timer_fn = timer_fn; - timer->handle_addr = handle; - timerlist_add (timerlist, timer); - - *handle = timer; - return (0); -} - -static inline int timerlist_add_duration (struct timerlist *timerlist, - void (*timer_fn) (void *data), - void *data, - unsigned long long nano_duration, - timer_handle *handle) -{ - struct timerlist_timer *timer; - - timer = (struct timerlist_timer *)malloc (sizeof (struct timerlist_timer)); - if (timer == 0) { - errno = ENOMEM; - return (-1); - } - - timer->expire_time = timerlist_nano_current_get () + nano_duration; - timer->is_absolute_timer = 0; - timer->data = data; - timer->timer_fn = timer_fn; - timer->handle_addr = handle; - timerlist_add (timerlist, timer); - - *handle = timer; - return (0); -} - -static inline void timerlist_del (struct timerlist *timerlist, - timer_handle _timer_handle) -{ - struct timerlist_timer *timer = (struct timerlist_timer *)_timer_handle; - - memset (timer->handle_addr, 0, sizeof (struct timerlist_timer *)); - /* - * If the next timer after the currently expiring timer because - * timerlist_del is called from a timer handler, get to the next - * timer - */ - if (timerlist->timer_iter == &timer->list) { - timerlist->timer_iter = timerlist->timer_iter->next; - } - list_del (&timer->list); - list_init (&timer->list); - free (timer); -} - -static inline unsigned long long timerlist_expire_time (struct timerlist *timerlist, timer_handle _timer_handle) -{ - struct timerlist_timer *timer = (struct timerlist_timer *)_timer_handle; - - return (timer->expire_time); -} - -static inline void timerlist_pre_dispatch (struct timerlist *timerlist, timer_handle _timer_handle) -{ - struct timerlist_timer *timer = (struct timerlist_timer *)_timer_handle; - - memset (timer->handle_addr, 0, sizeof (struct timerlist_timer *)); - list_del (&timer->list); - list_init (&timer->list); -} - -static inline void timerlist_post_dispatch (struct timerlist *timerlist, timer_handle _timer_handle) -{ - struct timerlist_timer *timer = (struct timerlist_timer *)_timer_handle; - - free (timer); -} - -/* - * returns the number of msec until the next timer will expire for use with poll - */ -static inline unsigned long long timerlist_msec_duration_to_expire (struct timerlist *timerlist) -{ - struct timerlist_timer *timer_from_list; - volatile unsigned long long current_time; - volatile unsigned long long msec_duration_to_expire; - - /* - * empty list, no expire - */ - if (timerlist->timer_head.next == &timerlist->timer_head) { - return (-1); - } - - timer_from_list = list_entry (timerlist->timer_head.next, - struct timerlist_timer, list); - - if (timer_from_list->is_absolute_timer) { - current_time = timerlist_nano_from_epoch (); - } else { - current_time = timerlist_nano_current_get (); - } - - /* - * timer at head of list is expired, zero msecs required - */ - if (timer_from_list->expire_time < current_time) { - return (0); - } - - msec_duration_to_expire = ((timer_from_list->expire_time - current_time) / TIMERLIST_NS_IN_MSEC) + - (1000 / HZ); - return (msec_duration_to_expire); -} - -/* - * Expires any timers that should be expired - */ -static inline void timerlist_expire (struct timerlist *timerlist) -{ - struct timerlist_timer *timer_from_list; - unsigned long long current_time_from_epoch; - unsigned long long current_monotonic_time; - unsigned long long current_time; - - current_monotonic_time = timerlist_nano_current_get (); - current_time_from_epoch = current_time = timerlist_nano_from_epoch (); - - for (timerlist->timer_iter = timerlist->timer_head.next; - timerlist->timer_iter != &timerlist->timer_head;) { - - timer_from_list = list_entry (timerlist->timer_iter, - struct timerlist_timer, list); - - current_time = (timer_from_list->is_absolute_timer ? current_time_from_epoch : current_monotonic_time); - - if (timer_from_list->expire_time < current_time) { - timerlist->timer_iter = timerlist->timer_iter->next; - - timerlist_pre_dispatch (timerlist, timer_from_list); - - timer_from_list->timer_fn (timer_from_list->data); - - timerlist_post_dispatch (timerlist, timer_from_list); - } else { - break; /* for timer iteration */ - } - } - timerlist->timer_iter = 0; -} -#endif /* TLIST_H_DEFINED */ diff --git a/exec/totemconfig.c b/exec/totemconfig.c index ad1b116..e9eda46 100644 --- a/exec/totemconfig.c +++ b/exec/totemconfig.c @@ -50,6 +50,7 @@ #include <corosync/swab.h> #include <corosync/list.h> +#include <qb/qbdefs.h> #include <corosync/totem/totem.h> #include <corosync/engine/objdb.h> #include <corosync/engine/config.h> @@ -64,7 +65,6 @@ #include "util.h" #include "totemconfig.h" -#include "tlist.h" /* for HZ */ #define TOKEN_RETRANSMITS_BEFORE_LOSS_CONST 4 #define TOKEN_TIMEOUT 1000 diff --git a/exec/totemsrp.c b/exec/totemsrp.c index 917d3ed..808ed7e 100644 --- a/exec/totemsrp.c +++ b/exec/totemsrp.c @@ -74,12 +74,16 @@ #include <sys/poll.h> #include <limits.h> +#include <qb/qbdefs.h> +#include <qb/qbutil.h> +#include <qb/qbloop.h> + #include <corosync/swab.h> #include <corosync/cs_queue.h> #include <corosync/sq.h> #include <corosync/list.h> #include <corosync/hdb.h> -#include <qb/qbloop.h> + #define LOGSYS_UTILS_ONLY 1 #include <corosync/engine/logsys.h> @@ -89,7 +93,6 @@ #include "wthread.h" #include "crypto.h" -#include "tlist.h" #define LOCALHOST_IP inet_addr("127.0.0.1") #define QUEUE_RTR_ITEMS_SIZE_MAX 16384 /* allow 16384 retransmit items */ @@ -694,8 +697,8 @@ static int pause_flush (struct totemsrp_instance *instance) uint64_t timestamp_msec; int res = 0; - now_msec = (timerlist_nano_current_get () / TIMERLIST_NS_IN_MSEC); - timestamp_msec = instance->pause_timestamp / TIMERLIST_NS_IN_MSEC; + now_msec = (qb_util_nano_current_get () / QB_TIME_NS_IN_MSEC); + timestamp_msec = instance->pause_timestamp / QB_TIME_NS_IN_MSEC; if ((now_msec - timestamp_msec) > (instance->totem_config->token_timeout / 2)) { log_printf (instance->totemsrp_log_level_notice, @@ -714,9 +717,9 @@ static int token_event_stats_collector (enum totem_callback_token_type type, con { struct totemsrp_instance *instance = (struct totemsrp_instance *)void_instance; uint32_t time_now; - unsigned long long nano_secs = timerlist_nano_current_get (); + unsigned long long nano_secs = qb_util_nano_current_get (); - time_now = (nano_secs / TIMERLIST_NS_IN_MSEC); + time_now = (nano_secs / QB_TIME_NS_IN_MSEC); if (type == TOTEM_CALLBACK_TOKEN_RECEIVED) { /* incr latest token the index */ @@ -1524,7 +1527,7 @@ static void timer_function_pause_timeout (void *data) { struct totemsrp_instance *instance = data; - instance->pause_timestamp = timerlist_nano_current_get (); + instance->pause_timestamp = qb_util_nano_current_get (); reset_pause_timeout (instance); } @@ -3341,7 +3344,7 @@ static int message_handler_orf_token ( unsigned long long tv_current; unsigned long long tv_diff; - tv_current = timerlist_nano_current_get (); + tv_current = qb_util_nano_current_get (); tv_diff = tv_current - tv_old; tv_old = tv_current; @@ -3573,7 +3576,7 @@ printf ("token seq %d\n", token->seq); token_send (instance, token, forward_token); #ifdef GIVEINFO - tv_current = timerlist_nano_current_get (); + tv_current = qb_util_nano_current_get (); tv_diff = tv_current - tv_old; tv_old = tv_current; log_printf (instance->totemsrp_log_level_debug, diff --git a/lib/votequorum.c b/lib/votequorum.c index 3f34160..470d318 100644 --- a/lib/votequorum.c +++ b/lib/votequorum.c @@ -45,6 +45,7 @@ #include <sys/socket.h> #include <errno.h> +#include <qb/qbdefs.h> #include <qb/qbipcc.h> #include <corosync/corotypes.h> diff --git a/services/pload.c b/services/pload.c index f7563c2..bd7240f 100644 --- a/services/pload.c +++ b/services/pload.c @@ -53,6 +53,7 @@ #include <assert.h> #include <qb/qblist.h> +#include <qb/qbutil.h> #include <qb/qbipc_common.h> #include <corosync/swab.h> @@ -65,8 +66,6 @@ #include <corosync/list.h> #include <corosync/engine/logsys.h> -#include "../exec/tlist.h" - LOGSYS_DECLARE_SUBSYS ("PLOAD"); enum pload_exec_message_req_types { @@ -363,11 +362,11 @@ static void message_handler_req_exec_pload_mcast ( last_msg_no = pload_mcast->msg_code; if (msgs_delivered == 0) { - tv1 = timerlist_nano_current_get (); + tv1 = qb_util_nano_current_get (); } msgs_delivered += 1; if (msgs_delivered == msgs_wanted) { - tv2 = timerlist_nano_current_get (); + tv2 = qb_util_nano_current_get (); tv_elapsed = tv2 - tv1; sprintf (log_buffer, "%5d Writes %d bytes per write %7.3f seconds runtime, %9.3f TP/S, %9.3f MB/S.\n", msgs_delivered, diff --git a/services/votequorum.c b/services/votequorum.c index f0832f2..9cb6aaf 100644 --- a/services/votequorum.c +++ b/services/votequorum.c @@ -55,8 +55,11 @@ #include <netinet/in.h> #include <arpa/inet.h> -#include <corosync/corotypes.h> #include <qb/qbipc_common.h> +#include <qb/qbdefs.h> +#include <qb/qbutil.h> + +#include <corosync/corotypes.h> #include <corosync/corodefs.h> #include <corosync/cfg.h> #include <corosync/list.h> @@ -66,9 +69,6 @@ #include <corosync/engine/coroapi.h> #include <corosync/engine/quorum.h> #include <corosync/ipc_votequorum.h> -#include <corosync/list.h> - -#include "../exec/tlist.h" #define VOTEQUORUM_MAJOR_VERSION 7 #define VOTEQUORUM_MINOR_VERSION 0 @@ -1319,8 +1319,8 @@ static void quorum_device_timer_fn(void *arg) if (!quorum_device || quorum_device->state == NODESTATE_DEAD) return; - if ( (quorum_device->last_hello / TIMERLIST_NS_IN_SEC) + quorumdev_poll/1000 < - (timerlist_nano_current_get () / TIMERLIST_NS_IN_SEC)) { + if ( (quorum_device->last_hello / QB_TIME_NS_IN_SEC) + quorumdev_poll/1000 < + (qb_util_nano_current_get () / QB_TIME_NS_IN_SEC)) { quorum_device->state = NODESTATE_DEAD; log_printf(LOGSYS_LEVEL_INFO, "lost contact with quorum device\n"); @@ -1403,7 +1403,7 @@ static void message_handler_req_lib_votequorum_qdisk_poll (void *conn, if (quorum_device) { if (req_lib_votequorum_qdisk_poll->state) { - quorum_device->last_hello = timerlist_nano_current_get (); + quorum_device->last_hello = qb_util_nano_current_get (); if (quorum_device->state == NODESTATE_DEAD) { quorum_device->state = NODESTATE_MEMBER; recalculate_quorum(0, 0); -- 1.7.3.1 _______________________________________________ Openais mailing list Openais@lists.linux-foundation.org https://lists.linux-foundation.org/mailman/listinfo/openais