Skip to content

Commit

Permalink
packetbeat/protos{,/amqp}: fix transaction hash size constant (#36723)
Browse files Browse the repository at this point in the history
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 df10d97)
  • Loading branch information
efd6 authored and mergify[bot] committed Oct 3, 2023
1 parent 10b17d8 commit 773840d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
*Packetbeat*

- Fix panic in HTTP protocol parsing when host header has empty host part. {issue}36497[36497] {issue}36518[36518]
- Fix default cache size calculation. {pull}36723[36723]

*Winlogbeat*

Expand Down
2 changes: 1 addition & 1 deletion packetbeat/protos/amqp/amqp_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
type amqpMethod func(*amqpMessage, []byte) (bool, bool)

const (
transactionsHashSize = 2 ^ 16
transactionsHashSize = 1 << 16

Check failure on line 29 in packetbeat/protos/amqp/amqp_structs.go

View workflow job for this annotation

GitHub Actions / lint (windows)

`transactionsHashSize` is unused (varcheck)
transactionTimeout = 10 * 1e9
)

Expand Down
2 changes: 1 addition & 1 deletion packetbeat/protos/protos.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

const (
DefaultTransactionHashSize = 2 ^ 16
DefaultTransactionHashSize = 1 << 16
DefaultTransactionExpiration time.Duration = 10 * time.Second
)

Expand Down

0 comments on commit 773840d

Please sign in to comment.