From 40ec5fae5bb440c46a9a57c9ecfbef4f8d9f5ab2 Mon Sep 17 00:00:00 2001 From: mom040267 Date: Sun, 9 Nov 2014 23:44:32 +0000 Subject: [PATCH] working on uclient --- ChangeLog | 2 +- rpm/build.settings.sh | 2 +- rpm/turnserver.spec | 4 +-- src/apps/uclient/uclient.c | 62 ++++++++++++++++++++++++++------------ src/ns_turn_defs.h | 2 +- 5 files changed, 48 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4fdd715..e436ef3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,5 @@ 11/07/2014 Oleg Moskalenko -Version 4.2.2.3 'Monza': +Version 4.2.3.1 'Monza': - Request re-transmission implemented in uclient test program. - TLS connection procedure improved in uclient test program. diff --git a/rpm/build.settings.sh b/rpm/build.settings.sh index 2f445ae..d44c2d1 100755 --- a/rpm/build.settings.sh +++ b/rpm/build.settings.sh @@ -2,7 +2,7 @@ # Common settings script. -TURNVERSION=4.2.2.3 +TURNVERSION=4.2.3.1 BUILDDIR=~/rpmbuild ARCH=`uname -p` TURNSERVER_SVN_URL=http://coturn.googlecode.com/svn diff --git a/rpm/turnserver.spec b/rpm/turnserver.spec index ff1aca1..5cea7db 100644 --- a/rpm/turnserver.spec +++ b/rpm/turnserver.spec @@ -1,5 +1,5 @@ Name: turnserver -Version: 4.2.2.3 +Version: 4.2.3.1 Release: 0%{dist} Summary: Coturn TURN Server @@ -295,7 +295,7 @@ fi %changelog * Thu Nov 07 2014 Oleg Moskalenko - - Sync to 4.2.2.3 + - Sync to 4.2.3.1 * Sun Oct 26 2014 Oleg Moskalenko - Sync to 4.2.2.2 * Sun Oct 05 2014 Oleg Moskalenko diff --git a/src/apps/uclient/uclient.c b/src/apps/uclient/uclient.c index 1ba6519..7403b88 100644 --- a/src/apps/uclient/uclient.c +++ b/src/apps/uclient/uclient.c @@ -308,28 +308,52 @@ int send_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int data_con static int wait_fd(int fd, unsigned int cycle) { - fd_set fds; - FD_ZERO(&fds); - FD_SET(fd,&fds); + if(fd>=(int)FD_SETSIZE) { + return 1; + } else { + fd_set fds; + FD_ZERO(&fds); + FD_SET(fd,&fds); - if(dos && cycle==0) - return 0; + if(dos && cycle==0) + return 0; - struct timeval timeout = {0,0}; - if(cycle == 0) - timeout.tv_usec = 500000; - else { - timeout.tv_sec = 1; - while(--cycle) timeout.tv_sec = timeout.tv_sec + timeout.tv_sec; + struct timeval start_time; + struct timeval ctime; + gettimeofday(&start_time,NULL); + + ctime.tv_sec = start_time.tv_sec; + ctime.tv_usec = start_time.tv_usec; + + int rc = 0; + + do { + struct timeval timeout = {0,0}; + if(cycle == 0) { + timeout.tv_usec = 500000; + } else { + + timeout.tv_sec = 1; + while(--cycle) timeout.tv_sec = timeout.tv_sec + timeout.tv_sec; + + if(ctime.tv_sec > start_time.tv_sec) { + if(ctime.tv_sec >= start_time.tv_sec + timeout.tv_sec) { + break; + } else { + timeout.tv_sec -= (ctime.tv_sec - start_time.tv_sec); + } + } + } + rc = select(fd+1,&fds,NULL,NULL,&timeout); + if((rc<0) && (errno == EINTR)) { + gettimeofday(&ctime,NULL); + } else { + break; + } + } while(1); + + return rc; } - - int rc = 0; - - do { - rc = select(fd+1,&fds,NULL,NULL,&timeout); - } while((rc<0) && (errno == EINTR)); - - return rc; } int recv_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int sync, int data_connection, app_tcp_conn_info *atc, stun_buffer* request_message) { diff --git a/src/ns_turn_defs.h b/src/ns_turn_defs.h index e755654..482b856 100644 --- a/src/ns_turn_defs.h +++ b/src/ns_turn_defs.h @@ -31,7 +31,7 @@ #ifndef __IOADEFS__ #define __IOADEFS__ -#define TURN_SERVER_VERSION "4.2.2.3" +#define TURN_SERVER_VERSION "4.2.3.1" #define TURN_SERVER_VERSION_NAME "Monza" #define TURN_SOFTWARE "Coturn-" TURN_SERVER_VERSION " '" TURN_SERVER_VERSION_NAME "'"