Browse Source

Test

etomic
jl777 8 years ago
parent
commit
c0ff755abb
  1. 5
      basilisk/basilisk.c
  2. 35
      iguana/dpow/dpow_network.c

5
basilisk/basilisk.c

@ -893,7 +893,7 @@ void basilisks_loop(void *arg)
basilisk_ping_send(myinfo,relay); basilisk_ping_send(myinfo,relay);
} }
counter++; counter++;
//fprintf(stderr,"E "); fprintf(stderr,"E ");
if ( myinfo->numdpows == 1 ) if ( myinfo->numdpows == 1 )
{ {
iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]); iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]);
@ -903,13 +903,14 @@ void basilisks_loop(void *arg)
{ {
dp = &myinfo->DPOWS[counter % myinfo->numdpows]; dp = &myinfo->DPOWS[counter % myinfo->numdpows];
iguana_dPoWupdate(myinfo,dp); iguana_dPoWupdate(myinfo,dp);
if ( (counter % myinfo->numdpows) != 0 ) //if ( (counter % myinfo->numdpows) != 0 )
{ {
//fprintf(stderr,"F "); //fprintf(stderr,"F ");
iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]); iguana_dPoWupdate(myinfo,&myinfo->DPOWS[0]);
} }
endmilli = startmilli + 30; endmilli = startmilli + 30;
} }
fprintf(stderr,"F ");
} }
else else
{ {

35
iguana/dpow/dpow_network.c

@ -1888,7 +1888,7 @@ void dpow_ipbitsadd(struct supernet_info *myinfo,struct dpow_info *dp,uint32_t *
int32_t dpow_nanomsg_update(struct supernet_info *myinfo) int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
{ {
int32_t i,n=0,num=0,size,broadcastflag,firstz = -1; char *retstr; uint32_t crc32,r,m; struct dpow_nanomsghdr *np=0; struct dpow_info *dp; struct dpow_block *bp; struct dex_nanomsghdr *dexp = 0; void *freeptr; int32_t i,n,num,num2,flags=0,size,iter,broadcastflag,firstz = -1; char *retstr; uint32_t crc32,r,m; struct dpow_nanomsghdr *np=0; struct dpow_info *dp; struct dpow_block *bp; struct dex_nanomsghdr *dexp = 0; void *freeptr;
if ( time(NULL) < myinfo->nanoinit+5 || (myinfo->dpowsock < 0 && myinfo->dexsock < 0 && myinfo->repsock < 0) ) if ( time(NULL) < myinfo->nanoinit+5 || (myinfo->dpowsock < 0 && myinfo->dexsock < 0 && myinfo->repsock < 0) )
return(-1); return(-1);
if ( myinfo->IAMNOTARY != 0 && myinfo->numnotaries <= 0 ) if ( myinfo->IAMNOTARY != 0 && myinfo->numnotaries <= 0 )
@ -1897,16 +1897,10 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
printf("INIT with %d notaries\n",myinfo->numnotaries); printf("INIT with %d notaries\n",myinfo->numnotaries);
} }
portable_mutex_lock(&myinfo->dpowmutex); portable_mutex_lock(&myinfo->dpowmutex);
/*for (i=0; i<100; i++) num = num2 = n = 0;
for (iter=0; iter<1000; iter++)
{ {
struct nn_pollfd pfd; if ( (flags & 1) == 0 && (size= signed_nn_recv(&freeptr,myinfo->ctx,myinfo->notaries,myinfo->numnotaries,myinfo->dpowsock,&np)) >= 0 )
pfd.fd = myinfo->dpowsock;
pfd.events = NN_POLLIN;
if ( nn_poll(&pfd,1,100) > 0 )
break;
usleep(1000);
}*/
while ( (size= signed_nn_recv(&freeptr,myinfo->ctx,myinfo->notaries,myinfo->numnotaries,myinfo->dpowsock,&np)) >= 0 && num < 1000 )
{ {
num++; num++;
if ( size > 0 ) if ( size > 0 )
@ -1953,14 +1947,13 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
} //else printf("crc error from.%d %x vs %x or no dp.%p [%s]\n",np->senderind,crc32,np->crc32,dp,np->symbol); } //else printf("crc error from.%d %x vs %x or no dp.%p [%s]\n",np->senderind,crc32,np->crc32,dp,np->symbol);
} else printf("ignore.%d np->datalen.%d %d (size %d - %ld) [%s]\n",np->senderind,np->datalen,(int32_t)(size-sizeof(*np)),size,sizeof(*np),np->symbol); } else printf("ignore.%d np->datalen.%d %d (size %d - %ld) [%s]\n",np->senderind,np->datalen,(int32_t)(size-sizeof(*np)),size,sizeof(*np),np->symbol);
} //else printf("wrong version from.%d %02x %02x size.%d [%s]\n",np->senderind,np->version0,np->version1,size,np->symbol); } //else printf("wrong version from.%d %02x %02x size.%d [%s]\n",np->senderind,np->version0,np->version1,size,np->symbol);
} //else printf("illegal size.%d\n",size); }
if ( freeptr != 0 ) if ( freeptr != 0 )
nn_freemsg(freeptr), np = 0, freeptr = 0; nn_freemsg(freeptr), np = 0, freeptr = 0;
} //else printf("no packets\n"); } else flag |= 1;
n = 0;
if ( myinfo->dexsock >= 0 ) // from servers if ( myinfo->dexsock >= 0 ) // from servers
{ {
while ( (size= signed_nn_recv(&freeptr,myinfo->ctx,myinfo->notaries,myinfo->numnotaries,myinfo->dexsock,&dexp)) > 0 && n < 1000 ) if ( (flags & 2) == 0 && (size= signed_nn_recv(&freeptr,myinfo->ctx,myinfo->notaries,myinfo->numnotaries,myinfo->dexsock,&dexp)) > 0 )
{ {
//fprintf(stderr,"%d ",size); //fprintf(stderr,"%d ",size);
n++; n++;
@ -1973,14 +1966,13 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
//printf("GOT DEX bus PACKET.%d\n",size); //printf("GOT DEX bus PACKET.%d\n",size);
if ( freeptr != 0 ) if ( freeptr != 0 )
nn_freemsg(freeptr), dexp = 0, freeptr = 0; nn_freemsg(freeptr), dexp = 0, freeptr = 0;
} } else flags |= 2;
} }
if ( myinfo->repsock >= 0 ) // from clients if ( myinfo->repsock >= 0 ) // from clients
{ {
num = 0; if ( (flags & 4) == 0 && (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) > 0 )
while ( (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) > 0 )
{ {
num++; num2++;
printf("REP got %d crc.%08x\n",size,calc_crc32(0,(void *)dexp,size)); printf("REP got %d crc.%08x\n",size,calc_crc32(0,(void *)dexp,size));
if ( (retstr= dex_response(&broadcastflag,myinfo,dexp)) != 0 ) if ( (retstr= dex_response(&broadcastflag,myinfo,dexp)) != 0 )
{ {
@ -2014,10 +2006,11 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
// nn_freemsg(freeptr), dexp = 0, freeptr = 0; // nn_freemsg(freeptr), dexp = 0, freeptr = 0;
if ( dexp != 0 ) if ( dexp != 0 )
nn_freemsg(dexp), dexp = 0; nn_freemsg(dexp), dexp = 0;
if ( num > 1000 ) //if ( num > 1000 )
break; // break;
} else flags |= 4;
printf("num.%d n.%d num2.%d rep packets\n",num,n,num2);
} }
printf("num.%d rep packets\n",num);
} }
portable_mutex_unlock(&myinfo->dpowmutex); portable_mutex_unlock(&myinfo->dpowmutex);
return(num); return(num);

Loading…
Cancel
Save