@ -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_mes sa ge ( " 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_mes sa ge ( " 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_mes sa ge ( " 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_mes sa ge ( " 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_mes sa ge ( " 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_mes sa ge ( " 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_mes sa ge ( " socktypes init \n " ) ;
PNACL_msg ( " socktypes init \n " ) ;
// Plug in individual socktypes
nn_global_add_socktype ( nn_pair_socktype ) ;
//sleep(1);
PNACL_mes sa ge ( " nn_xpair_socktype init \n " ) ;
PNACL_msg ( " nn_xpair_socktype init \n " ) ;
nn_global_add_socktype ( nn_xpair_socktype ) ;
PNACL_mes sa ge ( " 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_mes sa ge ( " do pool init \n " ) ;
PNACL_msg ( " do pool init \n " ) ;
nn_pool_init ( & SELF . pool ) ; // Start the worker threads
//sleep(1);
PNACL_mes sa ge ( " 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_mes sa ge ( " ctx init \n " ) ;
PNACL_msg ( " ctx init \n " ) ;
nn_ctx_init ( & SELF . ctx , nn_global_getpool ( ) , NULL ) ;
PNACL_mes sa ge ( " timer init \n " ) ;
PNACL_msg ( " timer init \n " ) ;
nn_timer_init ( & SELF . stat_timer , NN_GLOBAL_SRC_STAT_TIMER , & SELF . fsm ) ;
PNACL_mes sa ge ( " do FSM start \n " ) ;
PNACL_msg ( " do FSM start \n " ) ;
nn_fsm_start ( & SELF . fsm ) ;
PNACL_mes sa ge ( " 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_mes sa ge ( " 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_mes sa ge ("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_mes sa ge ("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_mes sa ge ("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_mes sa ge ("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_mes sa ge ("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_mes sa ge ("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_mes sa ge ("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_mes sa ge ("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_mes sa ge ("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_mes sa ge ("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_mes sa ge ( " %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_mes sa ge ( " 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_mes sa ge ( " 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_mes sa ge ( " bad source %d \n " , src ) ;
PNACL_msg ( " bad source %d \n " , src ) ;
nn_fsm_bad_source ( global - > state , src , type ) ;
}