From 4338727a2a53b04c7bae1c2cbb022952d0937949 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 22 Oct 2017 19:24:00 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_network.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index ae9a8c8c9..1419c8b6e 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -126,6 +126,7 @@ int32_t LP_peerindsock(int32_t *peerindp) struct LP_peerinfo *peer,*tmp; int32_t peerind = 0; HASH_ITER(hh,LP_peerinfos,peer,tmp) { + peerind++; if ( peer->errors < LP_MAXPEER_ERRORS && peer->pushsock >= 0 ) { if ( peerind < *peerindp ) @@ -134,7 +135,6 @@ int32_t LP_peerindsock(int32_t *peerindp) //printf("peerind.%d -> sock %d\n",peerind,peer->pushsock); return(peer->pushsock); } - peerind++; } return(-1); } @@ -158,9 +158,6 @@ void queue_loop(void *ignore) { if ( (sentbytes= nn_send(ptr->sock,ptr->msg,ptr->msglen,0)) != ptr->msglen ) printf("%d LP_send sent %d instead of %d\n",n,sentbytes,ptr->msglen); -#ifdef __APPLE__ -//else printf("%d %p qsent %u msglen.%d peerind.%d (%s)\n",n,ptr,ptr->crc32,ptr->msglen,ptr->peerind,ptr->msg); -#endif ptr->sock = -1; if ( ptr->peerind > 0 ) ptr->starttime = (uint32_t)time(NULL); @@ -239,12 +236,12 @@ printf("Q sent1 %u msglen.%d (%s)\n",crc32,msglen,msg); else { if ( (maxind= LP_numpeers()) > 0 ) - peerind = (rand() % maxind); - else peerind = 0; + peerind = (rand() % maxind) + 1; + else peerind = 1; sock0 = LP_peerindsock(&peerind); if ( (maxind= LP_numpeers()) > 0 ) - peerind = (rand() % maxind); - else peerind = 0; + peerind = (rand() % maxind) + 1; + else peerind = 1; sock1 = LP_peerindsock(&peerind); } if ( sock0 >= 0 )