Skip to content

Commit

Permalink
[~] added information about other errors
Browse files Browse the repository at this point in the history
[-] removed unnecessary "memset" calls after "calloc"
  • Loading branch information
Ya-Pasha-364shy committed Apr 17, 2024
1 parent d4c6884 commit 63f112a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 24 deletions.
21 changes: 19 additions & 2 deletions src/transport/xqc_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,38 +437,54 @@ xqc_engine_create(xqc_engine_type_t engine_type,
engine->config->cfg_log_event,
engine->config->cfg_log_timestamp,
engine->config->cfg_log_level_name,
&engine->eng_callback.log_callbacks, engine->user_data);
&engine->eng_callback.log_callbacks,
engine->user_data);

if (engine->log == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"unable to initialize logger in engine");
goto fail;
}

engine->rand_generator = xqc_random_generator_create(engine->log);
if (engine->rand_generator == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to initialize random generator in engine|");
goto fail;
}

engine->conns_hash = xqc_engine_conns_hash_create(engine->config);
if (engine->conns_hash == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to create connections hash|");
goto fail;
}

engine->conns_hash_dcid = xqc_engine_conns_hash_create(engine->config);
if (engine->conns_hash_dcid == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to create connections hash for reset packets|");
goto fail;
}

engine->conns_hash_sr_token = xqc_engine_conns_hash_create(engine->config);
if (engine->conns_hash_sr_token == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to create connections hash for stateless reset|");
goto fail;
}

engine->conns_active_pq = xqc_engine_conns_pq_create(engine->config);
if (engine->conns_active_pq == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to create priority queue|");
goto fail;
}

engine->conns_wait_wakeup_pq = xqc_engine_wakeup_pq_create(engine->config);
if (engine->conns_wait_wakeup_pq == NULL) {
xqc_log(engine->log, XQC_LOG_ERROR,
"|unable to create wakeup priority queue|");
goto fail;
}

Expand All @@ -477,11 +493,12 @@ xqc_engine_create(xqc_engine_type_t engine_type,
engine->tls_ctx = xqc_tls_ctx_create((xqc_tls_type_t)engine->eng_type, ssl_config,
&xqc_conn_tls_cbs, engine->log);
if (NULL == engine->tls_ctx) {
xqc_log(engine->log, XQC_LOG_ERROR, "|create tls context error");
xqc_log(engine->log, XQC_LOG_ERROR, "|create tls context error|");
goto fail;
}

} else {
xqc_log(engine->log, XQC_LOG_ERROR, "|invalid SSL configuration|");
goto fail;
}

Expand Down
3 changes: 1 addition & 2 deletions src/transport/xqc_multipath.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ xqc_path_create(xqc_connection_t *conn, xqc_cid_t *scid, xqc_cid_t *dcid)
if (path == NULL) {
return NULL;
}
xqc_memzero(path, sizeof(xqc_path_ctx_t));

