Browse Source

Try to fix memleak!

blackjok3r
blackjok3r 6 years ago
parent
commit
c2a5b84918
  1. 2
      iguana/dPoW.h
  2. 15
      iguana/dpow/dpow_fsm.c
  3. 2
      iguana/iguana_notary.c

2
iguana/dPoW.h

@ -115,7 +115,7 @@ struct dpow_block
uint64_t recvmask,bestmask,ratifybestmask,ratifyrecvmask,pendingbestmask,pendingratifybestmask,ratifysigmasks[2]; uint64_t recvmask,bestmask,ratifybestmask,ratifyrecvmask,pendingbestmask,pendingratifybestmask,ratifysigmasks[2];
struct dpow_recvdata recv[64]; struct dpow_recvdata recv[64];
struct dpow_entry notaries[DPOW_MAXRELAYS]; struct dpow_entry notaries[DPOW_MAXRELAYS];
uint32_t MoMdepth,state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch,paxwdcrc,lastnanosend; uint32_t MoMdepth,state,starttime,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2],lastepoch,paxwdcrc,lastnanosend,finished;
int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS]; int32_t rawratifiedlens[2],height,numnotaries,numerrors,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS];
int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk,matches,bestmatches; int8_t myind,bestk,ratifybestk,pendingbestk,pendingratifybestk,matches,bestmatches;
cJSON *ratified; cJSON *ratified;

15
iguana/dpow/dpow_fsm.c

