mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Conn: Use conn_id_ctx singleton
This commit is contained in:
parent
eba6355b84
commit
906cec9adb
1 changed files with 11 additions and 1 deletions
12
src/Conn.cc
12
src/Conn.cc
|
@ -195,7 +195,17 @@ const RecordValPtr& Connection::GetVal() {
|
||||||
conn_val = make_intrusive<RecordVal>(id::connection);
|
conn_val = make_intrusive<RecordVal>(id::connection);
|
||||||
|
|
||||||
auto id_val = make_intrusive<RecordVal>(id::conn_id);
|
auto id_val = make_intrusive<RecordVal>(id::conn_id);
|
||||||
auto* ctx = id_val->GetFieldAs<zeek::RecordVal>(5);
|
|
||||||
|
constexpr int ctx_offset = 5;
|
||||||
|
|
||||||
|
// If the conn_id_ctx type has no fields at all, set it to the singleton instance,
|
||||||
|
// otherwise the instance is initialized on first access through GetField() below.
|
||||||
|
if ( conn_id_ctx_singleton ) {
|
||||||
|
assert(id::conn_id_ctx->NumFields() == 0);
|
||||||
|
id_val->Assign(ctx_offset, conn_id_ctx_singleton);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ctx = id_val->GetField<zeek::RecordVal>(ctx_offset);
|
||||||
|
|
||||||
// Allow customized ConnKeys to augment conn_id and ctx.
|
// Allow customized ConnKeys to augment conn_id and ctx.
|
||||||
key->PopulateConnIdVal(*id_val, *ctx);
|
key->PopulateConnIdVal(*id_val, *ctx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue