Changeset: 4f9a66211926 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4f9a66211926 Modified Files: clients/Tests/exports.stable.out gdk/gdk_utils.c gdk/gdk_utils.h monetdb5/mal/mal.c monetdb5/mal/mal.h monetdb5/mal/mal_client.c monetdb5/mal/mal_debugger.c monetdb5/mal/mal_namespace.c monetdb5/mal/mal_session.c monetdb5/modules/mal/clients.c tools/mserver/mserver5.c tools/mserver/shutdowntest.c Branch: default Log Message:
Avoid calling exit in the reset functions. mal_exit now has status arg. diffs (279 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 @@ -277,7 +277,7 @@ void *GDKrealloc(void *pold, size_t size void GDKregister(MT_Id pid); gdk_return GDKreleasemmap(void *ptr, size_t size, size_t id); gdk_return GDKreleasesem(int sem_id); -void GDKreset(int status, int exit); +void GDKreset(int status); gdk_return GDKsetenv(const char *name, const char *value); void GDKsetmallocsuccesscount(lng count); ssize_t GDKstrFromStr(unsigned char *restrict dst, const unsigned char *restrict src, ssize_t len); @@ -2374,7 +2374,7 @@ MT_Lock mal_contextLock; MT_Lock mal_copyLock; void mal_dataflow_reset(void) __attribute__((__visibility__("hidden"))); MT_Lock mal_delayLock; -void mal_exit(void); +void mal_exit(int status); void mal_factory_reset(void) __attribute__((__visibility__("hidden"))); int mal_init(void); void mal_instruction_reset(void); @@ -2453,7 +2453,7 @@ char *msab_registerStop(void); char *msab_retreatScenario(const char *lang); char *msab_serialise(char **ret, const sabdb *db); char *msab_wildRetreat(void); -void mserver_reset(int exit); +void mserver_reset(void); str mtimeRef; str mulRef; str multicolumnRef; diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c --- a/gdk/gdk_utils.c +++ b/gdk/gdk_utils.c @@ -734,7 +734,7 @@ GDKregister(MT_Id pid) } void -GDKreset(int status, int exit) +GDKreset(int status) { MT_Id pid = MT_getpid(); Thread t, s; @@ -861,11 +861,6 @@ GDKreset(int status, int exit) MT_lock_destroy(&mallocsuccesslock); #endif #endif -#ifndef HAVE_EMBEDDED - if (exit) { - MT_global_exit(status); - } -#endif } /* coverity[+kill] */ @@ -881,9 +876,9 @@ GDKexit(int status) #endif } GDKprepareExit(); - GDKreset(status, 1); + GDKreset(status); #ifndef HAVE_EMBEDDED - MT_exit_thread(-1); + exit(status); #endif } diff --git a/gdk/gdk_utils.h b/gdk/gdk_utils.h --- a/gdk/gdk_utils.h +++ b/gdk/gdk_utils.h @@ -95,7 +95,7 @@ gdk_export bool GDKexiting(void); gdk_export void GDKregister(MT_Id pid); gdk_export void GDKprepareExit(void); -gdk_export void GDKreset(int status, int exit); +gdk_export void GDKreset(int status); gdk_export const char *GDKversion(void); gdk_export gdk_return GDKextractParentAndLastDirFromPath(const char *path, char *last_dir_parent, char *last_dir); diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c --- a/monetdb5/mal/mal.c +++ b/monetdb5/mal/mal.c @@ -93,7 +93,7 @@ int mal_init(void){ */ void cleanOptimizerPipe(void); -void mserver_reset(int exit) +void mserver_reset(void) { str err = 0; @@ -152,7 +152,7 @@ void mserver_reset(int exit) mal_namespace_reset(); /* No need to clean up the namespace, it will simply be extended * upon restart mal_namespace_reset(); */ - GDKreset(0, exit); // terminate all other threads + GDKreset(0); // terminate all other threads } @@ -166,7 +166,8 @@ void mserver_reset(int exit) * Beware, mal_exit is also called during a SIGTERM from the monetdb tool */ -void mal_exit(void){ - mserver_reset(1); - GDKexit(0); /* properly end GDK */ +void mal_exit(int status) +{ + mserver_reset(); + exit(status); /* properly end GDK */ } diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h --- a/monetdb5/mal/mal.h +++ b/monetdb5/mal/mal.h @@ -84,8 +84,8 @@ mal_export MT_Lock mal_oltpLock ; mal_export int mal_init(void); -mal_export void mal_exit(void); -mal_export void mserver_reset(int exit); +mal_export void mal_exit(int status); +mal_export void mserver_reset(void); /* This should be here, but cannot, as "Client" isn't known, yet ... |-( * For now, we move the prototype declaration to src/mal/mal_client.c, 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 @@ -73,7 +73,7 @@ MCinit(void) maxclients = 64; if (GDKsetenv("max_clients", "64") != GDK_SUCCEED) { fprintf(stderr,"#MCinit: GDKsetenv failed"); - mal_exit(); + mal_exit(1); } } @@ -83,7 +83,7 @@ MCinit(void) mal_clients = GDKzalloc(sizeof(ClientRec) * MAL_MAXCLIENTS); if( mal_clients == NULL){ fprintf(stderr,"#MCinit:" MAL_MALLOC_FAIL); - mal_exit(); + mal_exit(1); } } @@ -501,7 +501,7 @@ MCcloseClient(Client c) /* adm is set to disallow new clients entering */ mal_clients[CONSOLE].mode = FINISHCLIENT; - mal_exit(); + mal_exit(0); } str diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c --- a/monetdb5/mal/mal_debugger.c +++ b/monetdb5/mal/mal_debugger.c @@ -72,7 +72,7 @@ mdbInit(void) mdbTable = GDKzalloc(sizeof(mdbStateRecord) * MAL_MAXCLIENTS); if (mdbTable == NULL) { fprintf(stderr,"#mdbInit:" MAL_MALLOC_FAIL); - mal_exit(); + mal_exit(1); } } diff --git a/monetdb5/mal/mal_namespace.c b/monetdb5/mal/mal_namespace.c --- a/monetdb5/mal/mal_namespace.c +++ b/monetdb5/mal/mal_namespace.c @@ -120,7 +120,7 @@ static str findName(const char *nme, siz if (ns == NULL) { /* error we cannot recover from */ showException(GDKout, MAL, "findName", SQLSTATE(HY001) MAL_MALLOC_FAIL); - mal_exit(); + mal_exit(1); } ns->next = namespace; ns->count = 0; 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 @@ -42,33 +42,33 @@ malBootstrap(void) c = MCinitClient((oid) 0, 0, 0); if(c == NULL) { fprintf(stderr,"#malBootstrap:Failed to initialise client"); - mal_exit(); + mal_exit(1); } assert(c != NULL); c->curmodule = c->usermodule = userModule(); if(c->usermodule == NULL) { fprintf(stderr,"#malBootstrap:Failed to initialise client MAL module"); - mal_exit(); + mal_exit(1); } if ( (msg = defaultScenario(c)) ) { fprintf(stderr,"#malBootstrap:Failed to initialise default scenario: %s", msg); freeException(msg); - mal_exit(); + mal_exit(1); } if((msg = MSinitClientPrg(c, "user", "main")) != MAL_SUCCEED) { fprintf(stderr,"#malBootstrap:Failed to initialise client: %s", msg); freeException(msg); - mal_exit(); + mal_exit(1); } if( MCinitClientThread(c) < 0){ fprintf(stderr,"#malBootstrap:Failed to create client thread"); - mal_exit(); + mal_exit(1); } s = malInclude(c, bootfile, 0); if (s != NULL) { fprintf(stderr, "!%s\n", s); GDKfree(s); - mal_exit(); + mal_exit(1); } pushEndInstruction(c->curprg->def); chkProgram(c->usermodule, c->curprg->def); diff --git a/monetdb5/modules/mal/clients.c b/monetdb5/modules/mal/clients.c --- a/monetdb5/modules/mal/clients.c +++ b/monetdb5/modules/mal/clients.c @@ -601,7 +601,7 @@ CLTshutdown(Client cntxt, MalBlkPtr mb, snprintf(buf, 1024,"%d client sessions still running",leftover); *ret = GDKstrdup(buf); if ( force) - mal_exit(); + mal_exit(0); if(*ret == NULL) throw(MAL, "mal.shutdown", SQLSTATE(HY001) MAL_MALLOC_FAIL); return MAL_SUCCEED; diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c --- a/tools/mserver/mserver5.c +++ b/tools/mserver/mserver5.c @@ -232,7 +232,7 @@ static void handler(int sig) { (void) sig; - mal_exit(); + mal_exit(-1); } int @@ -674,7 +674,7 @@ main(int argc, char **av) /* check for internal exception message to terminate */ if (msg) { if (strcmp(msg, "MALException:client.quit:Server stopped.") == 0) - mal_exit(); + mal_exit(0); fprintf(stderr, "#%s: %s\n", monet_script[i], msg); freeException(msg); } @@ -697,9 +697,9 @@ main(int argc, char **av) while (1) MT_sleep_ms(5000); - /* mal_exit calls MT_global_exit, so statements after this call will + /* mal_exit calls exit, so statements after this call will * never get reached */ - mal_exit(); + mal_exit(0); return 0; } diff --git a/tools/mserver/shutdowntest.c b/tools/mserver/shutdowntest.c --- a/tools/mserver/shutdowntest.c +++ b/tools/mserver/shutdowntest.c @@ -302,7 +302,7 @@ cleanup: static void monetdb_shutdown(void) { if (monetdb_initialized) { - mserver_reset(0); + mserver_reset(); monetdb_initialized = 0; } } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list