MCPcopy Create free account
hub / github.com/apache/trafficserver / handle_connect

Function handle_connect

tools/http_load/http_load.c:1118–1239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1116}
1117
1118static void
1119handle_connect(int cnum, struct timeval *nowP, int double_check)
1120{
1121 static int connect_failures = 0;
1122 int url_num;
1123 int r;
1124 struct epoll_event ev;
1125
1126#ifdef DEBUG
1127 fprintf(stderr, "Entering handle_connect() for CNUM %d\n", cnum);
1128#endif
1129
1130 url_num = connections[cnum].url_num;
1131 connections[cnum].stats.requests_per_connection = 0;
1132 if (double_check) {
1133 /* Check to make sure the non-blocking connect succeeded. */
1134 int err, errlen;
1135
1136 if (connect(connections[cnum].conn_fd, (struct sockaddr *)&connections[cnum].sa, connections[cnum].sa_len) < 0) {
1137 if (max_connect_failures && (++connect_failures > max_connect_failures))
1138 exit(0);
1139 switch (errno) {
1140 case EISCONN:
1141 /* Ok! */
1142 break;
1143 case EINVAL:
1144 errlen = sizeof(err);
1145 if (getsockopt(connections[cnum].conn_fd, SOL_SOCKET, SO_ERROR, (void *)&err, (socklen_t *)&errlen) < 0)
1146 (void)fprintf(stderr, "%s: unknown connect error\n", urls[url_num].url_str);
1147 else
1148 (void)fprintf(stderr, "%s: %s\n", urls[url_num].url_str, strerror(err));
1149 close_connection(cnum);
1150 return;
1151 default:
1152 perror(urls[url_num].url_str);
1153 close_connection(cnum);
1154 return;
1155 }
1156 }
1157 }
1158
1159 if (urls[url_num].protocol == PROTO_HTTPS) {
1160 int flags;
1161
1162 /* Make SSL connection. */
1163 if (ssl_ctx == (SSL_CTX *)0) {
1164 SSL_load_error_strings();
1165 SSL_library_init();
1166 ssl_ctx = SSL_CTX_new(SSLv23_client_method());
1167 if (ssl_ctx == NULL) {
1168 (void)fprintf(stderr, "%s: failed to create SSL_CTX\n", argv0);
1169 ERR_print_errors_fp(stderr);
1170 return;
1171 }
1172
1173 /* For some reason this does not seem to work, but indications are that it should...
1174 Maybe something with how we create connections? TODO: Fix it... */
1175 SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_NONE, cert_verify_callback);

Callers 2

mainFunction · 0.85
start_socketFunction · 0.85

Calls 3

close_connectionFunction · 0.85
randomFunction · 0.85
writeFunction · 0.50

Tested by

no test coverage detected