Fix allocation on stat so that it uses malloc() since a user will need to use free...
[awesomized/libmemcached] / libtest / alarm.cc
index 2d662622c4bae6bf8607a26b9852ad3db4c4df8e..80d7b2f6def1a9568a4549515f2408fd0ae313dd 100644 (file)
@@ -34,7 +34,8 @@
  *
  */
 
-#include "mem_config.h"
+#include "libtest/yatlcon.h"
+
 #include <libtest/common.h>
 
 #include <sys/time.h>
@@ -59,6 +60,22 @@ void set_alarm()
 
 void set_alarm(long tv_sec, long tv_usec)
 {
+  // For the moment use any value to YATL_ALARM to cancel alarming.
+  if (getenv("YATL_ALARM"))
+  {
+    errno= 0;
+    tv_sec= strtol(getenv("YATL_ALARM"), (char **) NULL, 10);
+
+    if (errno != 0)
+    {
+      fatal_message("Bad value for YATL_ALARM");
+    }
+    else if (tv_sec == 0)
+    {
+      cancel_alarm();
+    }
+  }
+
 #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
   struct timeval it_value= { time_t(tv_sec), suseconds_t(tv_usec) };
 #else