Changeset: d594efacebf7 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d594efacebf7
Modified Files:
        gdk/gdk_system.c
        gdk/gdk_system.h
        monetdb5/mal/mal_interpreter.c
Branch: qcancel
Log Message:

start qcancel


diffs (146 lines):

diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c
--- a/gdk/gdk_system.c
+++ b/gdk/gdk_system.c
@@ -183,6 +183,7 @@ static struct winthread {
        ATOMIC_TYPE exited;
        bool detached:1, waiting:1;
        char threadname[MT_NAME_LEN];
+       QryCtx *qry_ctx;
 } *winthreads = NULL;
 static struct winthread mainthread = {
        .threadname = "main thread",
@@ -264,6 +265,37 @@ MT_thread_setdata(void *data)
                w->data = data;
 }
 
+void *
+MT_thread_getdata(void)
+{
+       if (threadslot == TLS_OUT_OF_INDEXES)
+               return NULL;
+       struct winthread *w = TlsGetValue(threadslot);
+
+       return w ? w->data : NULL;
+}
+
+void
+MT_thread_set_qry_ctx(QryCtx *ctx)
+{
+       if (threadslot == TLS_OUT_OF_INDEXES)
+               return;
+       struct winthread *w = TlsGetValue(threadslot);
+
+       if (w)
+               w->qry_ctx = ctx;
+}
+
+QryCtx *
+MT_thread_get_qry_ctx(void)
+{
+       if (threadslot == TLS_OUT_OF_INDEXES)
+               return NULL;
+       struct winthread *w = TlsGetValue(threadslot);
+
+       return w ? w->qry_ctx : NULL;
+}
+
 void
 MT_thread_setlockwait(MT_Lock *lock)
 {
@@ -338,16 +370,6 @@ MT_thread_override_limits(void)
        return w && w->working && strcmp(w->working, "store locked") == 0;
 }
 
-void *
-MT_thread_getdata(void)
-{
-       if (threadslot == TLS_OUT_OF_INDEXES)
-               return NULL;
-       struct winthread *w = TlsGetValue(threadslot);
-
-       return w ? w->data : NULL;
-}
-
 static void
 rm_winthread(struct winthread *w)
 {
@@ -566,6 +588,7 @@ static struct posthread {
        MT_Id mtid;
        ATOMIC_TYPE exited;
        bool detached:1, waiting:1;
+       QryCtx *qry_ctx;
 } *posthreads = NULL;
 static struct posthread mainthread = {
        .threadname = "main thread",
@@ -660,6 +683,27 @@ MT_thread_getdata(void)
 }
 
 void
+MT_thread_set_qry_ctx(QryCtx *ctx)
+{
+       if (!thread_initialized)
+               return;
+       struct posthread *p = pthread_getspecific(threadkey);
+
+       if (p)
+               p->qry_ctx = ctx;
+}
+
+QryCtx *
+MT_thread_get_qry_ctx(void)
+{
+       if (!thread_initialized)
+               return NULL;
+       struct posthread *p = pthread_getspecific(threadkey);
+
+       return p ? p->qry_ctx : NULL;
+}
+
+void
 MT_thread_setlockwait(MT_Lock *lock)
 {
        if (!thread_initialized)
diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h
--- a/gdk/gdk_system.h
+++ b/gdk/gdk_system.h
@@ -141,6 +141,12 @@ enum MT_thr_detach { MT_THR_JOINABLE, MT
 #define MT_NAME_LEN    32      /* length of thread/semaphore/etc. names */
 
 #define UNKNOWN_THREAD "unknown thread"
+typedef int64_t lng;
+
+typedef struct QryCtx {
+       lng starttime;
+       lng querytimeout;
+} QryCtx;
 
 gdk_export bool MT_thread_init(void);
 gdk_export int MT_create_thread(MT_Id *t, void (*function) (void *),
@@ -152,6 +158,8 @@ gdk_export void MT_thread_setdata(void *
 gdk_export void MT_exiting_thread(void);
 gdk_export MT_Id MT_getpid(void);
 gdk_export int MT_join_thread(MT_Id t);
+gdk_export QryCtx *MT_thread_get_qry_ctx(void);
+gdk_export void MT_thread_set_qry_ctx(QryCtx *ctx);
 
 #if SIZEOF_VOID_P == 4
 /* "limited" stack size on 32-bit systems */
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -463,6 +463,7 @@ str runMALsequence(Client cntxt, MalBlkP
        int     startedProfileQueue = 0;
 #define CHECKINTERVAL 1000 /* how often do we check for client disconnect */
        runtimeProfile.ticks = runtimeProfileFunction.ticks = 0;
+       QryCtx qry_ctx = {.starttime=mb->starttime, 
.querytimeout=cntxt->querytimeout};
 
        if (stk == NULL)
                throw(MAL, "mal.interpreter", MAL_STACK_FAIL);
@@ -515,6 +516,7 @@ str runMALsequence(Client cntxt, MalBlkP
        while (stkpc < mb->stop && stkpc != stoppc) {
                // incomplete block being executed, requires at least signature 
and end statement
                MT_thread_setalgorithm(NULL);
+               MT_thread_set_qry_ctx(&qry_ctx);
                pci = getInstrPtr(mb, stkpc);
                if (cntxt->mode == FINISHCLIENT){
                        stkpc = stoppc;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to