Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
b30767192d
  1. 8
      crypto777/iguana_utils.c
  2. 16
      iguana/iguana777.c
  3. 4
      iguana/main.c

8
crypto777/iguana_utils.c

@ -190,8 +190,8 @@ double dxblend(double *destp,double val,double decay)
return(slope);
}
/*queue_t TerminateQ; int32_t TerminateQ_queued;
void iguana_terminator(void *arg)
queue_t TerminateQ; int32_t TerminateQ_queued;
/*void iguana_terminator(void *arg)
{
struct iguana_thread *t; uint32_t lastdisp = 0; int32_t terminated = 0;
printf("iguana_terminator\n");
@ -229,7 +229,7 @@ void iguana_launcher(void *ptr)
coin = t->coin;
t->funcp(t->arg);
coin->Terminated[t->type % (sizeof(coin->Terminated)/sizeof(*coin->Terminated))]++;
queue_enqueue("TerminateQ",&coin->TerminateQ,&t->DL,0);
queue_enqueue("TerminateQ",&TerminateQ,&t->DL,0);
}
void iguana_terminate(struct iguana_info *coin,struct iguana_thread *t)
@ -254,7 +254,7 @@ struct iguana_thread *iguana_launch(struct iguana_info *coin,char *name,iguana_f
retval = OS_thread_create(&t->handle,NULL,(void *)iguana_launcher,(void *)t);
if ( retval != 0 )
printf("error launching %s\n",t->name);
while ( (t= queue_dequeue(&coin->TerminateQ,0)) != 0 )
while ( (t= queue_dequeue(&TerminateQ,0)) != 0 )
{
if ( (rand() % 100000) == 0 )
printf("terminated.%d launched.%d terminate.%p\n",coin->Terminated[t->type],coin->Launched[t->type],t);

16
iguana/iguana777.c

@ -374,21 +374,17 @@ void iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp)
void iguana_helper(void *arg)
{
FILE *fp = 0; char fname[512],name[64],*helpername = 0; cJSON *argjson=0; int32_t type,flag,idle=0;
FILE *fp = 0; cJSON *argjson=0; int32_t type,helperid=rand(),flag,idle=0;
struct iguana_helper *ptr; struct iguana_info *coin; struct OS_memspace MEM,*MEMB; struct iguana_bundle *bp;
if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 )
helpername = jstr(argjson,"name");
if ( helpername == 0 )
{
sprintf(name,"%d",rand());
helpername = name;
}
type = (name[0] % 2);
sprintf(fname,"%s/%s",GLOBALTMPDIR,helpername);
helperid = juint(argjson,"helperid");
type = (helperid % 2);
/*sprintf(fname,"%s/%s",GLOBALTMPDIR,helpername);
OS_compatible_path(fname);
fp = fopen(fname,"wb");
fp = fopen(fname,"wb");*/
if ( argjson != 0 )
free_json(argjson);
printf("HELPER.%d started\n",helperid);
memset(&MEM,0,sizeof(MEM));
MEMB = mycalloc('b',IGUANA_MAXBUNDLESIZE,sizeof(*MEMB));
while ( 1 )

4
iguana/main.c

@ -1107,12 +1107,14 @@ void iguana_main(void *arg)
API_json = jobj(API_json,"API");
free(tmpstr);
}
printf("generated API_json\n");
if ( IGUANA_NUMHELPERS == 0 )
IGUANA_NUMHELPERS = 1;
for (i=0; i<IGUANA_NUMHELPERS; i++)
{
sprintf(helperstr,"{\"name\":\"%d\"}",i);
sprintf(helperstr,"{\"name\":%d}",i);
helperargs = clonestr(helperstr);
printf("launch[%d] of %d (%s)\n",i,IGUANA_NUMHELPERS,helperstr);
iguana_launch(btcd,"iguana_helper",iguana_helper,helperargs,IGUANA_PERMTHREAD);
free(helperstr);
}

Loading…
Cancel
Save