Update of /cvsroot/monetdb/MonetDB5/src/tools
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv32017

Modified Files:
        merovingian.mx monetdb.mx 
Log Message:
Fix buggyness: we don't have to close the pipe, instead we can just
ignore the EOF sent by the client.  Reopening the pipe can be just too
fast for the OS, resulting in an interrupt.


Index: merovingian.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/merovingian.mx,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- merovingian.mx      2 Sep 2007 16:14:07 -0000       1.38
+++ merovingian.mx      2 Sep 2007 17:28:42 -0000       1.39
@@ -874,60 +874,60 @@
        char *p;
        sabdb *stats;
 
-       while (_keepListening == 1) {
-               if ((f = fopen((char *)d, "r")) == NULL) {
-                       fprintf(stderr, "unable to open up control command 
channel "
-                                       "for reading: %s\n", strerror(errno));
-                       return;
-               }
+       if ((f = fopen((char *)d, "r")) == NULL) {
+               fprintf(stderr, "unable to open up control command channel "
+                               "for reading: %s\n", strerror(errno));
+               return;
+       }
 
-               /* Try to handle control signals.  We can get race conditions 
due to
-                * clients coming in at the same time.  We might need to fix 
this
-                * situation sometime. */
-               while (_keepListening == 1 && fgets(buf, 256, f) != NULL) {
-                       /* format is simple: database<space>command */
-                       if ((p = strchr(buf, ' ')) == NULL) {
-                               fprintf(stderr, "malformed control signal: 
%s\n", buf);
-                       } else {
-                               *p++ = '\0';
-                               if (strcmp(p, "start\n") == 0) {
-                                       merlog("starting database %s due to 
control signal",
-                                                       buf);
-                                       forkMserver(buf, &stats, 1);
-                                       if (stats != NULL)
-                                               SABAOTHfreeStatus(&stats);
-                               } else if (strcmp(p, "stop\n") == 0 ||
-                                               strcmp(p, "kill\n") == 0)
-                               {
-                                       /* we need to f ind the right dpair, 
that is we
-                                        * sort of assume the control signal is 
right */
-                                       dpair dp = topdp;
-                                       while (dp != NULL) {
-                                               if (strcmp(dp->dbname, buf) == 
0) {
-                                                       if (strcmp(p, "stop\n") 
== 0) {
-                                                               
merlog("stopping database %s due to control "
-                                                                               
"signal", buf);
-                                                               kill(dp->pid, 
SIGTERM);
-                                                       } else {
-                                                               merlog("killing 
database %s due to control "
-                                                                               
"signal", buf);
-                                                               kill(dp->pid, 
SIGKILL);
-                                                       }
-                                                       break;
+       /* Try to handle control signals.  We can get race conditions due to
+        * clients coming in at the same time.  We might need to fix this
+        * situation sometime. */
+       while (_keepListening == 1) {
+               if (fgets(buf, 256, f) == NULL)
+                       continue; /* ignore EOF */
+               /* format is simple: database<space>command */
+               if ((p = strchr(buf, ' ')) == NULL) {
+                       fprintf(stderr, "malformed control signal: %s\n", buf);
+               } else {
+                       *p++ = '\0';
+                       if (strcmp(p, "start\n") == 0) {
+                               merlog("starting database %s due to control 
signal",
+                                               buf);
+                               forkMserver(buf, &stats, 1);
+                               if (stats != NULL)
+                                       SABAOTHfreeStatus(&stats);
+                       } else if (strcmp(p, "stop\n") == 0 ||
+                                       strcmp(p, "kill\n") == 0)
+                       {
+                               /* we need to f ind the right dpair, that is we
+                                * sort of assume the control signal is right */
+                               dpair dp = topdp;
+                               while (dp != NULL) {
+                                       if (strcmp(dp->dbname, buf) == 0) {
+                                               if (strcmp(p, "stop\n") == 0) {
+                                                       merlog("stopping 
database %s due to control "
+                                                                       
"signal", buf);
+                                                       kill(dp->pid, SIGTERM);
+                                               } else {
+                                                       merlog("killing 
database %s due to control "
+                                                                       
"signal", buf);
+                                                       kill(dp->pid, SIGKILL);
                                                }
-                                               dp = dp->next;
-                                       }
-                                       if (dp == NULL) {
-                                               fprintf(stderr, "control stop 
signal for "
-                                                               "non-existing 
database: %s\n", buf);
+                                               break;
                                        }
-                               } else {
-                                       fprintf(stderr, "unknown control 
command: %s", p);
+                                       dp = dp->next;
                                }
+                               if (dp == NULL) {
+                                       fprintf(stderr, "control stop signal 
for "
+                                                       "non-existing database: 
%s\n", buf);
+                               }
+                       } else {
+                               fprintf(stderr, "unknown control command: %s", 
p);
                        }
                }
-               fclose(f);
        }
+       fclose(f);
        fprintf(stderr, "control channel closed\n");
 }
 

Index: monetdb.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/tools/monetdb.mx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- monetdb.mx  2 Sep 2007 15:13:51 -0000       1.22
+++ monetdb.mx  2 Sep 2007 17:28:42 -0000       1.23
@@ -489,7 +489,7 @@
                exit(1);
        }
 
-       if ((f = fopen(path, "a")) == NULL) {
+       if ((f = fopen(path, "w")) == NULL) {
                fprintf(stderr, "start: cannot write command: %s\n",
                                strerror(errno));
                exit(2);
@@ -594,7 +594,7 @@
                exit(1);
        }
 
-       if ((f = fopen(path, "a")) == NULL) {
+       if ((f = fopen(path, "w")) == NULL) {
                fprintf(stderr, "stop: cannot write command: %s\n",
                                strerror(errno));
                exit(2);


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to