From 7576b9fd8a47516c4c710212b16b5582a22392b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 8 Jan 2016 19:13:24 -0300 Subject: [PATCH] test --- iguana/iguana_accept.c | 8 +++++++- iguana/iguana_peers.c | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/iguana/iguana_accept.c b/iguana/iguana_accept.c index 080d7f61a..ffee85075 100755 --- a/iguana/iguana_accept.c +++ b/iguana/iguana_accept.c @@ -62,12 +62,18 @@ int32_t iguana_acceptspoll(uint8_t *buf,int32_t bufsize,struct iguana_accept *ac void iguana_acceptloop(void *args) { - int32_t bindsock,sock; struct iguana_accept *ptr; struct iguana_peer *addr; struct iguana_info *coin = args; + struct iguana_peer *addr; struct iguana_info *coin = args; + struct pollfd pfd; int32_t bindsock,sock; struct iguana_accept *ptr; socklen_t clilen; struct sockaddr_in cli_addr; char ipaddr[64]; uint32_t ipbits; bindsock = iguana_socket(1,"0.0.0.0",coin->chain->portp2p); printf("iguana_bindloop 127.0.0.1:%d bind sock.%d\n",coin->chain->portp2p,bindsock); while ( bindsock >= 0 ) { + memset(&pfd,0,sizeof(pfd)); + pfd.fd = bindsock; + pfd.events = POLL_IN; + if ( poll(&pfd,1,100) <= 0 ) + continue; clilen = sizeof(cli_addr); printf("ACCEPT (%s:%d) on sock.%d\n","127.0.0.1",coin->chain->portp2p,bindsock); sock = accept(bindsock,(struct sockaddr *)&cli_addr,&clilen); diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 4f24b40ca..3b4ebc671 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -331,7 +331,7 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) close(sock); return(-1); } - if ( bindflag != 0 && listen(sock,100) != 0 ) + if ( bindflag != 0 && listen(sock,3) != 0 ) { printf("listen(%s) port.%d failed: %s sock.%d. errno.%d\n",hostname,port,strerror(errno),sock,errno); if ( sock >= 0 )