And this time I will actually attach the patch...

On Tue, Feb 17, 2009 at 06:26:34PM -0600, Ryan O'Hara wrote:
> 
> This patch adds a new corosync API call, timer_expire_time_get.
> 
> This call will return the absolute time representing the time that a
> timer (specified by handle) is due to expire.
> 
Index: include/corosync/engine/coroapi.h
===================================================================
--- include/corosync/engine/coroapi.h   (revision 1760)
+++ include/corosync/engine/coroapi.h   (working copy)
@@ -376,6 +376,9 @@
 
        unsigned long long (*timer_time_get) (void);
 
+       unsigned long long (*timer_expire_time_get) (
+               corosync_timer_handle_t timer_handle);
+
        /*
         * IPC APIs
         */
Index: exec/apidef.c
===================================================================
--- exec/apidef.c       (revision 1760)
+++ exec/apidef.c       (working copy)
@@ -72,6 +72,7 @@
        .timer_add_absolute = corosync_timer_add_absolute,
        .timer_delete = corosync_timer_delete,
        .timer_time_get = corosync_timer_time_get,
+       .timer_expire_time_get = corosync_timer_expire_time_get,
        .ipc_source_set = message_source_set,
        .ipc_source_is_local = message_source_is_local,
        .ipc_private_data_get = cs_conn_private_data_get,
Index: exec/tlist.h
===================================================================
--- exec/tlist.h        (revision 1760)
+++ exec/tlist.h        (working copy)
@@ -172,6 +172,13 @@
        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->nano_from_epoch);
+}
+
 static inline void timerlist_pre_dispatch (struct timerlist *timerlist, 
timer_handle timer_handle)
 {
        struct timerlist_timer *timer = (struct timerlist_timer *)timer_handle;
@@ -215,7 +222,6 @@
        if (timer_from_list->nano_from_epoch < nano_from_epoch) {
                return (0);
        }
-
        
        msec_duration_to_expire = ((timer_from_list->nano_from_epoch - 
nano_from_epoch) / 1000000ULL) +
                (1000 / HZ);
Index: exec/timer.c
===================================================================
--- exec/timer.c        (revision 1760)
+++ exec/timer.c        (working copy)
@@ -267,3 +267,29 @@
 {
        return (timerlist_nano_from_epoch());
 }
+
+unsigned long long corosync_timer_expire_time_get (
+       timer_handle timer_handle)
+{
+       int unlock;
+       unsigned long long expire;
+
+       if (timer_handle == 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, timer_handle);
+
+       if (unlock) {
+               pthread_mutex_unlock (&timer_mutex);
+       }
+
+       return (expire);
+}
Index: exec/timer.h
===================================================================
--- exec/timer.h        (revision 1760)
+++ exec/timer.h        (working copy)
@@ -63,4 +63,6 @@
 
 extern unsigned long long corosync_timer_time_get (void);
 
+extern unsigned long long corosync_timer_expire_time_get 
(corosync_timer_handle timer_handle);
+
 #endif /* TIMER_H_DEFINED */
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to