jl777 7 years ago
parent
commit
6578d99aeb
  1. 54
      crypto777/nanosrc/aio/usock_posix.c
  2. 42
      crypto777/nanosrc/aio/worker_posix.c
  3. 64
      crypto777/nanosrc/core/global.c
  4. 8
      crypto777/nanosrc/core/pipe.c
  5. 8
      crypto777/nanosrc/core/sock.c
  6. 2
      crypto777/nanosrc/nn_config.h
  7. 4
      crypto777/nanosrc/utils/efd_eventfd.c
  8. 12
      crypto777/nanosrc/utils/efd_pipe.c
  9. 2
      crypto777/nanosrc/utils/efd_socketpair.c
  10. 4
      crypto777/nanosrc/utils/err.c
  11. 14
      crypto777/nanosrc/utils/err.h
  12. 4
      crypto777/nanosrc/utils/thread_posix.c
  13. 1
      iguana/exchanges/Makefile

54
crypto777/nanosrc/aio/usock_posix.c

@ -167,7 +167,7 @@ int nn_usock_start (struct nn_usock *self, int domain, int type, int protocol)
s = socket (domain, type, protocol);
if (nn_slow (s < 0))
return -errno;
//PNACL_message("got socket s.%d\n",s);
//PNACL_msg("got socket s.%d\n",s);
nn_usock_init_from_fd (self, s);
/* Start the state machine. */
@ -368,7 +368,7 @@ void nn_usock_accept (struct nn_usock *self, struct nn_usock *listener)
and allow processing other events in the meantime */
if (nn_slow (errno != EAGAIN && errno != EWOULDBLOCK && errno != ECONNABORTED && errno != listener->errnum))
{
PNACL_message("listen errno.%d\n",errno);
PNACL_msg("listen errno.%d\n",errno);
listener->errnum = errno;
listener->state = NN_USOCK_STATE_ACCEPTING_ERROR;
nn_fsm_raise (&listener->fsm,
@ -406,7 +406,7 @@ void nn_usock_connect (struct nn_usock *self, const struct sockaddr *addr,
if ( nn_slow(errno != EINPROGRESS) )
{
self->errnum = errno;
PNACL_message("error.%d not EINPROGRESS\n",errno);
PNACL_msg("error.%d not EINPROGRESS\n",errno);
nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR);
return;
}
@ -435,9 +435,9 @@ void nn_usock_send (struct nn_usock *self, const struct nn_iovec *iov,
self->out.iov [out].iov_base = iov [i].iov_base;
self->out.iov [out].iov_len = iov [i].iov_len;
out++;
//PNACL_message("{%d} ",(int)iov [i].iov_len);
//PNACL_msg("{%d} ",(int)iov [i].iov_len);
}
//PNACL_message("iov[%d]\n",out);
//PNACL_msg("iov[%d]\n",out);
self->out.hdr.msg_iovlen = out;
/* Try to send the data immediately. */
@ -474,17 +474,17 @@ void nn_usock_recv (struct nn_usock *self, void *buf, size_t len, int *fd)
rc = nn_usock_recv_raw (self, buf, &nbytes);
if (nn_slow (rc < 0)) {
errnum_assert (rc == -ECONNRESET, -rc);
//PNACL_message("rc.%d vs ECONNRESET\n",rc,ECONNRESET);
//PNACL_msg("rc.%d vs ECONNRESET\n",rc,ECONNRESET);
nn_fsm_action (&self->fsm, NN_USOCK_ACTION_ERROR);
return;
}
//int i;
//for (i=0; i<16&&i<nbytes; i++)
// PNACL_message("%02x ",((uint8_t *)buf)[i]);
//PNACL_message("nn_usock_recv nbytes.%d\n",(int)nbytes);
// PNACL_msg("%02x ",((uint8_t *)buf)[i]);
//PNACL_msg("nn_usock_recv nbytes.%d\n",(int)nbytes);
/* Success. */
if (nn_fast (nbytes == len)) {
//PNACL_message("raise NN_USOCK_RECEIVED\n");
//PNACL_msg("raise NN_USOCK_RECEIVED\n");
nn_fsm_raise (&self->fsm, &self->event_received, NN_USOCK_RECEIVED);
return;
}
@ -1023,19 +1023,19 @@ int32_t nn_getiovec_size(uint8_t *buf,int32_t maxlen,struct msghdr *hdr)
if ( nn_slow(iov->iov_len == NN_MSG) )
{
errno = EINVAL;
PNACL_message("ERROR: iov->iov_len == NN_MSG\n");
PNACL_msg("ERROR: iov->iov_len == NN_MSG\n");
return(-1);
}
if ( nn_slow(!iov->iov_base && iov->iov_len) )
{
errno = EFAULT;
PNACL_message("ERROR: !iov->iov_base && iov->iov_len\n");
PNACL_msg("ERROR: !iov->iov_base && iov->iov_len\n");
return(-1);
}
if ( maxlen > 0 && nn_slow(size + iov->iov_len > maxlen) )
{
errno = EINVAL;
PNACL_message("ERROR: sz.%d + iov->iov_len.%d < maxlen.%d\n",(int32_t)size,(int32_t)iov->iov_len,maxlen);
PNACL_msg("ERROR: sz.%d + iov->iov_len.%d < maxlen.%d\n",(int32_t)size,(int32_t)iov->iov_len,maxlen);
return(-1);
}
if ( iov->iov_len > 0 )
@ -1071,10 +1071,10 @@ ssize_t mysendmsg(int32_t usock,struct msghdr *hdr,int32_t flags)
if ( nn_getiovec_size(&buf[offset],veclen,hdr) == veclen )
{
nbytes = send(usock,buf,offset + veclen,0);
//PNACL_message(">>>>>>>>> send.[%d %d %d %d] (n.%d v.%d c.%d)-> usock.%d nbytes.%d\n",buf[offset],buf[offset+1],buf[offset+2],buf[offset+3],(int32_t)offset+veclen,veclen,clen,usock,(int32_t)nbytes);
//PNACL_msg(">>>>>>>>> send.[%d %d %d %d] (n.%d v.%d c.%d)-> usock.%d nbytes.%d\n",buf[offset],buf[offset+1],buf[offset+2],buf[offset+3],(int32_t)offset+veclen,veclen,clen,usock,(int32_t)nbytes);
if ( nbytes != offset + veclen )
{
//PNACL_message("nbytes.%d != offset.%d veclen.%d errno.%d usock.%d\n",(int32_t)nbytes,(int32_t)offset,veclen,errno,usock);
//PNACL_msg("nbytes.%d != offset.%d veclen.%d errno.%d usock.%d\n",(int32_t)nbytes,(int32_t)offset,veclen,errno,usock);
}
if ( nbytes >= offset )
nbytes -= offset;
@ -1082,19 +1082,19 @@ ssize_t mysendmsg(int32_t usock,struct msghdr *hdr,int32_t flags)
else
{
err = -errno;
PNACL_message("mysendmsg: unexpected nn_getiovec_size error %d\n",err);
PNACL_msg("mysendmsg: unexpected nn_getiovec_size error %d\n",err);
}
if ( buf != _buf )
free(buf);
if ( err != 0 )
{
PNACL_message("nn_usock_send_raw errno.%d err.%d\n",errno,err);
PNACL_msg("nn_usock_send_raw errno.%d err.%d\n",errno,err);
return(-errno);
}
}
else
{
PNACL_message("nn_usock_send_raw errno.%d invalid iovec size\n",errno);
PNACL_msg("nn_usock_send_raw errno.%d invalid iovec size\n",errno);
return(-errno);
}
return(nbytes);
@ -1106,32 +1106,32 @@ ssize_t myrecvmsg(int32_t usock,struct msghdr *hdr,int32_t flags,int32_t len)
iov = hdr->msg_iov;
/*if ( (n= (int32_t)recv(usock,lens,sizeof(lens),0)) != sizeof(lens) )
{
PNACL_message("error getting veclen/clen n.%d vs %d from usock.%d\n",n,(int32_t)sizeof(lens),usock);
PNACL_msg("error getting veclen/clen n.%d vs %d from usock.%d\n",n,(int32_t)sizeof(lens),usock);
return(0);
} else PNACL_message("GOT %d bytes from usock.%d\n",n,usock);
} else PNACL_msg("GOT %d bytes from usock.%d\n",n,usock);
offset = 0;
veclen = lens[offset++];
veclen |= ((int32_t)lens[offset++] << 8);
veclen |= ((int32_t)lens[offset++] << 16);
clen = lens[offset++];
clen |= ((int32_t)lens[offset++] << 8);
PNACL_message("veclen.%d clen.%d waiting in usock.%d\n",veclen,clen,usock);
PNACL_msg("veclen.%d clen.%d waiting in usock.%d\n",veclen,clen,usock);
if ( clen > 0 )
{
if ( (cbytes= (int32_t)recv(usock,hdr->msg_control,clen,0)) != clen )
{
PNACL_message("myrecvmsg: unexpected cbytes.%d vs clen.%d\n",cbytes,clen);
PNACL_msg("myrecvmsg: unexpected cbytes.%d vs clen.%d\n",cbytes,clen);
}
} else cbytes = 0;*/
hdr->msg_controllen = 0;
if ( (nbytes= (int32_t)recv(usock,iov->iov_base,len,0)) != len )
{
//PNACL_message("myrecvmsg: partial nbytes.%d vs veclen.%d\n",(int32_t)nbytes,len);
//PNACL_msg("myrecvmsg: partial nbytes.%d vs veclen.%d\n",(int32_t)nbytes,len);
}
//PNACL_message("GOT nbytes.%d of len.%d from usock.%d\n",(int32_t)nbytes,len,usock);
//PNACL_msg("GOT nbytes.%d of len.%d from usock.%d\n",(int32_t)nbytes,len,usock);
if ( 0 && nbytes > 0 )
{
PNACL_message("got nbytes.%d from usock.%d [%d %d %d %d]\n",(int32_t)nbytes,usock,((uint8_t *)iov->iov_base)[0],((uint8_t *)iov->iov_base)[1],((uint8_t *)iov->iov_base)[2],((uint8_t *)iov->iov_base)[3]);
PNACL_msg("got nbytes.%d from usock.%d [%d %d %d %d]\n",(int32_t)nbytes,usock,((uint8_t *)iov->iov_base)[0],((uint8_t *)iov->iov_base)[1],((uint8_t *)iov->iov_base)[2],((uint8_t *)iov->iov_base)[3]);
}
return(nbytes);
}
@ -1201,13 +1201,13 @@ int32_t nn_process_cmsg(struct nn_usock *self,struct msghdr *hdr)
memcpy(&retval,(int32_t *)CMSG_DATA(cmsg),sizeof(int32_t));
if ( self->in.pfd )
{
PNACL_message("CMSG set self->in.pfd (%d)\n",retval);
PNACL_msg("CMSG set self->in.pfd (%d)\n",retval);
*self->in.pfd = retval;
self->in.pfd = NULL;
}
else
{
PNACL_message("CMSG nn_closefd(%d)\n",retval);
PNACL_msg("CMSG nn_closefd(%d)\n",retval);
nn_closefd(retval);
}
break;
@ -1312,7 +1312,7 @@ static int nn_usock_recv_raw(struct nn_usock *self, void *buf, size_t *len)
}
} else if ( hdr.msg_controllen > 0 )
nn_process_cmsg(self,&hdr);
//PNACL_message("nbytes.%d length.%d *len %d\n",(int)nbytes,(int)length,(int)*len);
//PNACL_msg("nbytes.%d length.%d *len %d\n",(int)nbytes,(int)length,(int)*len);
// If the data were received directly into the place we can return straight away
if ( usebuf != 0 )

