Skip to content

Commit

Permalink
Fix some unitialized fields in client struct (#1126)
Browse files Browse the repository at this point in the history
This commit adds initialization code for the fields
`io_last_reply_block` and `io_last_bufpos` of the `client` struct.

While in the current code flow, these fields are only accessed after
being written in the `trySendWriteToIOThreads`, I discovered that they
were not being initialized while doing some changes to the code flow of
IO threads.

I believe it's good pratice to initialize all fields of a struct upon
creation, and will avoid future bugs which are usually hard to debug.

Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
  • Loading branch information
rjd15372 authored Oct 4, 2024
1 parent dcac3e1 commit 6a8540c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ client *createClient(connection *conn) {
c->net_output_bytes = 0;
c->net_output_bytes_curr_cmd = 0;
c->commands_processed = 0;
c->io_last_reply_block = NULL;
c->io_last_bufpos = 0;
return c;
}

Expand Down

0 comments on commit 6a8540c

Please sign in to comment.