Changeset: ed417790216c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ed417790216c
Modified Files:
        clients/ChangeLog.Dec2011
        clients/mapiclient/stethoscope.c
Branch: Dec2011
Log Message:

stethoscope: fix connecting without monetdbd

Make sure we can connect directly to mservers, and that we don't print
garbage if making a connection actually failed.  Fixes bug #2944.


diffs (90 lines):

diff --git a/clients/ChangeLog.Dec2011 b/clients/ChangeLog.Dec2011
--- a/clients/ChangeLog.Dec2011
+++ b/clients/ChangeLog.Dec2011
@@ -1,6 +1,10 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Wed Dec  7 2011 Fabian Groffen <[email protected]>
+- Fix making connections with stethoscope to hosts without monetdbd.
+  Bug #2944.
+
 * Tue Dec  6 2011 Fabian Groffen <[email protected]>
 - Fixed some bugs in the PHP interface affecting the mapi_ping(),
   monetdb_insert_id() and auto_commit() functions.  Bugs #2936, #2937,
diff --git a/clients/mapiclient/stethoscope.c b/clients/mapiclient/stethoscope.c
--- a/clients/mapiclient/stethoscope.c
+++ b/clients/mapiclient/stethoscope.c
@@ -238,6 +238,7 @@ doProfile(void *d)
        MapiHdl hdl = NULL;
 
        /* set up the profiler */
+       id[0] = '\0';
        dbh = mapi_mapiuri(wthr->uri, wthr->user, wthr->pass, "mal");
        if (dbh == NULL || mapi_error(dbh))
                die(dbh, hdl);
@@ -248,7 +249,6 @@ doProfile(void *d)
                snprintf(id, 10, "[%d] ", wthr->tid);
                printf("-- connection with server %s is %s\n", wthr->uri, id);
        } else {
-               id[0] = '\0';
                printf("-- connection with server %s\n", wthr->uri);
        }
 
@@ -437,7 +437,7 @@ main(int argc, char **argv)
                dbname = "";
        }
 
-       if (alts == NULL) {
+       if (alts == NULL || *alts == NULL) {
                /* nothing to redirect, so a single host to try */
                char uri[512];
                snprintf(uri, 512, "mapi:monetdb://%s:%d/%s", host, portnr, 
dbname);
@@ -465,31 +465,26 @@ main(int argc, char **argv)
        } else {
                /* fork runner threads for all alternatives */
                i = 1;
-               if (*alts != NULL) {
-                       walk = thds = malloc(sizeof(wthread));
-                       while (1) {
-                               walk->tid = i++;
-                               walk->uri = *alts;
-                               walk->user = user;
-                               walk->pass = password;
-                               walk->argc = argc - a;
-                               walk->argv = &argv[a];
-                               walk->s = NULL;
+               walk = thds = malloc(sizeof(wthread));
+               while (1) {
+                       walk->tid = i++;
+                       walk->uri = *alts;
+                       walk->user = user;
+                       walk->pass = password;
+                       walk->argc = argc - a;
+                       walk->argv = &argv[a];
+                       walk->s = NULL;
 #if !defined(HAVE_PTHREAD_H) && defined(_MSC_VER)
-                               walk->id = CreateThread(NULL, 0, doProfile, 
walk, 0, NULL);
+                       walk->id = CreateThread(NULL, 0, doProfile, walk, 0, 
NULL);
 #else
-                               pthread_create(&walk->id, NULL, &doProfile, 
walk);
+                       pthread_create(&walk->id, NULL, &doProfile, walk);
 #endif
-                               alts++;
-                               if (*alts == NULL)
-                                       break;
-                               walk = walk->next = malloc(sizeof(wthread));
-                       }
-                       walk->next = NULL;
-               } else {
-                       fprintf(stderr, "%s: no databases found for '%s'\n",
-                                       argv[0], dbname);
+                       alts++;
+                       if (*alts == NULL)
+                               break;
+                       walk = walk->next = malloc(sizeof(wthread));
                }
+               walk->next = NULL;
                free(oalts);
                for (walk = thds; walk != NULL; walk = walk->next) {
 #if !defined(HAVE_PTHREAD_H) && defined(_MSC_VER)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to