Browse Source

Test

etomic
jl777 7 years ago
parent
commit
5c40e6118f
  1. 7
      crypto777/nanosrc/aio/worker_posix.c
  2. 6
      crypto777/nanosrc/utils/thread_posix.c
  3. 31
      iguana/exchanges/LP_nativeDEX.c

7
crypto777/nanosrc/aio/worker_posix.c

@ -175,7 +175,9 @@ static void nn_worker_routine (void *arg)
struct nn_worker_timer *timer;
printf("nn_worker_routine started\n");
self = (struct nn_worker*) arg;
#ifndef FROM_JS
while ( 1 ) // Infinite loop. It will be interrupted only when the object is shut down.
#endif
{
// Wait for new events and/or timeouts.
rc = nn_poller_wait(&self->poller,nn_timerset_timeout (&self->timerset));
@ -226,7 +228,12 @@ static void nn_worker_routine (void *arg)
nn_ctx_leave (task->owner->ctx);
}
nn_queue_term (&tasks);
#ifdef FROM_JS
printf("done worker ITER\n");
return;
#else
continue;
#endif
}
printf("nn_worker true i/o, invoke handler\n");
fd = nn_cont(phndl,struct nn_worker_fd,hndl); // It's a true I/O event. Invoke the handler

6
crypto777/nanosrc/utils/thread_posix.c

@ -42,6 +42,8 @@ void nn_thread_term(struct nn_thread *self)
errnum_assert(rc == 0,rc);
}
void *Nanomsg_threadarg;
#ifdef __PNACL
void nn_thread_init(struct nn_thread *self,nn_thread_routine *routine,void *arg)
{
@ -50,8 +52,12 @@ void nn_thread_init(struct nn_thread *self,nn_thread_routine *routine,void *arg)
printf("nn_thread_init routine.%p arg.%p\n",routine,arg);
self->routine = routine;
self->arg = arg;
#ifdef FROM_JS
Nanomsg_threadarg = self;
#else
rc = pthread_create(&self->handle,NULL,nn_thread_main_routine,(void *)self);
errnum_assert (rc == 0, rc);
#endif
}
#else

31
iguana/exchanges/LP_nativeDEX.c

@ -1031,11 +1031,26 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
}
#ifdef FROM_JS
extern void *Nanomsg_threadarg;
void emscripten_usleep(int32_t x)
{
}
char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params,int32_t timeout)
{
static uint32_t counter; char fname[512],*retstr; long fsize;
if ( strncmp("http://",url,strlen("http://")) != 0 )
return(clonestr("{\"error\":\"only http allowed\"}"));
sprintf(fname,"bitcoind_RPC/req.%u",counter);
counter++;
//printf("issue.(%s)\n",url);
emscripten_wget(url,fname);
retstr = OS_filestr(&fsize,fname);
//printf("bitcoind_RPC(%s) -> fname.(%s) %s\n",url,fname,retstr);
return(retstr);
}
void LP_fromjs_iter()
{
static void *ctx;
@ -1048,6 +1063,8 @@ void LP_fromjs_iter()
ctx = bitcoin_ctx();
if ( 0 && (LP_counter % 100) == 0 )
printf("LP_fromjs_iter got called LP_counter.%d userpass.(%s) ctx.%p\n",LP_counter,G.USERPASS,ctx);
if ( Nanomsg_threadarg != 0 )
nn_thread_main_routine(Nanomsg_threadarg);
LP_pubkeys_query();
LP_utxosQ_process();
LP_nanomsg_recvs(ctx);
@ -1055,20 +1072,6 @@ void LP_fromjs_iter()
LP_counter++;
}
char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char *command,char *params,int32_t timeout)
{
static uint32_t counter; char fname[512],*retstr; long fsize;
if ( strncmp("http://",url,strlen("http://")) != 0 )
return(clonestr("{\"error\":\"only http allowed\"}"));
sprintf(fname,"bitcoind_RPC/req.%u",counter);
counter++;
//printf("issue.(%s)\n",url);
emscripten_wget(url,fname);
retstr = OS_filestr(&fsize,fname);
//printf("bitcoind_RPC(%s) -> fname.(%s) %s\n",url,fname,retstr);
return(retstr);
}
#endif

Loading…
Cancel
Save