mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Cleanup/improve PList usage and Event API
Majority of PLists are now created as automatic/stack objects, rather than on heap and initialized either with the known-capacity reserved upfront or directly from an initializer_list (so there's no wasted slack in the memory that gets allocated for lists containing a fixed/known number of elements). Added versions of the ConnectionEvent/QueueEvent methods that take a val_list by value. Added a move ctor/assign-operator to Plists to allow passing them around without having to copy the underlying array of pointers.
This commit is contained in:
parent
78dcbcc71a
commit
8bc65f09ec
92 changed files with 1585 additions and 1679 deletions
|
@ -147,9 +147,9 @@ int NFS_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_status,
|
|||
|
||||
if ( nfs_reply_status )
|
||||
{
|
||||
val_list* vl = event_common_vl(c, rpc_status, nfs_status,
|
||||
start_time, last_time, reply_len);
|
||||
analyzer->ConnectionEvent(nfs_reply_status, vl);
|
||||
auto vl = event_common_vl(c, rpc_status, nfs_status,
|
||||
start_time, last_time, reply_len, 0);
|
||||
analyzer->ConnectionEvent(nfs_reply_status, std::move(vl));
|
||||
}
|
||||
|
||||
if ( ! rpc_success )
|
||||
|
@ -274,18 +274,18 @@ int NFS_Interp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status rpc_status,
|
|||
// optional and all are set to 0 ...
|
||||
if ( event )
|
||||
{
|
||||
val_list* vl = event_common_vl(c, rpc_status, nfs_status,
|
||||
start_time, last_time, reply_len);
|
||||
|
||||
Val *request = c->TakeRequestVal();
|
||||
|
||||
auto vl = event_common_vl(c, rpc_status, nfs_status,
|
||||
start_time, last_time, reply_len, (bool)request + (bool)reply);
|
||||
|
||||
if ( request )
|
||||
vl->append(request);
|
||||
vl.append(request);
|
||||
|
||||
if ( reply )
|
||||
vl->append(reply);
|
||||
vl.append(reply);
|
||||
|
||||
analyzer->ConnectionEvent(event, vl);
|
||||
analyzer->ConnectionEvent(event, std::move(vl));
|
||||
}
|
||||
else
|
||||
Unref(reply);
|
||||
|
@ -317,15 +317,15 @@ StringVal* NFS_Interp::nfs3_file_data(const u_char*& buf, int& n, uint64_t offse
|
|||
return 0;
|
||||
}
|
||||
|
||||
val_list* NFS_Interp::event_common_vl(RPC_CallInfo *c, BifEnum::rpc_status rpc_status,
|
||||
val_list NFS_Interp::event_common_vl(RPC_CallInfo *c, BifEnum::rpc_status rpc_status,
|
||||
BifEnum::NFS3::status_t nfs_status,
|
||||
double rep_start_time,
|
||||
double rep_last_time, int reply_len)
|
||||
double rep_last_time, int reply_len, int extra_elements)
|
||||
{
|
||||
// Returns a new val_list that already has a conn_val, and nfs3_info.
|
||||
// These are the first parameters for each nfs_* event ...
|
||||
val_list *vl = new val_list;
|
||||
vl->append(analyzer->BuildConnVal());
|
||||
val_list vl(2 + extra_elements);
|
||||
vl.append(analyzer->BuildConnVal());
|
||||
VectorVal* auxgids = new VectorVal(internal_type("index_vec")->AsVectorType());
|
||||
|
||||
for ( size_t i = 0; i < c->AuxGIDs().size(); ++i )
|
||||
|
@ -346,7 +346,7 @@ val_list* NFS_Interp::event_common_vl(RPC_CallInfo *c, BifEnum::rpc_status rpc_s
|
|||
info->Assign(11, new StringVal(c->MachineName()));
|
||||
info->Assign(12, auxgids);
|
||||
|
||||
vl->append(info);
|
||||
vl.append(info);
|
||||
return vl;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue