[Openais] [PATCH]: openais/trunk: Add code for saTmrTimerRemainingTimeGet

Ryan O'Hara rohara at redhat.com
Tue Feb 17 16:29:05 PST 2009


Patch to finish logic withing saTmrTimerRemainingTimeGet, which makes
use to new corosync API call, api->timer_expire_time_get(handle).

-------------- next part --------------
Index: test/testtmr.c
===================================================================
--- test/testtmr.c	(revision 1701)
+++ test/testtmr.c	(working copy)
@@ -95,6 +95,7 @@
 	SaTimeT current_time;
 	SaTimeT clock_tick;
 	SaTimeT call_time;
+	SaTimeT expire_time;
 
 	void *data_a = 0xdeadbeef;
 	void *data_b = 0xdecafbad;
@@ -162,8 +163,8 @@
 	else {
 		printf ("[DEBUG]: id=%u attributes:\n", id_a);
 		printf ("[DEBUG]:\t type=%"PRId64"\n", attrs.type);
-		printf ("[DEBUG]:\t expire=%"PRIi64"\n", attrs.initialExpirationTime);
-		printf ("[DEBUG]:\t duration=%"PRIi64"\n", attrs.timerPeriodDuration);
+		printf ("[DEBUG]:\t expire=%"PRIu64"\n", attrs.initialExpirationTime);
+		printf ("[DEBUG]:\t duration=%"PRIu64"\n", attrs.timerPeriodDuration);
 	}
 
 	result = saTmrTimerAttributesGet (handle, id_b, &attrs);
@@ -173,13 +174,29 @@
 	else {
 		printf ("[DEBUG]: id=%u attributes:\n", id_b);
 		printf ("[DEBUG]:\t type=%"PRId64"\n", attrs.type);
-		printf ("[DEBUG]:\t expire=%"PRIi64"\n", attrs.initialExpirationTime);
-		printf ("[DEBUG]:\t duration=%"PRIi64"\n", attrs.timerPeriodDuration);
+		printf ("[DEBUG]:\t expire=%"PRIu64"\n", attrs.initialExpirationTime);
+		printf ("[DEBUG]:\t duration=%"PRIu64"\n", attrs.timerPeriodDuration);
 	}
 
 	/* SLEEP */
 	sleep (10);
 
+	result = saTmrTimerRemainingTimeGet (handle, id_a, &expire_time);
+	if (result != SA_AIS_OK) {
+		printf ("[ERROR]: (%d) saTmrTimerRemainingTimeGet\n", result);
+	}
+	else {
+		printf ("[DEBUG]:\t id=%u expire=%"PRIu64"\n", id_a, expire_time);
+	}
+
+	result = saTmrTimerRemainingTimeGet (handle, id_b, &expire_time);
+	if (result != SA_AIS_OK) {
+		printf ("[ERROR]: (%d) saTmrTimerRemainingTimeGet\n", result);
+	}
+	else {
+		printf ("[DEBUG]:\t id=%u expire=%"PRIu64"\n", id_b, expire_time);
+	}
+
 	result = saTmrTimerReschedule (handle, id_a, &new_attrs_a, &time);
 	if (result != SA_AIS_OK) {
 		printf ("[ERROR]: (%d) saTmrTimerReschedule\n", result);
Index: services/tmr.c
===================================================================
--- services/tmr.c	(revision 1701)
+++ services/tmr.c	(working copy)
@@ -576,6 +576,10 @@
 		goto error_exit;
 	}
 
+	res_lib_tmr_timerremainingtimeget.remaining_time =
+		(SaTimeT)((api->timer_expire_time_get(timer_instance->timer_handle)) -
+			  (api->timer_time_get()));
+
 	hdb_handle_put (&timer_hdb, (unsigned int)(timer_instance->timer_id));
 
 error_exit:
Index: lib/tmr.c
===================================================================
--- lib/tmr.c	(revision 1701)
+++ lib/tmr.c	(working copy)
@@ -631,6 +631,8 @@
 		error = res_lib_tmr_timerremainingtimeget.header.error;
 	}
 
+	*remainingTime = res_lib_tmr_timerremainingtimeget.remaining_time;
+
 error_exit:
 	return (error);
 }


More information about the Openais mailing list