Skip to content

Commit

Permalink
Merge pull request #203 from trilogy-libraries/fix_max_allowed_packet
Browse files Browse the repository at this point in the history
Fix max_allowed_packet math
  • Loading branch information
jhawthorn authored Oct 11, 2024
2 parents 204ee88 + 698722e commit 2010e23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions contrib/ruby/test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,12 @@ def test_configured_max_packet_below_server

assert_equal "trilogy_query_send: TRILOGY_MAX_PACKET_EXCEEDED", exception.message

exception = assert_raises Trilogy::QueryError do
client.query query_for_target_packet_size(32 * 1024 * 1024 + 1)
end

assert_equal "trilogy_query_send: TRILOGY_MAX_PACKET_EXCEEDED", exception.message

assert client.ping
ensure
ensure_closed client
Expand Down
2 changes: 1 addition & 1 deletion src/builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int trilogy_builder_write_buffer(trilogy_builder_t *builder, const void *data, s

size_t fragment_remaining = TRILOGY_MAX_PACKET_LEN - builder->fragment_length;

if (builder->packet_length >= builder->packet_max_length - len) {
if (builder->packet_length + len >= builder->packet_max_length) {
return TRILOGY_MAX_PACKET_EXCEEDED;
}

Expand Down

0 comments on commit 2010e23

Please sign in to comment.