From ea6d565d41c9f780f6307f7b6d0cf97fdf8a352b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 07:45:35 +1030 Subject: [PATCH] packetbeat/protos{,/amqp}: fix transaction hash size constant (#36723) (#36731) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The transaction hash size is currently calculated as 2⊕16 (18) which is most likely not what was intended. The code entered the code base in the initial import which does not have an associated review. However, the symbol ^ signifies exponent in other languages, and XOR is almost never what someone would use for defining a constant like this, so it is very likely that the original author intended a 64Ki cache size. (cherry picked from commit df10d97e8ea1d8dd948d066025076a252e688971) Co-authored-by: Dan Kortschak <90160302+efd6@users.noreply.github.com> --- CHANGELOG.next.asciidoc | 1 + packetbeat/protos/amqp/amqp_structs.go | 2 +- packetbeat/protos/protos.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 685ddb2d060..c7428267700 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -88,6 +88,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] *Packetbeat* +- Fix default cache size calculation. {pull}36723[36723] *Winlogbeat* diff --git a/packetbeat/protos/amqp/amqp_structs.go b/packetbeat/protos/amqp/amqp_structs.go index 7abba4fc914..de31fce6af3 100644 --- a/packetbeat/protos/amqp/amqp_structs.go +++ b/packetbeat/protos/amqp/amqp_structs.go @@ -27,7 +27,7 @@ import ( type amqpMethod func(*amqpMessage, []byte) (bool, bool) const ( - transactionsHashSize = 2 ^ 16 + transactionsHashSize = 1 << 16 transactionTimeout = 10 * 1e9 ) diff --git a/packetbeat/protos/protos.go b/packetbeat/protos/protos.go index 23c79750370..3841db8f91b 100644 --- a/packetbeat/protos/protos.go +++ b/packetbeat/protos/protos.go @@ -33,7 +33,7 @@ import ( ) const ( - DefaultTransactionHashSize = 2 ^ 16 + DefaultTransactionHashSize = 1 << 16 DefaultTransactionExpiration time.Duration = 10 * time.Second )