42
crypto777/nanosrc/aio/worker_posix.c

@ -102,28 +102,28 @@ void nn_worker_task_term (struct nn_worker_task *self)
int nn_worker_init(struct nn_worker *self)
{
int32_t rc;
//PNACL_message("nn_worker_init %p\n",self);
//PNACL_msg("nn_worker_init %p\n",self);
rc = nn_efd_init(&self->efd);
//PNACL_message("efd init: rc.%d\n",rc);
//PNACL_msg("efd init: rc.%d\n",rc);
if ( rc < 0 )
return rc;
//PNACL_message("nn_mutex_init\n");
//PNACL_msg("nn_mutex_init\n");
nn_mutex_init(&self->sync);
//PNACL_message("nn_queue_init\n");
//PNACL_msg("nn_queue_init\n");
nn_queue_init(&self->tasks);
//PNACL_message("nn_queue_item_init\n");
//PNACL_msg("nn_queue_item_init\n");
nn_queue_item_init(&self->stop);
//PNACL_message("nn_poller_init\n");
//PNACL_msg("nn_poller_init\n");
nn_poller_init(&self->poller);
//PNACL_message("nn_poller_add\n");
//PNACL_msg("nn_poller_add\n");
nn_poller_add(&self->poller,nn_efd_getfd(&self->efd),&self->efd_hndl);
//PNACL_message("nn_poller_set_in\n");
//PNACL_msg("nn_poller_set_in\n");
nn_poller_set_in(&self->poller, &self->efd_hndl);
//PNACL_message("nn_timerset_init\n");
//PNACL_msg("nn_timerset_init\n");
nn_timerset_init(&self->timerset);
//PNACL_message("nn_thread_init\n");
//PNACL_msg("nn_thread_init\n");
nn_thread_init(&self->thread,nn_worker_routine, self);
//PNACL_message("finished nn_worker_init\n");
//PNACL_msg("finished nn_worker_init\n");
return 0;
}
@ -173,7 +173,7 @@ static void nn_worker_routine (void *arg)
struct nn_worker_task *task;
struct nn_worker_fd *fd;
struct nn_worker_timer *timer;
PNACL_message("nn_worker_routine started\n");
PNACL_msg("nn_worker_routine started\n");
self = (struct nn_worker*) arg;
while ( 1 ) // Infinite loop. It will be interrupted only when the object is shut down.
{
@ -185,7 +185,7 @@ static void nn_worker_routine (void *arg)
rc = nn_timerset_event(&self->timerset, &thndl);
if ( rc == -EAGAIN )
break;
PNACL_message("nn_worker process expired user\n");
PNACL_msg("nn_worker process expired user\n");
errnum_assert(rc == 0, -rc);
timer = nn_cont(thndl, struct nn_worker_timer, hndl);
nn_ctx_enter(timer->owner->ctx);
@ -197,7 +197,7 @@ static void nn_worker_routine (void *arg)
rc = nn_poller_event(&self->poller,&pevent,&phndl); // Get next poller event, such as IN or OUT
if ( nn_slow(rc == -EAGAIN) )
break;
PNACL_message("nn_worker process all events from the poller\n");
PNACL_msg("nn_worker process all events from the poller\n");
if ( phndl == &self->efd_hndl ) // If there are any new incoming worker tasks, process them
{
nn_assert (pevent == NN_POLLER_IN);
@ -212,14 +212,14 @@ static void nn_worker_routine (void *arg)
item = nn_queue_pop(&tasks); // Next worker task
if ( nn_slow(!item) )
break;
PNACL_message("nn_worker next worker task\n");
PNACL_msg("nn_worker next worker task\n");
if ( nn_slow(item == &self->stop) ) // If the worker thread is asked to stop, do so
{
nn_queue_term(&tasks);
return;
}
// It's a user-defined task. Notify the user that it has arrived in the worker thread
PNACL_message("nn_worker user defined task\n");
PNACL_msg("nn_worker user defined task\n");
task = nn_cont(item,struct nn_worker_task,item);
nn_ctx_enter(task->owner->ctx);
nn_fsm_feed(task->owner,task->src,NN_WORKER_TASK_EXECUTE,task);
@ -228,15 +228,15 @@ static void nn_worker_routine (void *arg)
nn_queue_term (&tasks);
continue;
}
PNACL_message("nn_worker true i/o, invoke handler\n");
PNACL_msg("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
PNACL_message("nn_worker true i/o, fd.%p\n",fd);
PNACL_msg("nn_worker true i/o, fd.%p\n",fd);
nn_ctx_enter(fd->owner->ctx);
PNACL_message("nn_worker true i/o, after nn_ctx_enter\n");
PNACL_msg("nn_worker true i/o, after nn_ctx_enter\n");
nn_fsm_feed(fd->owner,fd->src,pevent,fd);
PNACL_message("nn_worker true i/o, after nn_fsm_feed leave.%p\n",fd->owner->ctx);
PNACL_msg("nn_worker true i/o, after nn_fsm_feed leave.%p\n",fd->owner->ctx);
nn_ctx_leave(fd->owner->ctx);
PNACL_message("nn_worker true i/o, after nn_ctx_leave\n");
PNACL_msg("nn_worker true i/o, after nn_ctx_leave\n");
}
}
}

