Browse code

core: remove one function for blocking TCP write, deactivated since 2004

- remove one function for blocking TCP write, deactivated since 2004 in TCP core
- code is not compiling anymore if activated

Henning Westerholt authored on 09/01/2020 16:54:18
Showing 1 changed files
... ...
@@ -892,75 +892,6 @@ inline static int wbufq_run(int fd, struct tcp_connection* c, int* empty)
892 892
 
893 893
 
894 894
 
895
-#if 0
896
-/* blocking write even on non-blocking sockets 
897
- * if TCP_TIMEOUT will return with error */
898
-static int tcp_blocking_write(struct tcp_connection* c, int fd, char* buf,
899
-								unsigned int len)
900
-{
901
-	int n;
902
-	fd_set sel_set;
903
-	struct timeval timeout;
904
-	int ticks;
905
-	int initial_len;
906
-	
907
-	initial_len=len;
908
-again:
909
-	
910
-	n=send(fd, buf, len,
911
-#ifdef HAVE_MSG_NOSIGNAL
912
-			MSG_NOSIGNAL
913
-#else
914
-			0
915
-#endif
916
-		);
917
-	if (n<0){
918
-		if (errno==EINTR)	goto again;
919
-		else if (errno!=EAGAIN && errno!=EWOULDBLOCK){
920
-			LM_ERR("failed to send: (%d) %s\n", errno, strerror(errno));
921
-			TCP_EV_SEND_TIMEOUT(errno, &c->rcv);
922
-			TCP_STATS_SEND_TIMEOUT();
923
-			goto error;
924
-		}
925
-	}else if (n<len){
926
-		/* partial write */
927
-		buf+=n;
928
-		len-=n;
929
-	}else{
930
-		/* success: full write */
931
-		goto end;
932
-	}
933
-	while(1){
934
-		FD_ZERO(&sel_set);
935
-		FD_SET(fd, &sel_set);
936
-		timeout.tv_sec=tcp_send_timeout;
937
-		timeout.tv_usec=0;
938
-		ticks=get_ticks();
939
-		n=select(fd+1, 0, &sel_set, 0, &timeout);
940
-		if (n<0){
941
-			if (errno==EINTR) continue; /* signal, ignore */
942
-			LM_ERR("select failed: (%d) %s\n", errno, strerror(errno));
943
-			goto error;
944
-		}else if (n==0){
945
-			/* timeout */
946
-			if (get_ticks()-ticks>=tcp_send_timeout){
947
-				LM_ERR("send timeout (%d)\n", tcp_send_timeout);
948
-				goto error;
949
-			}
950
-			continue;
951
-		}
952
-		if (FD_ISSET(fd, &sel_set)){
953
-			/* we can write again */
954
-			goto again;
955
-		}
956
-	}
957
-error:
958
-		return -1;
959
-end:
960
-		return initial_len;
961
-}
962
-#endif
963
-
964 895
 /* Attempt to extract real connection information from an upstream load
965 896
  * balancer or reverse proxy. This should be called right after accept()ing the
966 897
  * connection, and before TLS negotiation.
... ...
@@ -2794,7 +2725,6 @@ static int tcpconn_do_send(int fd, struct tcp_connection* c,
2794 2725
 		n=_tcpconn_write_nb(fd, c, buf, len);
2795 2726
 	}else{
2796 2727
 #endif /* TCP_ASYNC */
2797
-		/* n=tcp_blocking_write(c, fd, buf, len); */
2798 2728
 		n=tsend_stream(fd, buf, len,
2799 2729
 						TICKS_TO_S(cfg_get(tcp, tcp_cfg, send_timeout)) *
2800 2730
 						1000);