Changeset: b972128e6ca3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b972128e6ca3
Modified Files:
        monetdb5/modules/mal/wlc.c
        sql/backends/monet5/wlr.c
Branch: default
Log Message:

Use mtime timestamps at wlcr


diffs (86 lines):

diff --git a/monetdb5/modules/mal/wlc.c b/monetdb5/modules/mal/wlc.c
--- a/monetdb5/modules/mal/wlc.c
+++ b/monetdb5/modules/mal/wlc.c
@@ -162,6 +162,7 @@
 #include <time.h>
 #include "mal_builder.h"
 #include "wlc.h"
+#include "mtime.h"
 
 MT_Lock     wlc_lock = MT_LOCK_INITIALIZER("wlc_lock");
 
@@ -529,18 +530,18 @@ WLCstop(Client cntxt, MalBlkPtr mb, MalS
 static str
 WLCsettime(Client cntxt, InstrPtr pci, InstrPtr p, str fcn)
 {
-       struct timeval clock;
-       time_t clk ;
-       struct tm ctm = (struct tm) {0};
-       char wlc_time[26];
+       timestamp ts = timestamp_current();
+       str wlc_time = NULL;
+       size_t wlc_limit = 0;
+       InstrPtr ins;
 
        (void) pci;
-       if(gettimeofday(&clock,NULL) == -1)
+       assert(!is_timestamp_nil(ts));
+       if (timestamp_tostr(&wlc_time, &wlc_limit, &ts, true) < 0)
                throw(MAL, fcn, "Unable to retrieve current time");
-       clk = clock.tv_sec;
-       (void) gmtime_r(&clk, &ctm);
-       strftime(wlc_time, sizeof(wlc_time), "%Y-%m-%d %H:%M:%S.000",&ctm);
-       if (pushStr(cntxt->wlc, p, wlc_time) == NULL)
+       ins = pushStr(cntxt->wlc, p, wlc_time);
+       GDKfree(wlc_time);
+       if (ins == NULL)
                throw(MAL, fcn, MAL_MALLOC_FAIL);
        return MAL_SUCCEED;
 }
diff --git a/sql/backends/monet5/wlr.c b/sql/backends/monet5/wlr.c
--- a/sql/backends/monet5/wlr.c
+++ b/sql/backends/monet5/wlr.c
@@ -440,12 +440,9 @@ WLRprocessBatch(Client cntxt)
  */
 static void
 WLRprocessScheduler(void *arg)
-{      Client cntxt = (Client) arg;
+{
+       Client cntxt = (Client) arg;
        int duration = 0;
-       struct timeval clock;
-       time_t clk;
-       struct tm ctm;
-       char clktxt[26];
        str msg = MAL_SUCCEED;
 
        msg = WLRgetConfig();
@@ -470,16 +467,22 @@ WLRprocessScheduler(void *arg)
                // wait at most for the cycle period, also at start
                duration = (wlc_beat > 0 ? wlc_beat:1) * 1000 ;
                if( wlr_timelimit[0]){
-                       gettimeofday(&clock, NULL);
-                       clk = clock.tv_sec;
-                       ctm = (struct tm) {0};
-                       (void) localtime_r(&clk, &ctm);
-                       strftime(clktxt, sizeof(clktxt), "%Y-%m-%d 
%H:%M:%S.000",&ctm);
+                       timestamp ts = timestamp_current();
+                       str wlc_time = NULL;
+                       size_t wlc_limit = 0;
+                       int compare;
 
+                       assert(!is_timestamp_nil(ts));
+                       if (timestamp_tostr(&wlc_time, &wlc_limit, &ts, true) < 
0) {
+                               snprintf(wlr_error, BUFSIZ, "Unable to retrieve 
current time");
+                               return;
+                       }
                        // actually never wait longer then the timelimit 
requires
                        // preference is given to the beat.
+                       compare = strncmp(wlc_time, wlr_timelimit, 
sizeof(wlr_timelimit));
+                       GDKfree(wlc_time);
                        MT_thread_setworking("sleeping");
-                       if(strncmp(clktxt, wlr_timelimit,sizeof(wlr_timelimit)) 
>= 0 && duration >100)
+                       if (compare >= 0 && duration >100)
                                MT_sleep_ms(duration);
                } 
                for( ; duration > 0  && wlr_state != WLR_STOP; duration -= 200){
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to