path->path_state = XQC_PATH_STATE_INIT;
path->parent_conn = conn;
Expand Down Expand Up @@ -466,7 +465,7 @@ xqc_conn_create_path(xqc_engine_t *engine, const xqc_cid_t *scid, uint64_t *new_

path = xqc_conn_create_path_inner(conn, NULL, NULL, ps_inner);
if (path == NULL) {
xqc_log(conn->log, XQC_LOG_ERROR, "|xqc_path_create error|");
xqc_log(conn->log, XQC_LOG_ERROR, "|xqc_conn_create_path_inner error|");
return -XQC_EMP_CREATE_PATH;
}

Expand Down
7 changes: 0 additions & 7 deletions src/transport/xqc_send_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1699,13 +1699,6 @@ xqc_send_ctl_get_earliest_loss_time(xqc_send_ctl_t *send_ctl, xqc_pkt_num_space_
return time;
}


xqc_usec_t
xqc_send_ctl_get_srtt(xqc_send_ctl_t *send_ctl)
{
return send_ctl->ctl_srtt;
}

float
xqc_send_ctl_get_retrans_rate(xqc_send_ctl_t *send_ctl)
{
Expand Down
4 changes: 3 additions & 1 deletion src/transport/xqc_send_ctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ void xqc_send_ctl_set_loss_detection_timer(xqc_send_ctl_t *send_ctl);

xqc_usec_t xqc_send_ctl_get_earliest_loss_time(xqc_send_ctl_t *send_ctl, xqc_pkt_num_space_t *pns_ret);

xqc_usec_t xqc_send_ctl_get_srtt(xqc_send_ctl_t *send_ctl);
static inline xqc_usec_t xqc_send_ctl_get_srtt(xqc_send_ctl_t *send_ctl) {
return send_ctl->ctl_srtt;
}

float xqc_send_ctl_get_retrans_rate(xqc_send_ctl_t *send_ctl);

Expand Down
12 changes: 0 additions & 12 deletions tests/test_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,6 @@ xqc_convert_addr_text_to_sockaddr(int type,
{
if (type == AF_INET6) {
*saddr = calloc(1, sizeof(struct sockaddr_in6));
memset(*saddr, 0, sizeof(struct sockaddr_in6));
struct sockaddr_in6 *addr_v6 = (struct sockaddr_in6 *)(*saddr);
inet_pton(type, addr_text, &(addr_v6->sin6_addr.s6_addr));
addr_v6->sin6_family = type;
Expand All @@ -1470,7 +1469,6 @@ xqc_convert_addr_text_to_sockaddr(int type,

} else {
*saddr = calloc(1, sizeof(struct sockaddr_in));
memset(*saddr, 0, sizeof(struct sockaddr_in));
struct sockaddr_in *addr_v4 = (struct sockaddr_in *)(*saddr);
inet_pton(type, addr_text, &(addr_v4->sin_addr.s_addr));
addr_v4->sin_family = type;
Expand All @@ -1491,12 +1489,10 @@ xqc_client_init_addr(user_conn_t *user_conn,

if (ip_type == AF_INET6) {
user_conn->local_addr = (struct sockaddr *)calloc(1, sizeof(struct sockaddr_in6));
memset(user_conn->local_addr, 0, sizeof(struct sockaddr_in6));
user_conn->local_addrlen = sizeof(struct sockaddr_in6);

} else {
user_conn->local_addr = (struct sockaddr *)calloc(1, sizeof(struct sockaddr_in));
memset(user_conn->local_addr, 0, sizeof(struct sockaddr_in));
user_conn->local_addrlen = sizeof(struct sockaddr_in);
}
}
Expand All @@ -1512,13 +1508,6 @@ xqc_client_create_path_socket(xqc_user_path_t *path,
return XQC_ERROR;
}
#ifndef XQC_SYS_WINDOWS
if (path_interface != NULL
&& xqc_client_bind_to_interface(path->path_fd, path_interface) < 0)
{
printf("|xqc_client_bind_to_interface error|");
return XQC_ERROR;
}

if (g_test_case == 103 || g_test_case == 104) {
path->rebinding_path_fd = xqc_client_create_socket((g_ipv6 ? AF_INET6 : AF_INET),
path->peer_addr, path->peer_addrlen, path_interface);
Expand Down Expand Up @@ -3418,7 +3407,6 @@ xqc_client_timeout_callback(int fd, short what, void *arg)
restart_after_a_while--;
//we don't care the memory leak caused by user_stream. It's just for one-shot testing. :D
user_stream_t *user_stream = calloc(1, sizeof(user_stream_t));
memset(user_stream, 0, sizeof(user_stream_t));
user_stream->user_conn = user_conn;
printf("gtest 15: restart from idle!\n");
user_stream->stream = xqc_stream_create(ctx.engine, &(user_conn->cid), NULL, user_stream);
Expand Down

0 comments on commit 63f112a

Please sign in to comment.