Changeset: 8b415a9bf8e4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/8b415a9bf8e4
Modified Files:
        monetdb5/mal/mal_profiler.c
Branch: default
Log Message:

changed some locks, should fix parsing issues with stethoscope


diffs (72 lines):

diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -65,14 +65,12 @@ static void logjsonInternal(char *logbuf
        size_t len;
        len = strlen(logbuffer);
 
-       MT_lock_set(&mal_profileLock);
        if (maleventstream) {
        // upon request the log record is sent over the profile stream
                (void) mnstr_write(maleventstream, logbuffer, 1, len);
                if (flush)
                        (void) mnstr_flush(maleventstream, MNSTR_FLUSH_DATA);
        }
-       MT_lock_unset(&mal_profileLock);
 }
 
 /*
@@ -475,11 +473,13 @@ static void
 renderProfilerEvent(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, 
int start)
 {
        str ev;
+       MT_lock_set(&mal_profileLock);
        ev = prepareProfilerEvent(cntxt, mb, stk, pci, start);
        if( ev ){
                logjsonInternal(ev, true);
                free(ev);
        }
+       MT_lock_unset(&mal_profileLock);
 }
 
 /* the OS details on cpu load are read from /proc/stat
@@ -648,16 +648,19 @@ openProfilerStream(Client cntxt)
        getrusage(RUSAGE_SELF, &infoUsage);
        prevUsage = infoUsage;
 #endif
+       MT_lock_set(&mal_profileLock);
        if (myname == 0){
                myname = putName("profiler");
                logjsonInternal(monet_characteristics, true);
        }
        if(maleventstream){
                /* The DBA can always grab the stream, others have to wait */
-               if (cntxt->user == MAL_ADMIN)
+               if (cntxt->user == MAL_ADMIN) {
                        closeProfilerStream(cntxt);
-               else
+               } else {
+                       MT_lock_unset(&mal_profileLock);
                        throw(MAL,"profiler.start","Profiler already running, 
stream not available");
+               }
        }
        malProfileMode = -1;
        maleventstream = cntxt->fdout;
@@ -671,7 +674,6 @@ openProfilerStream(Client cntxt)
 
        MT_sleep_ms(200);
 
-       MT_lock_set(&mal_profileLock);
        for(j = 0; j <THREADS; j++){
                Client c = 0; MalBlkPtr m=0; MalStkPtr s = 0; InstrPtr p = 0;
                c = workingset[j].cntxt;
@@ -719,8 +721,8 @@ startProfiler(Client cntxt)
                myname = putName("profiler");
        }
        malProfileMode = 1;
+       logjsonInternal(monet_characteristics, true);
        MT_lock_unset(&mal_profileLock);
-       logjsonInternal(monet_characteristics, true);
        // reset the trace table
        clearTrace(cntxt);
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to