diff --git a/contrib/ruby/test/client_test.rb b/contrib/ruby/test/client_test.rb index b6f7bfff..6b968e98 100644 --- a/contrib/ruby/test/client_test.rb +++ b/contrib/ruby/test/client_test.rb @@ -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 diff --git a/src/builder.c b/src/builder.c index 6603412f..5ecb40d5 100644 --- a/src/builder.c +++ b/src/builder.c @@ -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; }