From f42f928860819037276d88e4261c3e17ba086079 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 11:10:35 -0300 Subject: [PATCH] test --- src/komodo.h | 4 ---- src/komodo_events.h | 2 ++ src/komodo_notary.h | 2 ++ src/komodo_pax.h | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index e9b193b1b..0f46a9f71 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -192,10 +192,8 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate"); if ( (fp= fopen(fname,"rb+")) != 0 ) { - pthread_mutex_lock(&komodo_mutex); while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) ; - pthread_mutex_unlock(&komodo_mutex); } else fp = fopen(fname,"wb+"); printf("fname.(%s) fpos.%ld\n",fname,ftell(fp)); KOMODO_INITDONE = (uint32_t)time(NULL); @@ -208,7 +206,6 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar if ( fp != 0 ) // write out funcid, height, other fields, call side effect function { //printf("fpos.%ld ",ftell(fp)); - pthread_mutex_lock(&komodo_mutex); if ( KMDheight != 0 ) { if ( KMDtimestamp != 0 ) @@ -313,7 +310,6 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar //komodo_notarized_update(height,NOTARIZED_HEIGHT,NOTARIZED_HASH,NOTARIZED_DESTTXID); } fflush(fp); - pthread_mutex_unlock(&komodo_mutex); } } diff --git a/src/komodo_events.h b/src/komodo_events.h index d7411737f..b5178d396 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -19,6 +19,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen) { struct komodo_event *ep; uint16_t len = (uint16_t)(sizeof(*ep) + datalen); + portable_mutex_lock(&komodo_mutex); ep = (struct komodo_event *)calloc(1,len); ep->len = len; ep->height = height; @@ -28,6 +29,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char memcpy(ep->space,data,datalen); sp->Komodo_events = (struct komodo_event **)realloc(sp->Komodo_events,(1 + sp->Komodo_numevents) * sizeof(*sp->Komodo_events)); sp->Komodo_events[sp->Komodo_numevents++] = ep; + portable_mutex_unlock(&komodo_mutex); return(ep); } diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 5cea65f95..cbfca6563 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -168,6 +168,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not printf("komodo_notarized_update REJECT notarized_height %d > %d nHeight\n",notarized_height,nHeight); return; } + portable_mutex_lock(&komodo_mutex); sp->NPOINTS = (struct notarized_checkpoint *)realloc(sp->NPOINTS,(sp->NUM_NPOINTS+1) * sizeof(*sp->NPOINTS)); np = &sp->NPOINTS[sp->NUM_NPOINTS++]; memset(np,0,sizeof(*np)); @@ -175,6 +176,7 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height; sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash; sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid; + portable_mutex_unlock(&komodo_mutex); } //struct komodo_state *komodo_stateptr(char *symbol,char *dest); diff --git a/src/komodo_pax.h b/src/komodo_pax.h index a4af4b5aa..77f7c5f1f 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -285,10 +285,12 @@ void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals) KMDBTC = ((double)kmdbtc / (1000000000. * 1000.)); BTCUSD = ((double)btcusd / (1000000000. / 1000.)); CNYUSD = ((double)cnyusd / 1000000000.); + portable_mutex_lock(&komodo_mutex); PVALS = (uint32_t *)realloc(PVALS,(NUM_PRICES+1) * sizeof(*PVALS) * 36); PVALS[36 * NUM_PRICES] = height; memcpy(&PVALS[36 * NUM_PRICES + 1],pvals,sizeof(*pvals) * 35); NUM_PRICES++; + portable_mutex_unlock(&komodo_mutex); if ( 0 ) printf("OP_RETURN.%d KMD %.8f BTC %.6f CNY %.6f NUM_PRICES.%d (%llu %llu %llu)\n",height,KMDBTC,BTCUSD,CNYUSD,NUM_PRICES,(long long)kmdbtc,(long long)btcusd,(long long)cnyusd); }