Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11752
Modified Files:
mal_box.mx mal_client.mx mal_session.mx
Log Message:
The box initialization routine does not need a separate thread,
only a private Client context. Otherwise raise conditions arrise
to manage the client record.
This patch may resolve some spurious errors
Index: mal_client.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_client.mx,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -d -r1.151 -r1.152
--- mal_client.mx 2 Jun 2007 09:55:35 -0000 1.151
+++ mal_client.mx 2 Jun 2007 21:17:37 -0000 1.152
@@ -342,7 +342,7 @@
GDKfree(x);
}
-Client MCnewClient(){
+static Client MCnewClient(){
Client c;
if( mal_clients[CONSOLE].user)
GDKprotect();
@@ -443,7 +443,6 @@
prompt = !fin? GDKgetenv("monet_prompt"): PROMPT1;
c->prompt= GDKstrdup(prompt);
c->promptlength= strlen(prompt);
- if( isAdministrator(c)) MCinitClientThread(c);
return c;
}
@-
@@ -460,10 +459,10 @@
t= c->mythread;
} else
*/
- snprintf(cname, 11, SZFMT, (size_t)(c->user));
- cname[11] = '\0';
- c->mypid = MT_getpid();
- c->mythread = t = THRnew(c->mypid,cname);
+ snprintf(cname, 11, SZFMT, (size_t)(c->user));
+ cname[11] = '\0';
+ c->mypid = MT_getpid();
+ c->mythread = t = THRnew(c->mypid,cname);
c->errbuf = GDKerrbuf;
if (c->errbuf == NULL) {
GDKsetbuf( GDKmalloc(GDKMAXERRLEN));
@@ -669,7 +668,9 @@
work by closing them.
@c
void MCkillClient(Client c, int timeout) {
+ size_t pid;
if (c && c->user != oid_nil ) {
+ mal_set_lock(mal_contextLock, "stopClient");
#ifdef MAL_DEBUG_CLIENT
printf("killClient %d\n", c - mal_clients);
@@ -692,11 +693,18 @@
c->fdin = NULL;
assert(c->bak == NULL);
/* GDKwarning("killClient:about to kill process
...\n");*/
+ pid= c->mythread->pid;
+ c->mythread->pid=0;
+ c->mode= FREECLIENT;
+ mal_unset_lock(mal_contextLock, "stopClient");
MT_sleep_ms(1000 * timeout);
- MT_kill_thread(c->mythread->pid);
+ MT_kill_thread(pid);
MT_sleep_ms(1000 * timeout);
/*GDKwarning("killClient:process killed\n");*/
+ return;
}
+ c->mode= FREECLIENT;
+ mal_unset_lock(mal_contextLock, "stopClient");
}
}
@@ -748,11 +756,9 @@
if( ! isAdministrator(c))
throw(PERMD, "stop","Only permitted from server console");
- mal_set_lock(mal_contextLock, "stopClient");
for(c = mal_clients; c < mal_clients+MAL_MAXCLIENTS; c++) {
if (c->mode > FREECLIENT && c->user == which) {
MCkillClient(c, PROCESSTIMEOUT);
- mal_unset_lock(mal_contextLock, "stopClient");
return MAL_SUCCEED;
}
}
Index: mal_session.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_session.mx,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -d -r1.136 -r1.137
--- mal_session.mx 5 May 2007 14:56:35 -0000 1.136
+++ mal_session.mx 2 Jun 2007 21:17:37 -0000 1.137
@@ -79,6 +79,7 @@
if (bf)
bootfile = bf;
MSinitClientPrg(c,"user", "main");
+ MCinitClientThread(c);
malInclude(c, bootfile, 0);
pushEndInstruction(c->curprg->def);
trimMalBlk(c->curprg->def);
Index: mal_box.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_box.mx,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- mal_box.mx 16 May 2007 21:20:08 -0000 1.76
+++ mal_box.mx 2 Jun 2007 21:17:37 -0000 1.77
@@ -721,12 +721,14 @@
#endif
if (access(boxfile, R_OK) == 0) {
Client child= MCforkClient(MCgetClient());
- defaultScenario(child);
- evalFile(child, boxfile, 0);
- MCkillClient(child,2);
+ if( child != MCgetClient()){
+ defaultScenario(child);
+ evalFile(child, boxfile, 0);
+ MCkillClient(child,0);
#ifdef DEBUG_MAL_BOX
- stream_printf(GDKout, "loadBox:loaded the file %s\n", boxfile);
+ stream_printf(GDKout, "loadBox:loaded the file %s\n",
boxfile);
#endif
+ }
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins