Changeset: 699b18e827e4 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/699b18e827e4 Modified Files: clients/Tests/exports.stable.out monetdb5/mal/mal.c monetdb5/mal/mal_authorize.c monetdb5/mal/mal_client.c monetdb5/mal/mal_dataflow.c monetdb5/mal/mal_embedded.c monetdb5/mal/mal_import.c monetdb5/mal/mal_internal.h monetdb5/mal/mal_interpreter.c monetdb5/mal/mal_interpreter.h monetdb5/mal/mal_private.h monetdb5/mal/mal_session.c monetdb5/modules/mal/tablet.c sql/backends/monet5/sql.c sql/server/rel_schema.c sql/server/sql_mvc.c Branch: default Log Message:
merged with Sep2022 diffs (truncated from 407 to 300 lines): diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out --- a/clients/Tests/exports.stable.out +++ b/clients/Tests/exports.stable.out @@ -945,7 +945,6 @@ int getBitConstant(MalBlkPtr mb, bit val int getBlockBegin(MalBlkPtr mb, int pc); int getBlockExit(MalBlkPtr mb, int pc); int getBteConstant(MalBlkPtr mb, bte val); -Client getClientContext(void); int getDblConstant(MalBlkPtr mb, dbl val); str getExceptionMessage(const char *); str getExceptionMessageAndState(const char *); diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c --- a/monetdb5/mal/mal.c +++ b/monetdb5/mal/mal.c @@ -43,93 +43,6 @@ MT_Lock mal_copyLock = MT_LOCK_INITI MT_Lock mal_delayLock = MT_LOCK_INITIALIZER(mal_delayLock); - -#ifdef HAVE_PTHREAD_H - -static pthread_key_t tl_client_key; - -static int -initialize_tl_client_key(void) -{ - static bool initialized = false; - if (initialized) - return 0; - - if (pthread_key_create(&tl_client_key, NULL) != 0) - return -1; - - initialized = true; - return 0; -} - -/* declared in mal_interpreter.h so MAL operators can access it */ -Client -getClientContext(void) -{ - if (initialize_tl_client_key()) - return NULL; - return (Client) pthread_getspecific(tl_client_key); -} - -/* declared in mal_private.h so only the MAL interpreter core can access it */ -Client -setClientContext(Client cntxt) -{ - Client old = getClientContext(); - - if (pthread_setspecific(tl_client_key, cntxt) != 0) - GDKfatal("Failed to set thread local Client context"); - - return old; -} - -#elif defined(WIN32) - -static DWORD tl_client_key = 0; - -static int -initialize_tl_client_key(void) -{ - static bool initialized = false; - if (initialized) - return 0; - - DWORD key = TlsAlloc(); - if (key == TLS_OUT_OF_INDEXES) - return -1; - - tl_client_key = key; - initialized = true; - return 0; -} - -/* declared in mal_interpreter.h so MAL operators can access it */ -Client -getClientContext(void) -{ - if (initialize_tl_client_key()) - return NULL; - return (Client) TlsGetValue(tl_client_key); -} - -/* declared in mal_private.h so only the MAL interpreter core can access it */ -Client -setClientContext(Client cntxt) -{ - Client old = getClientContext(); - - if (TlsSetValue(tl_client_key, cntxt) == 0) - GDKfatal("Failed to set thread local Client context"); - - return old; -} - -#else - -#error "no pthreads and no Win32, don't know what to do" - -#endif - const char * mal_version(void) { @@ -160,9 +73,6 @@ mal_init(char *modules[], bool embedded, return -1; } - if (initialize_tl_client_key() != 0) - return -1; - if (!MCinit()) return -1; #ifndef NDEBUG diff --git a/monetdb5/mal/mal_client.c b/monetdb5/mal/mal_client.c --- a/monetdb5/mal/mal_client.c +++ b/monetdb5/mal/mal_client.c @@ -292,9 +292,6 @@ MCinitClient(oid user, bstream *fin, str MT_lock_set(&mal_contextLock); c = MCnewClient(); if (c) { - Client c_old = setClientContext(c); - (void) c_old; - assert(NULL == c_old); c = MCinitClientRecord(c, user, fin, fout); MT_thread_set_qry_ctx(&c->qryctx); } @@ -428,7 +425,6 @@ MCcloseClient(Client c) c->sqlprofiler = 0; free(c->handshake_options); c->handshake_options = NULL; - setClientContext(NULL); MT_thread_set_qry_ctx(NULL); assert(c->qryctx.datasize == 0); MT_sema_destroy(&c->s); diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c --- a/monetdb5/mal/mal_dataflow.c +++ b/monetdb5/mal/mal_dataflow.c @@ -314,7 +314,6 @@ DFLOWworker(void *T) cntxt = ATOMIC_PTR_GET(&t->cntxt); while (1) { MT_thread_set_qry_ctx(NULL); - setClientContext(NULL); if (fnxt == 0) { MT_thread_setworking(NULL); cntxt = ATOMIC_PTR_GET(&t->cntxt); @@ -345,7 +344,6 @@ DFLOWworker(void *T) flow = fe->flow; assert(flow); MT_thread_set_qry_ctx(flow->set_qry_ctx ? &flow->cntxt->qryctx : NULL); - setClientContext(flow->cntxt); /* whenever we have a (concurrent) error, skip it */ if (ATOMIC_PTR_GET(&flow->error)) { diff --git a/monetdb5/mal/mal_embedded.c b/monetdb5/mal/mal_embedded.c --- a/monetdb5/mal/mal_embedded.c +++ b/monetdb5/mal/mal_embedded.c @@ -46,7 +46,7 @@ static bool embeddedinitialized = false; str malEmbeddedBoot(int workerlimit, int memorylimit, int querytimeout, int sessiontimeout, bool with_mapi_server) { - Client c, c_old; + Client c; QryCtx *qc_old; str msg = MAL_SUCCEED; @@ -99,7 +99,6 @@ malEmbeddedBoot(int workerlimit, int mem initNamespace(); initHeartbeat(); // initResource(); - c_old = setClientContext(NULL); //save context qc_old = MT_thread_get_qry_ctx(); c = MCinitClient((oid) 0, 0, 0); if(c == NULL) @@ -111,26 +110,22 @@ malEmbeddedBoot(int workerlimit, int mem c->curmodule = c->usermodule = userModule(); if(c->usermodule == NULL) { MCcloseClient(c); - setClientContext(c_old); // restore context MT_thread_set_qry_ctx(qc_old); throw(MAL, "malEmbeddedBoot", "Failed to initialize client MAL module"); } if ( (msg = defaultScenario(c)) ) { MCcloseClient(c); - setClientContext(c_old); // restore context MT_thread_set_qry_ctx(qc_old); return msg; } if ((msg = MSinitClientPrg(c, "user", "main")) != MAL_SUCCEED) { MCcloseClient(c); - setClientContext(c_old); // restore context MT_thread_set_qry_ctx(qc_old); return msg; } char *modules[5] = { "embedded", "sql", "generator", "udf" }; if ((msg = malIncludeModules(c, modules, 0, !with_mapi_server, NULL)) != MAL_SUCCEED) { MCcloseClient(c); - setClientContext(c_old); // restore context MT_thread_set_qry_ctx(qc_old); return msg; } @@ -138,7 +133,6 @@ malEmbeddedBoot(int workerlimit, int mem msg = chkProgram(c->usermodule, c->curprg->def); if ( msg != MAL_SUCCEED || (msg= c->curprg->def->errors) != MAL_SUCCEED ) { MCcloseClient(c); - setClientContext(c_old); // restore context MT_thread_set_qry_ctx(qc_old); return msg; } @@ -146,7 +140,6 @@ malEmbeddedBoot(int workerlimit, int mem if (msg == MAL_SUCCEED) embeddedinitialized = true; MCcloseClient(c); - setClientContext(c_old); // restore context MT_thread_set_qry_ctx(qc_old); initProfiler(); return msg; diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c --- a/monetdb5/mal/mal_import.c +++ b/monetdb5/mal/mal_import.c @@ -276,7 +276,7 @@ mal_cmdline(char *s, size_t *len) str compileString(Symbol *fcn, Client cntxt, str s) { - Client c, c_old; + Client c; QryCtx *qc_old; size_t len = strlen(s); buffer *b; @@ -316,14 +316,12 @@ compileString(Symbol *fcn, Client cntxt, } strncpy(fdin->buf, qry, len+1); - c_old = setClientContext(NULL); // save context qc_old = MT_thread_get_qry_ctx(); // compile in context of called for c = MCinitClient(MAL_ADMIN, fdin, 0); if( c == NULL){ GDKfree(qry); GDKfree(b); - setClientContext(c_old); // restore context MT_thread_set_qry_ctx(qc_old); throw(MAL,"mal.eval","Can not create user context"); } @@ -336,7 +334,6 @@ compileString(Symbol *fcn, Client cntxt, GDKfree(b); c->usermodule= 0; MCcloseClient(c); - setClientContext(c_old); // restore context MT_thread_set_qry_ctx(qc_old); return msg; } @@ -352,7 +349,6 @@ compileString(Symbol *fcn, Client cntxt, c->usermodule= 0; /* restore IO channel */ MCcloseClient(c); - setClientContext(c_old); // restore context MT_thread_set_qry_ctx(qc_old); GDKfree(qry); GDKfree(b); diff --git a/monetdb5/mal/mal_internal.h b/monetdb5/mal/mal_internal.h --- a/monetdb5/mal/mal_internal.h +++ b/monetdb5/mal/mal_internal.h @@ -16,8 +16,6 @@ void setqptimeout(lng usecs) __attribute__((__visibility__("hidden"))); -Client setClientContext(Client cntxt) - __attribute__((__visibility__("hidden"))); extern size_t qsize; diff --git a/monetdb5/mal/mal_interpreter.h b/monetdb5/mal/mal_interpreter.h --- a/monetdb5/mal/mal_interpreter.h +++ b/monetdb5/mal/mal_interpreter.h @@ -32,9 +32,6 @@ mal_export str callMAL(Client cntxt, Mal mal_export void garbageElement(Client cntxt, ValPtr v); mal_export void garbageCollector(Client cntxt, MalBlkPtr mb, MalStkPtr stk, int flag); -/* defined in mal.c */ -mal_export Client getClientContext(void); - mal_export ptr getArgReference(MalStkPtr stk, InstrPtr pci, int k); #if !defined(NDEBUG) && defined(__GNUC__) /* for ease of programming and debugging (assert reporting a useful diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c --- a/monetdb5/mal/mal_session.c +++ b/monetdb5/mal/mal_session.c @@ -214,7 +214,6 @@ MSscheduleClient(str command, str challe Client c; MT_thread_set_qry_ctx(NULL); - setClientContext(NULL); /* decode BIG/LIT:user:{cypher}passwordchal:lang:database: line */ _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org