Changeset: 62ab26ccf4a5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=62ab26ccf4a5
Modified Files:
monetdb5/mal/mal.c
monetdb5/mal/mal_dataflow.c
monetdb5/mal/mal_private.h
Branch: Feb2013
Log Message:
Backported cleanup of dataflow threads on exit from default branch.
See changeset 3023eafdb017.
diffs (95 lines):
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -188,6 +188,7 @@ size_t monet_memory;
#include "mal_client.h"
#include "mal_sabaoth.h"
#include "mal_recycle.h"
+#include "mal_private.h"
MT_Lock mal_contextLock;
MT_Lock mal_namespaceLock;
@@ -291,6 +292,7 @@ void mal_exit(void){
*/
RECYCLEshutdown(mal_clients); /* remove any left over intermediates */
stopProfiling();
+ stopMALdataflow();
#if 0
{
int reruns=0, goon;
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
@@ -37,6 +37,7 @@
*/
#include "monetdb_config.h"
#include "mal_dataflow.h"
+#include "mal_private.h"
#define DFLOWpending 0 /* runnable */
#define DFLOWrunning 1 /* currently in progress */
@@ -89,6 +90,7 @@ static struct worker {
enum {IDLE, RUNNING, EXITED} flag;
} workers[THREADS];
static Queue *todo = 0; /* pending instructions */
+static int volatile exiting = 0;
/*
* Calculate the size of the dataflow dependency graph.
@@ -212,6 +214,8 @@ q_dequeue(Queue *q)
assert(q);
MT_sema_down(&q->s, "q_dequeue");
+ if (exiting)
+ return NULL;
MT_lock_set(&q->l, "q_dequeue");
if (q->exitcount > 0) {
q->exitcount--;
@@ -281,6 +285,9 @@ DFLOWworker(void *T)
break;;
} else
fe = fnxt;
+ if (exiting) {
+ break;
+ }
fnxt = 0;
assert(fe);
flow = fe->flow;
@@ -580,6 +587,8 @@ DFLOWscheduler(DataFlow flow)
while (actions != tasks ) {
f = q_dequeue(flow->done);
+ if (exiting)
+ break;
if (f == NULL)
throw(MAL, "dataflow", "DFLOWscheduler():
q_dequeue(flow->done) returned NULL");
@@ -752,3 +761,20 @@ runMALdataflow(Client cntxt, MalBlkPtr m
}
return msg;
}
+
+void
+stopMALdataflow(void)
+{
+ int i;
+
+ exiting = 1;
+ if (todo) {
+ for (i = 0; i < THREADS; i++)
+ MT_sema_up(&todo->s, "stopMALdataflow");
+ for (i = 0; i < THREADS; i++) {
+ if (workers[i].flag != IDLE)
+ MT_join_thread(workers[i].id);
+ workers[i].flag = IDLE;
+ }
+ }
+}
diff --git a/monetdb5/mal/mal_private.h b/monetdb5/mal/mal_private.h
--- a/monetdb5/mal/mal_private.h
+++ b/monetdb5/mal/mal_private.h
@@ -20,3 +20,4 @@
/* This file should not be included in any file outside of this directory */
extern void MCexitClient(Client c);
+extern void stopMALdataflow(void);
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list