Browse Source

Test

etomic
jl777 7 years ago
parent
commit
3f081ad51a
  1. 6
      iguana/exchanges/LP_nativeDEX.c
  2. 29
      iguana/exchanges/stats.c

6
iguana/exchanges/LP_nativeDEX.c

@ -1171,7 +1171,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
printf("error launching LP_swapsloop for port.%u\n",myport); printf("error launching LP_swapsloop for port.%u\n",myport);
exit(-1); exit(-1);
} }
int32_t nonz; uint32_t lasthello = 0; int32_t nonz; //uint32_t lasthello = 0;
while ( 1 ) while ( 1 )
{ {
nonz = 0; nonz = 0;
@ -1187,7 +1187,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
usleep(1000); usleep(1000);
else if ( IAMLP == 0 ) else if ( IAMLP == 0 )
usleep(1000); usleep(1000);
if ( IAMLP != 0 && time(NULL) > lasthello+600 ) /*if ( IAMLP != 0 && time(NULL) > lasthello+600 )
{ {
char *hellostr,*retstr; cJSON *retjson; int32_t allgood,sock = LP_bindsock; char *hellostr,*retstr; cJSON *retjson; int32_t allgood,sock = LP_bindsock;
allgood = 0; allgood = 0;
@ -1220,7 +1220,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
} }
} }
} }
} }*/
} }
#endif #endif
} }

29
iguana/exchanges/stats.c

@ -740,38 +740,39 @@ void LP_rpc_processreq(void *_ptr)
} }
extern int32_t IAMLP; extern int32_t IAMLP;
int32_t LP_bindsock_reset,LP_bindsock = -1; //int32_t LP_bindsock_reset,LP_bindsock = -1;
void stats_rpcloop(void *args) void stats_rpcloop(void *args)
{ {
uint16_t port; int32_t retval,sock,initial_bindsock_reset; socklen_t clilen; struct sockaddr_in cli_addr; uint32_t ipbits,localhostbits; struct rpcrequest_info *req,*req2,*rtmp; uint16_t port; int32_t retval,sock=-1; socklen_t clilen; struct sockaddr_in cli_addr; uint32_t ipbits,localhostbits; struct rpcrequest_info *req,*req2,*rtmp;
if ( (port= *(uint16_t *)args) == 0 ) if ( (port= *(uint16_t *)args) == 0 )
port = 7779; port = 7779;
RPC_port = port; RPC_port = port;
printf("Start stats_rpcloop.%u\n",port);
localhostbits = (uint32_t)calc_ipbits("127.0.0.1"); localhostbits = (uint32_t)calc_ipbits("127.0.0.1");
initial_bindsock_reset = LP_bindsock_reset; //initial_bindsock_reset = LP_bindsock_reset;
while ( LP_bindsock_reset == initial_bindsock_reset ) while ( 1 )//LP_bindsock_reset == initial_bindsock_reset )
{ {
//printf("LP_bindsock.%d\n",LP_bindsock); //printf("LP_bindsock.%d\n",LP_bindsock);
if ( LP_bindsock < 0 ) if ( sock < 0 )
{ {
while ( (LP_bindsock= iguana_socket(1,"0.0.0.0",port)) < 0 ) while ( (sock= iguana_socket(1,"0.0.0.0",port)) < 0 )
usleep(10000); usleep(10000);
#ifndef _WIN32 #ifndef _WIN32
//fcntl(LP_bindsock, F_SETFL, fcntl(LP_bindsock, F_GETFL, 0) | O_NONBLOCK); //fcntl(sock, F_SETFL, fcntl(sock, F_GETFL, 0) | O_NONBLOCK);
#endif #endif
//if ( counter++ < 1 ) //if ( counter++ < 1 )
printf(">>>>>>>>>> DEX stats 127.0.0.1:%d bind sock.%d DEX stats API enabled <<<<<<<<<\n",port,LP_bindsock); printf(">>>>>>>>>> DEX stats 127.0.0.1:%d bind sock.%d DEX stats API enabled <<<<<<<<<\n",port,sock);
} }
//printf("after LP_bindsock.%d\n",LP_bindsock); //printf("after sock.%d\n",sock);
clilen = sizeof(cli_addr); clilen = sizeof(cli_addr);
sock = accept(LP_bindsock,(struct sockaddr *)&cli_addr,&clilen); sock = accept(sock,(struct sockaddr *)&cli_addr,&clilen);
//#ifdef _WIN32 //#ifdef _WIN32
if ( sock < 0 ) if ( sock < 0 )
{ {
printf("iguana_rpcloop ERROR on accept usock.%d errno %d %s\n",sock,errno,strerror(errno)); printf("iguana_rpcloop ERROR on accept usock.%d errno %d %s\n",sock,errno,strerror(errno));
closesocket(LP_bindsock); closesocket(sock);
LP_bindsock = -1; sock = -1;
continue; continue;
} }
/*#else /*#else
@ -794,8 +795,8 @@ continue;
if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 ) if ( (retval= OS_thread_create(&req->T,NULL,(void *)LP_rpc_processreq,req)) != 0 )
{ {
printf("error launching rpc handler on port %d, retval.%d\n",port,retval); printf("error launching rpc handler on port %d, retval.%d\n",port,retval);
closesocket(LP_bindsock); closesocket(sock);
LP_bindsock = -1; sock = -1;
portable_mutex_lock(&LP_gcmutex); portable_mutex_lock(&LP_gcmutex);
DL_FOREACH_SAFE(LP_garbage_collector,req2,rtmp) DL_FOREACH_SAFE(LP_garbage_collector,req2,rtmp)
{ {

Loading…
Cancel
Save