Changeset: a292e4fab8f4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a292e4fab8f4
Modified Files:
        clients/mapiclient/tomograph.c
Branch: default
Log Message:

Handle error and last line in buffer


diffs (183 lines):

diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -494,13 +494,13 @@ struct COLOR{
        {0,0,"algebra","subselect","green"},
        {0,0,"algebra","*","lightgreen"},
 
-       {0,0,"bat","mirror","orange"},
-       {0,0,"bat","reverse","orange"},
+       //{0,0,"bat","mirror","orange"},
+       //{0,0,"bat","reverse","orange"},
        {0,0,"bat","*","orange"},
 
-       {0,0,"batcalc","-","moccasin"},
-       {0,0,"batcalc","*","moccasin"},
-       {0,0,"batcalc","+","moccasin"},
+       //{0,0,"batcalc","-","moccasin"},
+       //{0,0,"batcalc","*","moccasin"},
+       //{0,0,"batcalc","+","moccasin"},
        {0,0,"batcalc","dbl","papayawhip"},
        {0,0,"batcalc","str","papayawhip"},
        {0,0,"batcalc","*","lightyellow"},
@@ -643,8 +643,8 @@ static void showmemory(void)
        fprintf(gnudata,"unset xtics\n");
        mn = (long) (min/1024.0);
        mx = (long) (max/1024.0);
-       mx += (mn == mx);
-       fprintf(gnudata,"set yrange [%ld:%ld]\n", mn, (long)(1.1 * mx));
+       mx += (mn == mx)+1;
+       fprintf(gnudata,"set yrange [%ld:%ld]\n", mn, (long)mx);
        fprintf(gnudata,"set ytics (\"%.1f\" %ld, \"%.1f\" %ld)\n", min 
/1024.0, mn, max/1024.0, mx);
        fprintf(gnudata,"plot \"%s.dat\" using 1:2 notitle with dots linecolor 
rgb \"blue\"\n",(tracefile?"scratch":filename));
        fprintf(gnudata,"unset yrange\n");
@@ -1132,7 +1132,7 @@ static void update(int state, int thread
        }
 }
 
-static void parser(char *row){
+static int parser(char *row){
 #ifdef HAVE_STRPTIME
        char *c;
     struct tm stm;
@@ -1145,10 +1145,10 @@ static void parser(char *row){
        long reads, writes;
 
        if (row[0] != '[')
-               return;
+               return -1;
        c= strchr(row,(int)'"');
        if ( c == 0)
-               return;
+               return -2;
        if (strncmp(c+1,"start",5) == 0) {
                state = 0;
                c += 6;
@@ -1172,7 +1172,7 @@ static void parser(char *row){
                c = strptime(c+1,"%H:%M:%S", &stm);
                clkticks = (((long)(stm.tm_hour * 60) + stm.tm_min) * 60 + 
stm.tm_sec) * 1000000;
                if ( c == 0)
-                       return;
+                       return -11;
                if (  *c == '.') {
                        long usec;
                        /* microseconds */
@@ -1181,46 +1181,45 @@ static void parser(char *row){
                        clkticks += usec;
                }
                c = strchr(c+1, (int)'"');
-       } else return;
+       } else return -3;
 
        c = strchr(c+1, (int)',');
        if ( c == 0)
-               return;
+               return -4 ;
        thread = atoi(c+1);
        c = strchr(c+1, (int)',');
        if ( c == 0)
-               return;
+               return -5;
        ticks = atol(c+1);
        c = strchr(c+1, (int)',');
        if ( c == 0)
-               return;
+               return -6;
        memory = atol(c+1);
        c = strchr(c+1, (int)',');
+       if ( debug && state != 4)
+               fprintf(stderr,"%s\n",row);
        if ( c == 0)
-               return;
+               return state== 4? 0:-7;
        reads = atol(c+1);
        c = strchr(c+1, (int)',');
        if ( c == 0)
-               return;
+               return -8;
        writes = atol(c+1);
 
        c = strchr(c+1, (int)',');
        if ( c == 0)
-               return;
+               return -9;
        c++;
        fcn = c;
        stmt = strdup(fcn);
 
-       if ( debug)
-               fprintf(stderr,"%s\n",row);
-
        c = strstr(c+1, ":=");
        if ( c ){
                fcn = c+2;
                /* find genuine function calls */
                while ( isspace((int) *fcn) && *fcn) fcn++;
                if ( strchr(fcn, (int) '.') == 0)
-                       return;
+                       return -10;
        } else {
                fcn =strchr(fcn,(int)'"');
                if ( fcn ){
@@ -1236,6 +1235,7 @@ static void parser(char *row){
 #else
        (void) row;
 #endif
+       return 0;
 }
 
 static void
@@ -1295,9 +1295,6 @@ doRequest(Mapi mid, const char *buf)
 
        format_result(mid, hdl);
 
-       //if (mapi_get_active(mid) == NULL)
-               //mapi_close_handle(hdl);
-       fprintf(stderr, "  -t | --trace=<filename>\n");
        return 0;
 }
 
@@ -1309,7 +1306,7 @@ static void *
 doProfile(void *d)
 {
        wthread *wthr = (wthread*)d;
-       int i;
+       int i,len;
        size_t a;
        ssize_t n;
        char *response, *x;
@@ -1448,23 +1445,25 @@ doProfile(void *d)
        if ( sqlstatement) {
                doRequest(dbhsql, sqlstatement);
        }
-       i = 0;
-       while ((n = mnstr_read(wthr->s, buf, 1, BUFSIZ)) > 0) {
+       len = 0;
+       while ((n = mnstr_read(wthr->s, buf, 1, BUFSIZ-len)) > 0) {
                buf[n] = 0;
                response = buf;
                while ((e = strchr(response, '\n')) != NULL) {
                        *e = 0;
                        /* TOMOGRAPH EXTENSIONS */
-                       parser(response);
+                       i = parser(response);
+                       if ( debug && i )
+                               fprintf(stderr,"ERROR %d:%s\n",i,response);
                        response = e + 1;
                }
                /* handle last line in buffer */
-               if ( *response)
-                       printf("%s",response);
-               if (++i % 200) {
-                       i = 0;
-                       fflush(NULL);
-               }
+               if ( *response) {
+                       if ( debug) 
+                               printf("LASTLINE:%s",response);
+                       len = strlen(response);
+                       strncpy(buf,response, len+1);
+               } else len = 0;
        }
        fflush(NULL);
 
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to