Changeset: e47866950925 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e47866950925
Modified Files:
        monetdb5/mal/mal.c
        monetdb5/mal/mal_client.c
        monetdb5/modules/mal/clients.c
        monetdb5/optimizer/opt_mitosis.c
Branch: default
Log Message:

Avoid division by zero
Execution of a sql command in the mserver console could
render a crash in the mitosis optimizer.


diffs (48 lines):

diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -126,7 +126,7 @@ void mal_exit(void){
 {
        int reruns=0, go_on;
        do{
-               if ( (go_on = MCactiveClients()) )
+               if ( (go_on = MCactiveClients() -1) )
                        MT_sleep_ms(1000);
                mnstr_printf(mal_clients->fdout,"#MALexit: %d clients still 
active\n", go_on);
        } while (++reruns < SERVERSHUTDOWNDELAY && go_on > 1);
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
@@ -447,7 +447,7 @@ MCactiveClients(void)
                running += (cntxt->mode == RUNCLIENT);
                blocked += (cntxt->mode == BLOCKCLIENT);
        }
-       return finishing+running;
+       return finishing+running +1 /* the admin */;
 }
 
 void
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
@@ -561,7 +561,7 @@ CLTshutdown(Client cntxt, MalBlkPtr mb, 
                throw(MAL,"mal.shutdown", "Administrator rights required");
        MCstopClients(cntxt);
        do{
-               if ( (leftover = MCactiveClients()) )
+               if ( (leftover = MCactiveClients()-1) )
                        MT_sleep_ms(1000);
                delay --;
        } while (delay > 0 && leftover > 1);
diff --git a/monetdb5/optimizer/opt_mitosis.c b/monetdb5/optimizer/opt_mitosis.c
--- a/monetdb5/optimizer/opt_mitosis.c
+++ b/monetdb5/optimizer/opt_mitosis.c
@@ -127,6 +127,8 @@ OPTmitosisImplementation(Client cntxt, M
        /* if data exceeds memory size,
         * i.e., (rowcnt*argsize > monet_memory),
         * i.e., (rowcnt > monet_memory/argsize = m) */
+       assert(threads > 0);
+       assert(activeClients > 0);
        if (rowcnt > m && m / threads / activeClients > 0) {
                /* create |pieces| > |threads| partitions such that
                 * |threads| partitions at a time fit in memory,
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to