Преглед изворни кода

Added dont send for provisional responses.

Nils Ohlmeier пре 23 година
родитељ
комит
853746319b
1 измењених фајлова са 13 додато и 7 уклоњено
  1. 13 7
      test/sipsak.c

+ 13 - 7
test/sipsak.c

@@ -38,6 +38,7 @@ bouquets and brickbats to [email protected]
 */
 
 /* TO-DO:
+   - improve dontsend
    - filter out retransmissions
    - support for short notation
    - support for IPv6
@@ -491,6 +492,7 @@ void shoot(char *buff)
 	struct pollfd sockerr;
 	int ssock, redirected, retryAfter, nretries;
 	int sock, i, len, ret, usrlocstep, randretrys;
+	int dontsend;
 	char *contact, *crlf, *foo, *bar;
 	char reply[BUFSIZE];
 	fd_set	fd;
@@ -501,7 +503,7 @@ void shoot(char *buff)
 	redirected = 1;
 	nretries = 5;
 	retryAfter = 5000;
-	usrlocstep = 0;
+	usrlocstep=dontsend = 0;
 
 	/* create a sending socket */
 	sock = (int)socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
@@ -650,12 +652,14 @@ void shoot(char *buff)
 				printf("** request **\n%s\n", buff);
 			}
 
-			/* lets fire the request to the server and store when we did */
-			ret = send(sock, buff, strlen(buff), 0);
-			(void)gettimeofday(&sendtime, &tz);
-			if (ret==-1) {
-				perror("send failure");
-				exit( 1 );
+			if (! dontsend) {
+				/* lets fire the request to the server and store when we did */
+				ret = send(sock, buff, strlen(buff), 0);
+				(void)gettimeofday(&sendtime, &tz);
+				if (ret==-1) {
+					perror("send failure");
+					exit( 1 );
+				}
 			}
 
 			/* in flood we are only interested in sending so skip the rest */
@@ -851,6 +855,8 @@ void shoot(char *buff)
 							printf("(%.3f ms) %s\n", 
 								deltaT(&sendtime, &recvtime), reply);
 #endif
+							dontsend=1;
+							i--;
 							continue;
 						}
 						else {