mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Merge remote-tracking branch 'origin/master' into topic/johanna/clone
This commit is contained in:
commit
d13c939233
1389 changed files with 5408 additions and 12577 deletions
87
src/Val.cc
87
src/Val.cc
|
@ -1,6 +1,6 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include "bro-config.h"
|
||||
#include "zeek-config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -21,7 +21,6 @@
|
|||
#include "NetVar.h"
|
||||
#include "Expr.h"
|
||||
#include "Serializer.h"
|
||||
#include "RemoteSerializer.h"
|
||||
#include "PrefixTable.h"
|
||||
#include "Conn.h"
|
||||
#include "Reporter.h"
|
||||
|
@ -1630,18 +1629,9 @@ int TableVal::Assign(Val* index, HashKey* k, Val* new_val, Opcode op)
|
|||
else
|
||||
{
|
||||
// A set.
|
||||
if ( old_entry_val && remote_check_sync_consistency )
|
||||
{
|
||||
Val* has_old_val = val_mgr->GetInt(1);
|
||||
StateAccess::Log(
|
||||
new StateAccess(OP_ADD, this, index,
|
||||
has_old_val));
|
||||
Unref(has_old_val);
|
||||
}
|
||||
else
|
||||
StateAccess::Log(
|
||||
new StateAccess(OP_ADD, this,
|
||||
index, 0, 0));
|
||||
StateAccess::Log(
|
||||
new StateAccess(OP_ADD, this,
|
||||
index, 0, 0));
|
||||
}
|
||||
|
||||
if ( rec_index )
|
||||
|
@ -1929,29 +1919,30 @@ Val* TableVal::Default(Val* index)
|
|||
return def_attr->AttrExpr()->IsConst() ? def_val->Ref() : def_val->Clone();
|
||||
|
||||
const Func* f = def_val->AsFunc();
|
||||
val_list* vl = new val_list();
|
||||
val_list vl;
|
||||
|
||||
if ( index->Type()->Tag() == TYPE_LIST )
|
||||
{
|
||||
const val_list* vl0 = index->AsListVal()->Vals();
|
||||
vl = val_list(vl0->length());
|
||||
loop_over_list(*vl0, i)
|
||||
vl->append((*vl0)[i]->Ref());
|
||||
vl.append((*vl0)[i]->Ref());
|
||||
}
|
||||
else
|
||||
vl->append(index->Ref());
|
||||
{
|
||||
vl = val_list{index->Ref()};
|
||||
}
|
||||
|
||||
Val* result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
result = f->Call(vl);
|
||||
result = f->Call(&vl);
|
||||
}
|
||||
|
||||
catch ( InterpreterException& e )
|
||||
{ /* Already reported. */ }
|
||||
|
||||
delete vl;
|
||||
|
||||
if ( ! result )
|
||||
{
|
||||
Error("no value returned from &default function");
|
||||
|
@ -2124,20 +2115,12 @@ Val* TableVal::Delete(const Val* index)
|
|||
{
|
||||
if ( v )
|
||||
{
|
||||
if ( v->Value() && remote_check_sync_consistency )
|
||||
// A table.
|
||||
StateAccess::Log(
|
||||
new StateAccess(OP_DEL, this,
|
||||
index, v->Value()));
|
||||
else
|
||||
{
|
||||
// A set.
|
||||
Val* has_old_val = val_mgr->GetInt(1);
|
||||
StateAccess::Log(
|
||||
new StateAccess(OP_DEL, this, index,
|
||||
has_old_val));
|
||||
Unref(has_old_val);
|
||||
}
|
||||
// A set.
|
||||
Val* has_old_val = val_mgr->GetInt(1);
|
||||
StateAccess::Log(
|
||||
new StateAccess(OP_DEL, this, index,
|
||||
has_old_val));
|
||||
Unref(has_old_val);
|
||||
}
|
||||
else
|
||||
StateAccess::Log(
|
||||
|
@ -2491,21 +2474,6 @@ double TableVal::CallExpireFunc(Val* idx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
val_list* vl = new val_list;
|
||||
vl->append(Ref());
|
||||
|
||||
// Flatten lists of a single element.
|
||||
if ( idx->Type()->Tag() == TYPE_LIST &&
|
||||
idx->AsListVal()->Length() == 1 )
|
||||
{
|
||||
Val* old = idx;
|
||||
idx = idx->AsListVal()->Index(0);
|
||||
idx->Ref();
|
||||
Unref(old);
|
||||
}
|
||||
|
||||
vl->append(idx);
|
||||
|
||||
double secs = 0;
|
||||
|
||||
try
|
||||
|
@ -2515,19 +2483,31 @@ double TableVal::CallExpireFunc(Val* idx)
|
|||
if ( ! vf )
|
||||
{
|
||||
// Will have been reported already.
|
||||
delete_vals(vl);
|
||||
Unref(idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( vf->Type()->Tag() != TYPE_FUNC )
|
||||
{
|
||||
Unref(vf);
|
||||
delete_vals(vl);
|
||||
vf->Error("not a function");
|
||||
Unref(vf);
|
||||
Unref(idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Val* vs = vf->AsFunc()->Call(vl);
|
||||
|
||||
// Flatten lists of a single element.
|
||||
if ( idx->Type()->Tag() == TYPE_LIST &&
|
||||
idx->AsListVal()->Length() == 1 )
|
||||
{
|
||||
Val* old = idx;
|
||||
idx = idx->AsListVal()->Index(0);
|
||||
idx->Ref();
|
||||
Unref(old);
|
||||
}
|
||||
|
||||
val_list vl{Ref(), idx};
|
||||
Val* vs = vf->AsFunc()->Call(&vl);
|
||||
|
||||
if ( vs )
|
||||
{
|
||||
|
@ -2536,7 +2516,6 @@ double TableVal::CallExpireFunc(Val* idx)
|
|||
}
|
||||
|
||||
Unref(vf);
|
||||
delete vl;
|
||||
}
|
||||
|
||||
catch ( InterpreterException& e )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue