Selaa lähdekoodia

working on uclient

mom040267 11 vuotta sitten
vanhempi
sitoutus
40ec5fae5b
5 muutettua tiedostoa jossa 46 lisäystä ja 22 poistoa
  1. 1 1
      ChangeLog
  2. 1 1
      rpm/build.settings.sh
  3. 2 2
      rpm/turnserver.spec
  4. 41 17
      src/apps/uclient/uclient.c
  5. 1 1
      src/ns_turn_defs.h

+ 1 - 1
ChangeLog

@@ -1,5 +1,5 @@
 11/07/2014 Oleg Moskalenko <[email protected]>
-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.
 

+ 1 - 1
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

+ 2 - 2
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 <[email protected]>
-  - Sync to 4.2.2.3
+  - Sync to 4.2.3.1
 * Sun Oct 26 2014 Oleg Moskalenko <[email protected]>
   - Sync to 4.2.2.2
 * Sun Oct 05 2014 Oleg Moskalenko <[email protected]>

+ 41 - 17
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);
 
-	int rc = 0;
+		ctime.tv_sec = start_time.tv_sec;
+		ctime.tv_usec = start_time.tv_usec;
 
-	do {
-		rc = select(fd+1,&fds,NULL,NULL,&timeout);
-	} while((rc<0) && (errno == EINTR));
+		int rc = 0;
 
-	return rc;
+		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 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) {

+ 1 - 1
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 "'"