sws.c: improve proxy mode torture testing support - followup to 18c6c8a5
This commit is contained in:
parent
21401840fa
commit
b15024be4d
@ -1184,8 +1184,7 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port)
|
|||||||
const char *op_br = "";
|
const char *op_br = "";
|
||||||
const char *cl_br = "";
|
const char *cl_br = "";
|
||||||
#ifdef TCP_NODELAY
|
#ifdef TCP_NODELAY
|
||||||
curl_socklen_t flag = 1;
|
curl_socklen_t flag;
|
||||||
int level = IPPROTO_TCP;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
@ -1218,9 +1217,12 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port)
|
|||||||
|
|
||||||
#ifdef TCP_NODELAY
|
#ifdef TCP_NODELAY
|
||||||
/* Disable the Nagle algorithm */
|
/* Disable the Nagle algorithm */
|
||||||
if(setsockopt(serverfd, level, TCP_NODELAY,
|
flag = 1;
|
||||||
(void *)&flag, sizeof(flag)) < 0)
|
if(0 != setsockopt(serverfd, IPPROTO_TCP, TCP_NODELAY,
|
||||||
|
(void *)&flag, sizeof(flag)))
|
||||||
logmsg("====> TCP_NODELAY for server conection failed");
|
logmsg("====> TCP_NODELAY for server conection failed");
|
||||||
|
else
|
||||||
|
logmsg("TCP_NODELAY set for server conection");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
@ -1304,8 +1306,7 @@ static void http_connect(curl_socket_t *infdp,
|
|||||||
bool poll_client_wr[2] = { TRUE, TRUE };
|
bool poll_client_wr[2] = { TRUE, TRUE };
|
||||||
bool poll_server_wr[2] = { TRUE, TRUE };
|
bool poll_server_wr[2] = { TRUE, TRUE };
|
||||||
#ifdef TCP_NODELAY
|
#ifdef TCP_NODELAY
|
||||||
curl_socklen_t flag = 1;
|
curl_socklen_t flag;
|
||||||
int level = IPPROTO_TCP;
|
|
||||||
#endif
|
#endif
|
||||||
bool primary = FALSE;
|
bool primary = FALSE;
|
||||||
bool secondary = FALSE;
|
bool secondary = FALSE;
|
||||||
@ -1319,7 +1320,7 @@ static void http_connect(curl_socket_t *infdp,
|
|||||||
/* Sleep here to make sure the client reads CONNECT response's
|
/* Sleep here to make sure the client reads CONNECT response's
|
||||||
'end of headers' separate from the server data that follows.
|
'end of headers' separate from the server data that follows.
|
||||||
This is done to prevent triggering libcurl known bug #39. */
|
This is done to prevent triggering libcurl known bug #39. */
|
||||||
for(loop = 2; loop && !got_exit_signal; loop--)
|
for(loop = 2; (loop > 0) && !got_exit_signal; loop--)
|
||||||
wait_ms(250);
|
wait_ms(250);
|
||||||
if(got_exit_signal)
|
if(got_exit_signal)
|
||||||
goto http_connect_cleanup;
|
goto http_connect_cleanup;
|
||||||
@ -1417,15 +1418,22 @@ static void http_connect(curl_socket_t *infdp,
|
|||||||
logmsg("====> Client connect DATA");
|
logmsg("====> Client connect DATA");
|
||||||
#ifdef TCP_NODELAY
|
#ifdef TCP_NODELAY
|
||||||
/* Disable the Nagle algorithm */
|
/* Disable the Nagle algorithm */
|
||||||
if(setsockopt(datafd, level, TCP_NODELAY,
|
flag = 1;
|
||||||
(void *)&flag, sizeof(flag)) < 0)
|
if(0 != setsockopt(datafd, IPPROTO_TCP, TCP_NODELAY,
|
||||||
logmsg("====> TCP_NODELAY for client conection failed");
|
(void *)&flag, sizeof(flag)))
|
||||||
|
logmsg("====> TCP_NODELAY for client DATA conection failed");
|
||||||
|
else
|
||||||
|
logmsg("TCP_NODELAY set for client DATA conection");
|
||||||
#endif
|
#endif
|
||||||
req2.pipelining = FALSE;
|
req2.pipelining = FALSE;
|
||||||
err = get_request(datafd, &req2);
|
err = get_request(datafd, &req2);
|
||||||
if(!err) {
|
if(!err) {
|
||||||
err = send_doc(datafd, &req2);
|
err = send_doc(datafd, &req2);
|
||||||
if(!err && (req2.testno == DOCNUMBER_CONNECT)) {
|
if(!err && (req2.testno == DOCNUMBER_CONNECT)) {
|
||||||
|
/* sleep to prevent triggering libcurl known bug #39. */
|
||||||
|
for(loop = 2; (loop > 0) && !got_exit_signal; loop--)
|
||||||
|
wait_ms(250);
|
||||||
|
if(!got_exit_signal) {
|
||||||
/* connect to the server */
|
/* connect to the server */
|
||||||
serverfd[DATA] = connect_to(ipaddr, req2.connect_port);
|
serverfd[DATA] = connect_to(ipaddr, req2.connect_port);
|
||||||
if(serverfd[DATA] != CURL_SOCKET_BAD) {
|
if(serverfd[DATA] != CURL_SOCKET_BAD) {
|
||||||
@ -1443,6 +1451,7 @@ static void http_connect(curl_socket_t *infdp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(datafd != CURL_SOCKET_BAD) {
|
if(datafd != CURL_SOCKET_BAD) {
|
||||||
/* secondary tunnel not established */
|
/* secondary tunnel not established */
|
||||||
shutdown(datafd, SHUT_RDWR);
|
shutdown(datafd, SHUT_RDWR);
|
||||||
@ -1542,7 +1551,7 @@ static void http_connect(curl_socket_t *infdp,
|
|||||||
|
|
||||||
/* endpoint read/write disabling, endpoint closing and tunnel teardown */
|
/* endpoint read/write disabling, endpoint closing and tunnel teardown */
|
||||||
for(i = 0; i <= max_tunnel_idx; i++) {
|
for(i = 0; i <= max_tunnel_idx; i++) {
|
||||||
for(loop = 2; loop; loop--) {
|
for(loop = 2; loop > 0; loop--) {
|
||||||
/* loop twice to satisfy condition interdependencies without
|
/* loop twice to satisfy condition interdependencies without
|
||||||
having to await select timeout or another socket event */
|
having to await select timeout or another socket event */
|
||||||
if(clientfd[i] != CURL_SOCKET_BAD) {
|
if(clientfd[i] != CURL_SOCKET_BAD) {
|
||||||
@ -1580,7 +1589,7 @@ static void http_connect(curl_socket_t *infdp,
|
|||||||
|
|
||||||
/* socket clearing */
|
/* socket clearing */
|
||||||
for(i = 0; i <= max_tunnel_idx; i++) {
|
for(i = 0; i <= max_tunnel_idx; i++) {
|
||||||
for(loop = 2; loop; loop--) {
|
for(loop = 2; loop > 0; loop--) {
|
||||||
if(clientfd[i] != CURL_SOCKET_BAD) {
|
if(clientfd[i] != CURL_SOCKET_BAD) {
|
||||||
if(!poll_client_wr[i] && !poll_client_rd[i]) {
|
if(!poll_client_wr[i] && !poll_client_rd[i]) {
|
||||||
logmsg("[%s] CLOSING client socket", data_or_ctrl(i));
|
logmsg("[%s] CLOSING client socket", data_or_ctrl(i));
|
||||||
@ -1791,7 +1800,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
flag = 1;
|
flag = 1;
|
||||||
if (0 != setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
|
if(0 != setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
|
||||||
(void *)&flag, sizeof(flag))) {
|
(void *)&flag, sizeof(flag))) {
|
||||||
error = SOCKERRNO;
|
error = SOCKERRNO;
|
||||||
logmsg("setsockopt(SO_REUSEADDR) failed with error: (%d) %s",
|
logmsg("setsockopt(SO_REUSEADDR) failed with error: (%d) %s",
|
||||||
@ -1891,10 +1900,11 @@ int main(int argc, char *argv[])
|
|||||||
* response in many small segments to torture the clients more.
|
* response in many small segments to torture the clients more.
|
||||||
*/
|
*/
|
||||||
flag = 1;
|
flag = 1;
|
||||||
if (setsockopt(msgsock, IPPROTO_TCP, TCP_NODELAY,
|
if(0 != setsockopt(msgsock, IPPROTO_TCP, TCP_NODELAY,
|
||||||
(void *)&flag, sizeof(flag)) == -1) {
|
(void *)&flag, sizeof(flag)))
|
||||||
logmsg("====> TCP_NODELAY failed");
|
logmsg("====> TCP_NODELAY failed");
|
||||||
}
|
else
|
||||||
|
logmsg("TCP_NODELAY set");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* initialization of httprequest struct is done in get_request(), but due
|
/* initialization of httprequest struct is done in get_request(), but due
|
||||||
|
Loading…
x
Reference in New Issue
Block a user