64
crypto777/nanosrc/core/global.c

@ -201,9 +201,9 @@ static void nn_global_add_transport (struct nn_transport *transport)
static void nn_global_add_socktype (struct nn_socktype *socktype)
{
PNACL_message("add socktype %p -> %p\n",socktype,&SELF.socktypes);
PNACL_msg("add socktype %p -> %p\n",socktype,&SELF.socktypes);
nn_list_insert (&SELF.socktypes, &socktype->item,nn_list_end (&SELF.socktypes));
PNACL_message("added socktype %p -> %p\n",socktype,&SELF.socktypes);
PNACL_msg("added socktype %p -> %p\n",socktype,&SELF.socktypes);
}
void nn_global_init (void)
{
@ -218,7 +218,7 @@ void nn_global_init (void)
nn_assert (LOBYTE (data.wVersion) == 2 &&
HIBYTE (data.wVersion) == 2);
#endif
PNACL_message("nn_global_init\n");
PNACL_msg("nn_global_init\n");
nn_alloc_init(); // Initialise the memory allocation subsystem
nn_random_seed(); // Seed the pseudo-random number generator
// Allocate the global table of SP sockets.
@ -227,7 +227,7 @@ void nn_global_init (void)
for (i=0; i<NN_MAX_SOCKETS; i++)
SELF.socks[i] = NULL;
SELF.nsocks = SELF.flags = 0;
PNACL_message("do getenv\n");
PNACL_msg("do getenv\n");
envvar = getenv("NN_PRINT_ERRORS"); // Print connection and accepting errors to the stderr
SELF.print_errors = envvar && *envvar; // any non-empty string is true
envvar = getenv("NN_PRINT_STATISTICS"); // Print socket statistics to stderr
@ -236,26 +236,26 @@ PNACL_message("do getenv\n");
alloc_assert (SELF.unused);
for (i=0; i<NN_MAX_SOCKETS; i++)
SELF.unused [i] = NN_MAX_SOCKETS - i - 1;
PNACL_message("list init\n");
PNACL_msg("list init\n");
// Initialise other parts of the global state.
nn_list_init(&SELF.transports);
nn_list_init(&SELF.socktypes);
//sleep(1);
PNACL_message("transports init\n");
PNACL_msg("transports init\n");
// Plug in individual transports.
nn_global_add_transport(nn_ipc);
nn_global_add_transport(nn_tcp);
nn_global_add_transport(nn_inproc);
nn_global_add_transport(nn_ws);
nn_global_add_transport(nn_tcpmux);
//nn_global_add_transport(nn_ws);
//nn_global_add_transport(nn_tcpmux);
//sleep(1);
PNACL_message("socktypes init\n");
PNACL_msg("socktypes init\n");
// Plug in individual socktypes
nn_global_add_socktype(nn_pair_socktype);
//sleep(1);
PNACL_message("nn_xpair_socktype init\n");
PNACL_msg("nn_xpair_socktype init\n");
nn_global_add_socktype(nn_xpair_socktype);
PNACL_message("did nn_xpair_socktype init\n");
PNACL_msg("did nn_xpair_socktype init\n");
nn_global_add_socktype(nn_rep_socktype);
nn_global_add_socktype(nn_req_socktype);
nn_global_add_socktype(nn_xrep_socktype);
@ -275,19 +275,19 @@ PNACL_message("socktypes init\n");
nn_global_add_socktype(nn_bus_socktype);
nn_global_add_socktype(nn_xbus_socktype);
//sleep(1);
PNACL_message("do pool init\n");
PNACL_msg("do pool init\n");
nn_pool_init(&SELF.pool); // Start the worker threads
//sleep(1);
PNACL_message("do FSM init\n");
PNACL_msg("do FSM init\n");
nn_fsm_init_root(&SELF.fsm,nn_global_handler,nn_global_shutdown,&SELF.ctx); // Start FSM
SELF.state = NN_GLOBAL_STATE_IDLE;
PNACL_message("ctx init\n");
PNACL_msg("ctx init\n");
nn_ctx_init(&SELF.ctx, nn_global_getpool(),NULL);
PNACL_message("timer init\n");
PNACL_msg("timer init\n");
nn_timer_init(&SELF.stat_timer,NN_GLOBAL_SRC_STAT_TIMER,&SELF.fsm);
PNACL_message("do FSM start\n");
PNACL_msg("do FSM start\n");
nn_fsm_start(&SELF.fsm);
PNACL_message("special sockets init\n");
PNACL_msg("special sockets init\n");
// Initializing special sockets.
addr = getenv("NN_STATISTICS_SOCKET");
if ( addr != 0 )
@ -503,7 +503,7 @@ int32_t nn_global_create_socket(int32_t domain,int32_t protocol)
int nn_socket(int domain,int protocol)
{
int rc;
PNACL_message("nn_socket flags.%d\n",SELF.flags);
PNACL_msg("nn_socket flags.%d\n",SELF.flags);
nn_glock_lock();
if (nn_slow (SELF.flags & NN_CTX_FLAG_ZOMBIE)) // If nn_term() was already called, return ETERM
{
@ -511,7 +511,7 @@ int nn_socket(int domain,int protocol)
errno = ETERM;
return -1;
}
//PNACL_message("nn_socket flags.%d\n",SELF.flags);
//PNACL_msg("nn_socket flags.%d\n",SELF.flags);
nn_global_init(); // Make sure that global state is initialised
rc = nn_global_create_socket (domain, protocol);
if ( rc < 0 )
@ -522,7 +522,7 @@ int nn_socket(int domain,int protocol)
return -1;
}
nn_glock_unlock();
//PNACL_message("did nn_global_init\n");
//PNACL_msg("did nn_global_init\n");
return rc;
}
@ -672,7 +672,7 @@ int32_t nn_recv(int32_t s,void *buf,size_t len,int32_t flags)
int32_t nn_sendmsg(int32_t s,const struct nn_msghdr *msghdr,int32_t flags)
{
int32_t rc,i,nnmsg; size_t sz; struct nn_iovec *iov; struct nn_msg msg; void *chunk;
//PNACL_message("nn_sendmsg.(%d) \n",s);
//PNACL_msg("nn_sendmsg.(%d) \n",s);
NN_BASIC_CHECKS;
if ( nn_slow(!msghdr) )
{
@ -772,13 +772,13 @@ int32_t nn_recvmsg(int32_t s,struct nn_msghdr *msghdr,int32_t flags)
chunk = nn_chunkref_getchunk(&msg.body);
*(void **)(msghdr->msg_iov[0].iov_base) = chunk;
sz = nn_chunk_size(chunk);
//PNACL_message("got message -> iov_base.%p sz.%d\n",msghdr->msg_iov[0].iov_base,(int32_t)sz);
//PNACL_msg("got message -> iov_base.%p sz.%d\n",msghdr->msg_iov[0].iov_base,(int32_t)sz);
}
else // Copy the message content into the supplied gather array
{
data = nn_chunkref_data(&msg.body);
sz = nn_chunkref_size(&msg.body);
//PNACL_message("got message -> data.%p sz.%d\n",data,(int32_t)sz);
//PNACL_msg("got message -> data.%p sz.%d\n",data,(int32_t)sz);
for (i=0; i!=msghdr->msg_iovlen; i++)
{
iov = &msghdr->msg_iov[i];
@ -809,7 +809,7 @@ int32_t nn_recvmsg(int32_t s,struct nn_msghdr *msghdr,int32_t flags)
int32_t nn_sendmsg(int32_t s,const struct nn_msghdr *msghdr,int32_t flags)
{
int32_t rc,i,nnmsg; size_t sz,spsz; struct nn_iovec *iov; struct nn_msg msg; void *chunk; struct nn_cmsghdr *cmsg;
//PNACL_message("nn_sendmsg.(%d) \n",s);
//PNACL_msg("nn_sendmsg.(%d) \n",s);
NN_BASIC_CHECKS;
if ( nn_slow(!msghdr) )
{
@ -928,7 +928,7 @@ int32_t nn_recvmsg(int32_t s,struct nn_msghdr *msghdr,int32_t flags)
{
struct nn_msg msg; uint8_t *data; struct nn_iovec *iov; void *chunk,*ctrl; struct nn_cmsghdr *chdr;
int32_t i,rc; size_t sz,hdrssz,ctrlsz,spsz,sptotalsz;
//PNACL_message("nn_recvmsg.(%d) \n",s);
//PNACL_msg("nn_recvmsg.(%d) \n",s);
NN_BASIC_CHECKS;
if ( nn_slow(!msghdr) )
{
@ -940,7 +940,7 @@ int32_t nn_recvmsg(int32_t s,struct nn_msghdr *msghdr,int32_t flags)
errno = EMSGSIZE;
return -1;
}
//PNACL_message("get a message from sock.%d\n",s);
//PNACL_msg("get a message from sock.%d\n",s);
rc = nn_sock_recv(SELF.socks[s],&msg,flags); // Get a message
if ( nn_slow(rc < 0) )
{
@ -952,13 +952,13 @@ int32_t nn_recvmsg(int32_t s,struct nn_msghdr *msghdr,int32_t flags)
chunk = nn_chunkref_getchunk(&msg.body);
*(void **)(msghdr->msg_iov[0].iov_base) = chunk;
sz = nn_chunk_size(chunk);
//PNACL_message("got message -> iov_base.%p sz.%d\n",msghdr->msg_iov[0].iov_base,(int32_t)sz);
//PNACL_msg("got message -> iov_base.%p sz.%d\n",msghdr->msg_iov[0].iov_base,(int32_t)sz);
}
else // Copy the message content into the supplied gather array
{
data = nn_chunkref_data(&msg.body);
sz = nn_chunkref_size (&msg.body);
//PNACL_message("got message -> data.%p sz.%d\n",data,(int32_t)sz);
//PNACL_msg("got message -> data.%p sz.%d\n",data,(int32_t)sz);
for (i=0; i!=msghdr->msg_iovlen; i++)
{
iov = &msghdr->msg_iov[i];
@ -1150,7 +1150,7 @@ static void nn_global_submit_errors (int i, struct nn_sock *s,
len = snprintf (curbuf, buf_left,
" nanomsg: Endpoint %d [%s] error: %s\n",
ep->eid, nn_ep_getaddr (ep), nn_strerror (ep->last_errno));
PNACL_message("%s\n",curbuf);
PNACL_msg("%s\n",curbuf);
#endif
if (buf_left < len)
break;
@ -1247,7 +1247,7 @@ static int nn_global_create_ep (int s, const char *addr, int bind)
#ifdef NN_USE_MYMSG
if ( strncmp("inproc",proto,strlen("inproc")) != 0 && strncmp("ipc",proto,strlen("ipc")) != 0 && strncmp("tcp",proto,strlen("tcp")) != 0 )
{
PNACL_message("only ipc, inproc and tcp transport is supported\n");
PNACL_msg("only ipc, inproc and tcp transport is supported\n");
printf("only ipc, inproc and tcp transport is supported\n");
fprintf(stderr,"only ipc, inproc and tcp transport is supported\n");
exit(-1);
@ -1324,12 +1324,12 @@ static void nn_global_handler (struct nn_fsm *myself,int src, int type, NN_UNUSE
nn_timer_start (&global->stat_timer, 10000); // Start statistics collection timer
return;
default:
PNACL_message("bad action %d type %d\n",src,type);
PNACL_msg("bad action %d type %d\n",src,type);
nn_fsm_bad_action(global->state, src, type);
}
default:
PNACL_message("bad source %d\n",src);
PNACL_msg("bad source %d\n",src);
nn_fsm_bad_source(global->state, src, type);
}

8
crypto777/nanosrc/core/pipe.c

@ -58,7 +58,7 @@ void nn_pipebase_init(struct nn_pipebase *self,const struct nn_pipebase_vfptr *v
memcpy(&self->options,&epbase->ep->options,sizeof(struct nn_ep_options));
nn_fsm_event_init(&self->in);
nn_fsm_event_init(&self->out);
PNACL_message("pipebase_init vfptr.%p recv.%p rcvprio.%d\n",vfptr,vfptr->recv,self->options.rcvprio);
PNACL_msg("pipebase_init vfptr.%p recv.%p rcvprio.%d\n",vfptr,vfptr->recv,self->options.rcvprio);
}
void nn_pipebase_term (struct nn_pipebase *self)
@ -78,7 +78,7 @@ int nn_pipebase_start (struct nn_pipebase *self)
self->instate = NN_PIPEBASE_INSTATE_ASYNC;
self->outstate = NN_PIPEBASE_OUTSTATE_IDLE;
rc = nn_sock_add(self->sock,(struct nn_pipe *)self);
PNACL_message("nn_pipebase_start self.%p rc.%d\n",self,rc);
PNACL_msg("nn_pipebase_start self.%p rc.%d\n",self,rc);
if ( nn_slow(rc < 0) )
{
self->state = NN_PIPEBASE_STATE_FAILED;
@ -98,7 +98,7 @@ void nn_pipebase_stop(struct nn_pipebase *self)
void nn_pipebase_received(struct nn_pipebase *self)
{
PNACL_message("nn_pipebase_received\n");
PNACL_msg("nn_pipebase_received\n");
if ( nn_fast(self->instate == NN_PIPEBASE_INSTATE_RECEIVING) )
{
self->instate = NN_PIPEBASE_INSTATE_RECEIVED;
@ -196,7 +196,7 @@ int nn_pipe_recv(struct nn_pipe *self,struct nn_msg *msg)
pipebase = (struct nn_pipebase*) self;
nn_assert (pipebase->instate == NN_PIPEBASE_INSTATE_IDLE);
pipebase->instate = NN_PIPEBASE_INSTATE_RECEIVING;
PNACL_message("call pipebase recv\n");
PNACL_msg("call pipebase recv\n");
rc = pipebase->vfptr->recv (pipebase,msg);
errnum_assert (rc >= 0, -rc);
if ( nn_fast(pipebase->instate == NN_PIPEBASE_INSTATE_RECEIVED) )

8
crypto777/nanosrc/core/sock.c

@ -489,11 +489,11 @@ int nn_sock_add_ep(struct nn_sock *self,struct nn_transport *transport,int32_t b
return rc;
}
nn_ep_start(ep);
PNACL_message("ep sock.(%s) started %s://(%s) bind.%d\n",self->socket_name,transport->name,addr,bind);
PNACL_msg("ep sock.(%s) started %s://(%s) bind.%d\n",self->socket_name,transport->name,addr,bind);
eid = self->eid++; // Increase the endpoint ID for the next endpoint
nn_list_insert(&self->eps,&ep->item,nn_list_end(&self->eps)); // Add to the list of active endpoints
nn_ctx_leave (&self->ctx);
} else PNACL_message("self->sock.(%s) %p already has (%s)\n",self->socket_name,self->sockbase->sock,addr);
} else PNACL_msg("self->sock.(%s) %p already has (%s)\n",self->socket_name,self->sockbase->sock,addr);
return(ep->eid);
}
@ -973,12 +973,12 @@ void nn_sock_report_error(struct nn_sock *self,struct nn_ep *ep,int32_t errnum,c
if ( ep != 0 )
{
fprintf(stderr,"nanomsg: socket.%s[%s]: Error: %s\n",self->socket_name,nn_ep_getaddr(ep),nn_strerror(errnum));
PNACL_message("nanomsg: socket.%s[%s]: [%s:%d] Error: %s\n",self->socket_name,nn_ep_getaddr(ep),fname,linenum,nn_strerror(errnum));
PNACL_msg("nanomsg: socket.%s[%s]: [%s:%d] Error: %s\n",self->socket_name,nn_ep_getaddr(ep),fname,linenum,nn_strerror(errnum));
}
else
{
fprintf(stderr,"nanomsg: socket.%s: Error: %s\n",self->socket_name, nn_strerror(errnum));
PNACL_message("nanomsg: socket.%s: [%s:%d] Error: %s\n",self->socket_name,fname,linenum,nn_strerror(errnum));
PNACL_msg("nanomsg: socket.%s: [%s:%d] Error: %s\n",self->socket_name,fname,linenum,nn_strerror(errnum));
}
}

2
crypto777/nanosrc/nn_config.h

@ -46,7 +46,7 @@
#define NN_HAVE_MSG_CONTROL 0
//#define STANDALONE 1
#define PNACL_message printf
#define PNACL_msg printf
#if !defined(WIN32)
//#define NN_ENABLE_EXTRA 1

4
crypto777/nanosrc/utils/efd_eventfd.c

@ -32,9 +32,9 @@ int nn_efd_init(struct nn_efd *self)
{
int rc;
int flags;
PNACL_message("inside efd_init eventfd\n");
PNACL_msg("inside efd_init eventfd\n");
self->efd = eventfd(0, EFD_CLOEXEC);
PNACL_message("self->efd: %d\n",self->efd);
PNACL_msg("self->efd: %d\n",self->efd);
if (self->efd == -1 && (errno == EMFILE || errno == ENFILE))
return -EMFILE;
errno_assert(self->efd != -1);

12
crypto777/nanosrc/utils/efd_pipe.c

@ -33,14 +33,14 @@
int nn_efd_init(struct nn_efd *self)
{
int rc,flags,p[2];
PNACL_message("inside efd_init: pipe\n");
PNACL_msg("inside efd_init: pipe\n");
//sleep(1);
#if defined NN_HAVE_PIPE2
rc = pipe2(p, O_NONBLOCK | O_CLOEXEC);
#else
rc = pipe(p);
#endif
PNACL_message("rc efd_init: %d\n",rc);
PNACL_msg("rc efd_init: %d\n",rc);
//sleep(1);
if (rc != 0 && (errno == EMFILE || errno == ENFILE))
return -EMFILE;
@ -50,20 +50,20 @@ int nn_efd_init(struct nn_efd *self)
#if !defined NN_HAVE_PIPE2 && defined FD_CLOEXEC
rc = fcntl (self->r, F_SETFD, FD_CLOEXEC);
PNACL_message("pipe efd_init: F_SETFDr rc %d\n",rc);
PNACL_msg("pipe efd_init: F_SETFDr rc %d\n",rc);
errno_assert(rc != -1);
rc = fcntl(self->w, F_SETFD, FD_CLOEXEC);
PNACL_message("pipe efd_init: F_SETFDw rc %d\n",rc);
PNACL_msg("pipe efd_init: F_SETFDw rc %d\n",rc);
errno_assert(rc != -1);
#endif
#if !defined NN_HAVE_PIPE2
flags = fcntl(self->r, F_GETFL, 0);
PNACL_message("pipe efd_init: flags %d\n",flags);
PNACL_msg("pipe efd_init: flags %d\n",flags);
if ( flags == -1 )
flags = 0;
rc = fcntl(self->r, F_SETFL, flags | O_NONBLOCK);
PNACL_message("pipe efd_init: rc %d flags.%d\n",rc,flags);
PNACL_msg("pipe efd_init: rc %d flags.%d\n",rc,flags);
errno_assert (rc != -1);
#endif

2
crypto777/nanosrc/utils/efd_socketpair.c

@ -35,7 +35,7 @@ int nn_efd_init (struct nn_efd *self)
int rc;
int flags;
int sp [2];
PNACL_message("socketpair efdinit\n");
PNACL_msg("socketpair efdinit\n");
#if defined SOCK_CLOEXEC
rc = socketpair (AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sp);
#else

4
crypto777/nanosrc/utils/err.c

@ -30,7 +30,7 @@
void nn_err_abort(void)
{
PNACL_message("nn_err_abort\n");
PNACL_msg("nn_err_abort\n");
while ( 1 )
{
printf("exit due to error\n");
@ -111,7 +111,7 @@ const char *nn_err_strerror(int32_t errnum)
#pragma warning (push)
#pragma warning (disable:4996)
#endif
PNACL_message("nanomsg: errno.%d (%s)\n",errnum,strerror(errnum));
PNACL_msg("nanomsg: errno.%d (%s)\n",errnum,strerror(errnum));
getchar();
return strerror (errnum);
#if defined _MSC_VER

14
crypto777/nanosrc/utils/err.h

@ -26,7 +26,7 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
#define PNACL_message printf
#define PNACL_msg printf
/* Include nn.h header to define nanomsg-specific error codes. */
#include "../nn.h"
@ -45,7 +45,7 @@
#define nn_assert(x) \
do {\
if (nn_slow (!(x))) {\
PNACL_message("Assertion failed: %s (%s:%d)\n", #x, \
PNACL_msg("Assertion failed: %s (%s:%d)\n", #x, \
__FILE__, __LINE__);\
fflush (stderr);\
nn_err_abort ();\
@ -55,7 +55,7 @@
#define nn_assert_state(obj, state_name) \
do {\
if (nn_slow ((obj)->state != state_name)) {\
PNACL_message( \
PNACL_msg( \
"Assertion failed: %d == %s (%s:%d)\n", \
(obj)->state, #state_name, \
__FILE__, __LINE__);\
@ -67,7 +67,7 @@
#define alloc_assert(x) \
do {\
if (nn_slow (!x)) {\
PNACL_message("Out of memory (%s:%d)\n",\
PNACL_msg("Out of memory (%s:%d)\n",\
__FILE__, __LINE__);\
nn_err_abort ();\
}\
@ -77,7 +77,7 @@
#define errno_assert(x) \
do {\
if (nn_slow (!(x))) {\
PNACL_message("%s [%d] (%s:%d)\n", nn_err_strerror (errno),\
PNACL_msg("%s [%d] (%s:%d)\n", nn_err_strerror (errno),\
(int) errno, __FILE__, __LINE__);\
nn_err_abort ();\
}\
@ -87,7 +87,7 @@
#define errnum_assert(cond, err) \
do {\
if (nn_slow (!(cond))) {\
PNACL_message("%s [%d] (%s:%d)\n", nn_err_strerror (err),(int) (err), __FILE__, __LINE__);\
PNACL_msg("%s [%d] (%s:%d)\n", nn_err_strerror (err),(int) (err), __FILE__, __LINE__);\
nn_err_abort ();\
}\
} while (0)
@ -119,7 +119,7 @@
/* Assertion-like macros for easier fsm debugging. */
#define nn_fsm_error(message, state, src, type) \
do {\
PNACL_message("%s: state=%d source=%d action=%d (%s:%d)\n", \
PNACL_msg("%s: state=%d source=%d action=%d (%s:%d)\n", \
message, state, src, type, __FILE__, __LINE__);\
nn_err_abort ();\
} while (0)

4
crypto777/nanosrc/utils/thread_posix.c

@ -30,7 +30,7 @@ static void *nn_thread_main_routine(void *arg)
{
struct nn_thread *self;
self = (struct nn_thread *)arg;
PNACL_message("nn_thread_main_routine arg.%p self->routine(%p) at %p\n",arg,self->arg,self->routine);
PNACL_msg("nn_thread_main_routine arg.%p self->routine(%p) at %p\n",arg,self->arg,self->routine);
self->routine(self->arg); // Run the thread routine
return NULL;
}
@ -47,7 +47,7 @@ void nn_thread_init(struct nn_thread *self,nn_thread_routine *routine,void *arg)
{
int32_t rc;
// No signals should be processed by this thread. The library doesn't use signals and thus all the signals should be delivered to application threads, not to worker threads.
PNACL_message("nn_thread_init routine.%p arg.%p\n",routine,arg);
PNACL_msg("nn_thread_init routine.%p arg.%p\n",routine,arg);
self->routine = routine;
self->arg = arg;
rc = pthread_create(&self->handle,NULL,nn_thread_main_routine,(void *)self);

1
iguana/exchanges/Makefile

@ -4,6 +4,5 @@
include ../crypto777/crypto777.sources
all:
#echo building... $(CRYPTO777_SRCS)
emcc -s ASSERTIONS=1 -s ASYNCIFY=1 -s TOTAL_MEMORY=134217728 --preload-file coins.json -D__PNACL -DFROM_JS -O2 -I../includes -I../crypto777 -s PTHREAD_POOL_SIZE=8 -s USE_PTHREADS=1 -o /var/www/html/index.html exchanges/mm.c $(CRYPTO777_SRCS) mini-gmp.c secp256k1/src/secp256k1.c -lm

Loading…
Cancel
Save