Changeset: b12acf09468e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b12acf09468e
Modified Files:
        tools/merovingian/ChangeLog.Aug2011
        tools/merovingian/daemon/forkmserver.c
Branch: Aug2011
Log Message:

forkMserver: stop waiting when server has already stopped

Slight improvement for the bad case scenario.  When a server terminates,
it serves no purpose to wait for 10 seconds before returning.  Just
return immediately with an error instead.


diffs (50 lines):

diff --git a/tools/merovingian/ChangeLog.Aug2011 
b/tools/merovingian/ChangeLog.Aug2011
--- a/tools/merovingian/ChangeLog.Aug2011
+++ b/tools/merovingian/ChangeLog.Aug2011
@@ -1,6 +1,10 @@
 # ChangeLog file for sql/src/backends/monet5/merovingian
 # This file is updated with mchangelog
 
+* Thu Oct  6 2011 Fabian Groffen <[email protected]>
+- Improved response time of 'monetdb start' when the database fails
+  to start.
+
 * Wed Oct  5 2011 Fabian Groffen <[email protected]>
 - Fixed a bug in monetdbd where starting a failing database could
   incorrectly be reported as a 'running but dead' database.
diff --git a/tools/merovingian/daemon/forkmserver.c 
b/tools/merovingian/daemon/forkmserver.c
--- a/tools/merovingian/daemon/forkmserver.c
+++ b/tools/merovingian/daemon/forkmserver.c
@@ -370,18 +370,29 @@ forkMserver(char *database, sabdb** stat
                                } while ((scen = scen->next) != NULL);
                                if (scen != NULL)
                                        break;
+                       } else {
+                               /* in the meanwhile, if the server has stopped, 
it will
+                                * have been removed from the dpair list, so 
check if
+                                * it's still there. */
+                               pthread_mutex_lock(&_mero_topdp_lock);
+                               dp = _mero_topdp;
+                               while (dp != NULL && dp->pid != pid)
+                                       dp = dp->next;
+                               pthread_mutex_unlock(&_mero_topdp_lock);
+                               if (dp == NULL)
+                                       break; /* server doesn't run, no need 
to wait any longer */
                        }
                }
                /* if we've never found a connection, try to figure out why */
-               if (i >= 20) {
+               if (i >= 20 || dp == NULL) {
                        int state = (*stats)->state;
                        int hasconn = (*stats)->conns != NULL && 
(*stats)->conns->val != NULL;
 
                        /* starting failed */
                        msab_freeStatus(stats);
 
-                       /* in the meanwhile the list may have changed so 
refetch the
-                        * parent and self */
+                       /* in the meanwhile the list may have changed (again) so
+                        * refetch dp */
                        pthread_mutex_lock(&_mero_topdp_lock);
                        dp = _mero_topdp;
                        while (dp != NULL && dp->pid != pid)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to