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

Function start_connection

tools/http_load/http_load.c:917–989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

915}
916
917static void
918start_connection(struct timeval *nowP)
919{
920 int cnum, url_num;
921 static int cycle_slot = 0;
922
923 /* Find an empty connection slot. */
924 if (socket_pool > 0) {
925 int prev_cycle_slot = cycle_slot;
926
927 while (1) {
928 ++cycle_slot;
929 if (cycle_slot > socket_pool)
930 cycle_slot = 0;
931 if (prev_cycle_slot == cycle_slot) {
932 return;
933#if 0
934 /* Unused right now, not sure why */
935 printf("Warning: cycling through all socket slots\n");
936 tmr_run(nowP);
937#endif
938 }
939 if (connections[cycle_slot].conn_state == CNST_FREE) {
940 /* Choose a URL. */
941 if (do_sequential) {
942 url_num = cur_url++;
943 if (cur_url >= num_urls)
944 cur_url = 0;
945 } else {
946 url_num = ((unsigned long)random()) % ((unsigned int)num_urls);
947 }
948
949 /* Start the socket. */
950 start_socket(url_num, cycle_slot, nowP);
951 if (connections[cycle_slot].conn_state != CNST_FREE) {
952 ++num_connections;
953 /*
954 if ( num_connections > max_parallel )
955 max_parallel = num_connections;
956 */
957 }
958 ++fetches_started;
959 return;
960 }
961 }
962 } else {
963 for (cnum = 0; cnum < max_connections; ++cnum)
964 if (connections[cnum].conn_state == CNST_FREE) {
965 /* Choose a URL. */
966 if (do_sequential) {
967 url_num = cur_url++;
968 if (cur_url >= num_urls)
969 cur_url = 0;
970 } else {
971 url_num = ((unsigned long)random()) % ((unsigned int)num_urls);
972 }
973 /* Start the socket. */
974 start_socket(url_num, cnum, nowP);

Callers 2

mainFunction · 0.85
start_timerFunction · 0.85

Calls 4

tmr_runFunction · 0.85
randomFunction · 0.85
start_socketFunction · 0.85
finishFunction · 0.85

Tested by

no test coverage detected