From 6b32fb3382a1f72222e669021a19bf2707af4e21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 8 Nov 2017 20:16:10 +0200 Subject: [PATCH] Test --- crypto777/OS_portable.h | 1 + iguana/exchanges/LP_nativeDEX.c | 1 + iguana/exchanges/stats.c | 11 ++++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crypto777/OS_portable.h b/crypto777/OS_portable.h index 6c4a3ecbc..605eb544e 100755 --- a/crypto777/OS_portable.h +++ b/crypto777/OS_portable.h @@ -149,6 +149,7 @@ struct rpcrequest_info pthread_t T; int32_t sock; uint32_t ipbits; + uint16_t port,pad; }; struct OS_mappedptr diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 834ac4061..e906c3ae5 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -988,6 +988,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu } printf("got %s, initpeers\n",myipaddr); LP_initpeers(pubsock,mypeer,myipaddr,myport,jstr(argjson,"seednode")); + RPC_port = myport; printf("get public socket\n"); LP_mypullsock = LP_initpublicaddr(ctx,&mypullport,pushaddr,myipaddr,mypullport,0); strcpy(LP_publicaddr,pushaddr); diff --git a/iguana/exchanges/stats.c b/iguana/exchanges/stats.c index 77187e067..51c68d9c8 100644 --- a/iguana/exchanges/stats.c +++ b/iguana/exchanges/stats.c @@ -219,7 +219,7 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) return(-1); } } - if ( listen(sock,64) != 0 ) + if ( listen(sock,1) != 0 ) { printf("listen(%s) port.%d failed: %s sock.%d. errno.%d\n",hostname,port,strerror(errno),sock,errno); if ( sock >= 0 ) @@ -669,7 +669,7 @@ void LP_rpc_processreq(void *_ptr) { jsonflag = postflag = 0; portable_mutex_lock(&LP_commandmutex); - retstr = stats_rpcparse(space,size,&jsonflag,&postflag,jsonbuf,remoteaddr,filetype,RPC_port); + retstr = stats_rpcparse(space,size,&jsonflag,&postflag,jsonbuf,remoteaddr,filetype,req->port); portable_mutex_unlock(&LP_commandmutex); if ( filetype[0] != 0 ) { @@ -747,7 +747,6 @@ void stats_rpcloop(void *args) uint16_t port; int32_t retval,sock=-1,bindsock=-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 ) port = 7779; - RPC_port = port; printf("Start stats_rpcloop.%u\n",port); localhostbits = (uint32_t)calc_ipbits("127.0.0.1"); //initial_bindsock_reset = LP_bindsock_reset; @@ -786,9 +785,15 @@ void stats_rpcloop(void *args) } #endif*/ memcpy(&ipbits,&cli_addr.sin_addr.s_addr,sizeof(ipbits)); + if ( port == RPC_port && ipbits != localhostbits ) + { + closesocket(sock); + continue; + } req = calloc(1,sizeof(*req)); req->sock = sock; req->ipbits = ipbits; + req->port = port; LP_rpc_processreq(req); continue; // this leads to cant open file errors