@ -284,6 +284,7 @@ void dpow_statemachinestart(void *ptr)
if ( src == 0 || dest == 0 ) if ( src == 0 || dest == 0 )
{ {
printf("null coin ptr? (%s %p or %s %p)\n",dp->symbol,src,dp->dest,dest); printf("null coin ptr? (%s %p or %s %p)\n",dp->symbol,src,dp->dest,dest);
bp->finished = 0xffffffff;
free(ptr); free(ptr);
return; return;
} }
@ -320,6 +321,7 @@ void dpow_statemachinestart(void *ptr)
if ( numratified > 64 ) if ( numratified > 64 )
{ {
fprintf(stderr,"cant ratify more than 64 notaries ratified has %d\n",numratified); fprintf(stderr,"cant ratify more than 64 notaries ratified has %d\n",numratified);
bp->finished = 0xffffffff;
free(ptr); free(ptr);
free_json(ratified); free_json(ratified);
return; return;
@ -381,6 +383,7 @@ void dpow_statemachinestart(void *ptr)
if ( dp->ratifying != 0 && bp->isratify == 0 ) if ( dp->ratifying != 0 && bp->isratify == 0 )
{ {
printf("skip notarization ht.%d when ratifying\n",bp->height); printf("skip notarization ht.%d when ratifying\n",bp->height);
bp->finished = 0xffffffff;
free(ptr); free(ptr);
return; return;
} }
@ -430,6 +433,7 @@ void dpow_statemachinestart(void *ptr)
for (i=0; i<33; i++) for (i=0; i<33; i++)
printf("%02x",dp->minerkey33[i]); printf("%02x",dp->minerkey33[i]);
printf(" statemachinestart this node %s %s is not official notary numnotaries.%d kmdht.%d bpht.%d\n",srcaddr,destaddr,bp->numnotaries,kmdheight,bp->height); printf(" statemachinestart this node %s %s is not official notary numnotaries.%d kmdht.%d bpht.%d\n",srcaddr,destaddr,bp->numnotaries,kmdheight,bp->height);
bp->finished = 0xffffffff;
free(ptr); free(ptr);
dp->ratifying -= bp->isratify; dp->ratifying -= bp->isratify;
exit(-1); exit(-1);
@ -440,6 +444,7 @@ void dpow_statemachinestart(void *ptr)
else else
{ {
printf("statemachinestart no kmdheight.%d\n",kmdheight); printf("statemachinestart no kmdheight.%d\n",kmdheight);
bp->finished = 0xffffffff;
free(ptr); free(ptr);
dp->ratifying -= bp->isratify; dp->ratifying -= bp->isratify;
return; return;
@ -455,6 +460,7 @@ void dpow_statemachinestart(void *ptr)
printf("%02x",bp->ratified_pubkeys[0][i]); printf("%02x",bp->ratified_pubkeys[0][i]);
printf(" new, cant change notary0\n"); printf(" new, cant change notary0\n");
dp->ratifying -= bp->isratify; dp->ratifying -= bp->isratify;
bp->finished = 0xffffffff;
free(ptr); free(ptr);
return; return;
} }
@ -529,8 +535,9 @@ void dpow_statemachinestart(void *ptr)
{ {
//printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height); //printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height);
dp->ratifying -= bp->isratify; dp->ratifying -= bp->isratify;
free(ptr); goto end;
return; //free(ptr);
//return;
} }
sleep(1); sleep(1);
} }
@ -609,7 +616,9 @@ void dpow_statemachinestart(void *ptr)
printf("[%d] END isratify.%d:%d bestk.%d %llx sigs.%llx state.%x machine ht.%d completed state.%x %s.%s %s.%s recvmask.%llx paxwdcrc.%x %p %p\n",Numallocated,bp->isratify,dp->ratifying,bp->bestk,(long long)bp->bestmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),bp->state,bp->height,bp->state,dp->dest,bits256_str(str,bp->desttxid),dp->symbol,bits256_str(str2,bp->srctxid),(long long)bp->recvmask,bp->paxwdcrc,src,dest); printf("[%d] END isratify.%d:%d bestk.%d %llx sigs.%llx state.%x machine ht.%d completed state.%x %s.%s %s.%s recvmask.%llx paxwdcrc.%x %p %p\n",Numallocated,bp->isratify,dp->ratifying,bp->bestk,(long long)bp->bestmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),bp->state,bp->height,bp->state,dp->dest,bits256_str(str,bp->desttxid),dp->symbol,bits256_str(str2,bp->srctxid),(long long)bp->recvmask,bp->paxwdcrc,src,dest);
dp->lastrecvmask = bp->recvmask; dp->lastrecvmask = bp->recvmask;
dp->ratifying -= bp->isratify; dp->ratifying -= bp->isratify;
bp->state = 0xffffffff;
end:
// unlock the dest utxo on KMD. // unlock the dest utxo on KMD.
if ( (strcmp("KMD",dest->symbol) == 0 ) && (ep->dest.prev_vout != -1) ) if ( (strcmp("KMD",dest->symbol) == 0 ) && (ep->dest.prev_vout != -1) )
{ {
@ -625,6 +634,6 @@ void dpow_statemachinestart(void *ptr)
} }
// dp->blocks[bp->height] = 0; // dp->blocks[bp->height] = 0;
bp->state = 0xffffffff; bp->finished = 0xffffffff;
free(ptr); free(ptr);
} }

2
iguana/iguana_notary.c

@ -143,7 +143,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
printf("ht.%d maxblocks.%d\n",ht,dp->maxblocks); printf("ht.%d maxblocks.%d\n",ht,dp->maxblocks);
for (i=ht-DPOW_MAXFREQ*5; i>ht-DPOW_MAXFREQ*100&&i>DPOW_MAXFREQ; i--) for (i=ht-DPOW_MAXFREQ*5; i>ht-DPOW_MAXFREQ*100&&i>DPOW_MAXFREQ; i--)
{ {
if ( (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff ) //(i % DPOW_MAXFREQ) != 0 && if ( (bp= dp->blocks[i]) != 0 && bp->finished == 0xffffffff ) //(i % DPOW_MAXFREQ) != 0 &&
{ {
if ( dp->currentbp == dp->blocks[i] ) if ( dp->currentbp == dp->blocks[i] )
dp->currentbp = 0; dp->currentbp = 0;

Loading…
Cancel
Save