Browse Source

Test

etomic
jl777 7 years ago
parent
commit
9b11cc612e
  1. 8
      crypto777/OS_portable.h
  2. 1
      iguana/exchanges/LP_nativeDEX.c
  3. 11
      iguana/exchanges/LP_network.c
  4. 18
      iguana/exchanges/stats.c

8
crypto777/OS_portable.h

@ -143,6 +143,14 @@ typedef struct queue
char name[64],initflag;
} queue_t;
struct rpcrequest_info
{
struct rpcrequest_info *next,*prev;
pthread_t T;
int32_t sock;
uint32_t ipbits;
};
struct OS_mappedptr
{
char fname[512];

1
iguana/exchanges/LP_nativeDEX.c

@ -81,6 +81,7 @@ struct LP_peerinfo *LP_peerinfos,*LP_mypeer;
struct LP_forwardinfo *LP_forwardinfos;
struct iguana_info *LP_coins;
struct LP_pubkeyinfo *LP_pubkeyinfos;
struct rpcrequest_info *LP_garbage_collector;
#include "LP_network.c"

11
iguana/exchanges/LP_network.c

@ -267,12 +267,21 @@ int32_t LP_peerindsock(int32_t *peerindp)
void queue_loop(void *arg)
{
struct LP_queue *ptr,*tmp; int32_t sentbytes,nonz,flag,duplicate,n=0;
struct rpcrequest_info *req,*rtmp; struct LP_queue *ptr,*tmp; int32_t sentbytes,nonz,flag,duplicate,n=0;
strcpy(queue_loop_stats.name,"queue_loop");
queue_loop_stats.threshold = 500.;
while ( 1 )
{
LP_millistats_update(&queue_loop_stats);
portable_mutex_lock(&LP_networkmutex);
DL_FOREACH_SAFE(LP_garbage_collector,req,rtmp)
{
DL_DELETE(LP_garbage_collector,req);
printf("garbage collect ipbits.%x\n",req->ipbits);
free(req);
}
portable_mutex_unlock(&LP_networkmutex);
nonz = 0;
//printf("LP_Q.%p next.%p prev.%p\n",LP_Q,LP_Q!=0?LP_Q->next:0,LP_Q!=0?LP_Q->prev:0);
n = 0;

18
iguana/exchanges/stats.c

@ -589,11 +589,12 @@ int32_t iguana_getheadersize(char *buf,int32_t recvlen)
}
uint16_t RPC_port;
extern portable_mutex_t LP_commandmutex;
struct rpcrequest_info { pthread_t T; int32_t sock; uint32_t ipbits; };
extern portable_mutex_t LP_commandmutex,LP_networkmutex;
extern struct rpcrequest_info *LP_garbage_collector;
void LP_rpc_processreq(void *_ptr)
{
static uint32_t spawned,maxspawned;
char filetype[128],content_type[128];
int32_t recvlen,flag,postflag=0,contentlen,remains,sock,numsent,jsonflag=0,hdrsize,len;
char helpname[512],remoteaddr[64],*buf,*retstr,*space,*jsonbuf; struct rpcrequest_info *req = _ptr;
@ -607,6 +608,14 @@ void LP_rpc_processreq(void *_ptr)
jsonbuf = calloc(1,size);
remains = size-1;
buf = jsonbuf;
portable_mutex_lock(&LP_networkmutex);
spawned++;
portable_mutex_unlock(&LP_networkmutex);
if ( spawned > maxspawned )
{
printf("max rpc threads spawned and alive %d <- %d\n",maxspawned,spawned);
spawned = maxspawned;
}
while ( remains > 0 )
{
//printf("flag.%d remains.%d recvlen.%d\n",flag,remains,recvlen);
@ -726,7 +735,10 @@ void LP_rpc_processreq(void *_ptr)
free(space);
free(jsonbuf);
closesocket(sock);
free(_ptr);
portable_mutex_lock(&LP_networkmutex);
DL_APPEND(LP_garbage_collector,req);
spawned--;
portable_mutex_unlock(&LP_networkmutex);
}
extern int32_t IAMLP;

Loading…
Cancel
Save