static void sxe_load_connect_ramp_tcp(void) { unsigned int i; SXE_RETURN result; unsigned int connection_id; SXEE60("tcp_connect_ramp()"); for (i = 0; i < sxe_load_connect_ramp; i++) { connection_id = sxe_pool_set_oldest_element_state(sxe_load_connection_pool, SXE_LOAD_CONNECTION_STATE_FREE, SXE_LOAD_CONNECTION_STATE_AWAITING_CONNECT); if (connection_id == SXE_POOL_NO_INDEX) { SXEL60("All connections established"); goto SXE_EARLY_OUT; } /* loop until we can bind and connect successfully (port/ip chosen might already be inuse by the system) */ do { sxe_load_connection_pool[connection_id].connection = sxe_new_tcp(NULL, sxe_load_client_ip_as_text[sxe_load_client_ip_index], sxe_load_next_port, sxe_load_event_connect_tcp, sxe_load_event_read_client_tcp, sxe_load_event_close_tcp); result = sxe_connect(sxe_load_connection_pool[connection_id].connection, sxe_load_server_ip, sxe_load_server_port); sxe_load_client_ip_index++; if (sxe_load_client_ip_index == sxe_load_client_ip_count) { sxe_load_client_ip_index = 0; sxe_load_next_port--; if (sxe_load_next_port <= 1024) { sxe_load_next_port = 65535; } } if (result != SXE_RETURN_OK) { sxe_close(sxe_load_connection_pool[connection_id].connection); } } while (result != SXE_RETURN_OK); SXEL60("Starting new tcp connection"); /* save the pool index in the SXE extra data */ SXE_USER_DATA_AS_INT(sxe_load_connection_pool[connection_id].connection) = connection_id; sxe_load_connection_pool[connection_id].connecting_time = sxe_time_get(); sxe_load_connection_pool[connection_id].queries_completed = 0; } SXE_EARLY_OR_ERROR_OUT: SXER60("return"); }
{ "GET / HTTP/1.0\r\nA B\r\n\r\n", TEST_400 }, { "GET / HTTP/1.0\r\n:B\r\n\r\n", TEST_400 }, { "GET / HTTP/1.0\r\n A:B\r\n\r\n", TEST_400 }, { "POST / HTTP/1.1\r\nContent-Length:\r\n\r\n", TEST_400 }, /* Empty Content-Length */ { "POST / HTTP/1.1\r\nContent-Length: non-numeric\r\n\r\n", TEST_400 }, { A1000 A1000, TEST_414 }, }; static SXE * listener; static tap_ev_queue tq_client; static tap_ev_queue tq_server; static void test_event_connect(SXE * this) { SXEE61I("test_event_connect(id=%u)", SXE_USER_DATA_AS_INT(this)); tap_ev_queue_push(tq_client, __func__, 1, "this", this); SXER60I("return"); } static void test_event_read(SXE * this, int length) { SXE_UNUSED_PARAMETER(length); SXEE63I("test_event_read(id=%u, length=%u): response length %u", SXE_USER_DATA_AS_INT(this), length, SXE_BUF_USED(this)); tap_ev_queue_push(tq_client, __func__, 3, "this", this, "buf", tap_dup(SXE_BUF(this), SXE_BUF_USED(this)), "used", SXE_BUF_USED(this)); sxe_buf_clear(this); SXER60I("return"); } static void
static void test_event_ready_to_write(SXE_POOL_TCP * pool, void * info) { SXE_UNUSED_ARGUMENT(pool); SXE_UNUSED_ARGUMENT(info); SXEE6("test_event_ready_to_write(pool=%s, info=%p)", SXE_POOL_TCP_GET_NAME(pool), info); tap_ev_push(__func__, 0); sxe_pool_tcp_write(pool, write_data, strlen(write_data), NULL); SXER6("return"); } static void test_event_connected(SXE* this) { SXEE6I("test_event_connected()"); tap_ev_push("test_event_connected", 1, "pid", SXE_USER_DATA_AS_INT(this)); SXER6I("return"); } static void test_event_read(SXE * this, int length) { SXEE6I("test_event_read(length=%d)", length); SXEA1(length != 0, "Read event has length == 0"); tap_ev_push(__func__, 3, "this", this, "length", length, "buf", tap_dup(SXE_BUF(this), length)); SXE_BUF_CLEAR(this); SXER6I("return"); } static void test_event_close(SXE * this)