mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 13:38:19 +00:00
Remove StateAccess class.
This commit is contained in:
parent
02214dafc4
commit
31ddca863c
8 changed files with 14 additions and 744 deletions
130
src/Val.cc
130
src/Val.cc
|
@ -438,8 +438,6 @@ ID* MutableVal::Bind() const
|
|||
"%u", ++id_counter);
|
||||
name[MAX_NAME_SIZE-1] = '\0';
|
||||
|
||||
// DBG_LOG(DBG_STATE, "new unique ID %s", name);
|
||||
|
||||
id = new ID(name, SCOPE_GLOBAL, true);
|
||||
id->SetType(const_cast<MutableVal*>(this)->Type()->Ref());
|
||||
|
||||
|
@ -457,8 +455,6 @@ void MutableVal::TransferUniqueID(MutableVal* mv)
|
|||
if ( ! id )
|
||||
Bind();
|
||||
|
||||
DBG_LOG(DBG_STATE, "transfering ID (new %s, old/alias %s)", new_name, id->Name());
|
||||
|
||||
// Keep old name as alias.
|
||||
aliases.push_back(id);
|
||||
|
||||
|
@ -1178,55 +1174,6 @@ int TableVal::Assign(Val* index, HashKey* k, Val* new_val, Opcode op)
|
|||
subnets->Insert(index, new_entry_val);
|
||||
}
|
||||
|
||||
if ( LoggingAccess() && op != OP_NONE )
|
||||
{
|
||||
Val* rec_index = 0;
|
||||
if ( ! index )
|
||||
index = rec_index = RecoverIndex(&k_copy);
|
||||
|
||||
if ( new_val )
|
||||
{
|
||||
// A table.
|
||||
if ( new_val->IsMutableVal() )
|
||||
new_val->AsMutableVal()->AddProperties(GetProperties());
|
||||
|
||||
bool unref_old_val = false;
|
||||
Val* old_val = old_entry_val ?
|
||||
old_entry_val->Value() : 0;
|
||||
if ( op == OP_INCR && ! old_val )
|
||||
// If it's an increment, somebody has already
|
||||
// checked that the index is there. If it's
|
||||
// not, that can only be due to using the
|
||||
// default.
|
||||
{
|
||||
old_val = Default(index);
|
||||
unref_old_val = true;
|
||||
}
|
||||
|
||||
assert(op != OP_INCR || old_val);
|
||||
|
||||
StateAccess::Log(
|
||||
new StateAccess(
|
||||
op == OP_INCR ?
|
||||
OP_INCR_IDX : OP_ASSIGN_IDX,
|
||||
this, index, new_val, old_val));
|
||||
|
||||
if ( unref_old_val )
|
||||
Unref(old_val);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// A set.
|
||||
StateAccess::Log(
|
||||
new StateAccess(OP_ADD, this,
|
||||
index, 0, 0));
|
||||
}
|
||||
|
||||
if ( rec_index )
|
||||
Unref(rec_index);
|
||||
}
|
||||
|
||||
// Keep old expiration time if necessary.
|
||||
if ( old_entry_val && attrs && attrs->FindAttr(ATTR_EXPIRE_CREATE) )
|
||||
new_entry_val->SetExpireAccess(old_entry_val->ExpireAccessTime());
|
||||
|
@ -1237,6 +1184,7 @@ int TableVal::Assign(Val* index, HashKey* k, Val* new_val, Opcode op)
|
|||
delete old_entry_val;
|
||||
}
|
||||
|
||||
Modified();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1556,11 +1504,7 @@ Val* TableVal::Lookup(Val* index, bool use_default_val)
|
|||
if ( v )
|
||||
{
|
||||
if ( attrs && attrs->FindAttr(ATTR_EXPIRE_READ) )
|
||||
{
|
||||
v->SetExpireAccess(network_time);
|
||||
if ( LoggingAccess() && ExpirationEnabled() )
|
||||
ReadOperation(index, v);
|
||||
}
|
||||
|
||||
return v->Value() ? v->Value() : this;
|
||||
}
|
||||
|
@ -1587,11 +1531,7 @@ Val* TableVal::Lookup(Val* index, bool use_default_val)
|
|||
if ( v )
|
||||
{
|
||||
if ( attrs && attrs->FindAttr(ATTR_EXPIRE_READ) )
|
||||
{
|
||||
v->SetExpireAccess(network_time);
|
||||
if ( LoggingAccess() && ExpirationEnabled() )
|
||||
ReadOperation(index, v);
|
||||
}
|
||||
|
||||
return v->Value() ? v->Value() : this;
|
||||
}
|
||||
|
@ -1645,11 +1585,7 @@ TableVal* TableVal::LookupSubnetValues(const SubNetVal* search)
|
|||
if ( entry )
|
||||
{
|
||||
if ( attrs && attrs->FindAttr(ATTR_EXPIRE_READ) )
|
||||
{
|
||||
entry->SetExpireAccess(network_time);
|
||||
if ( LoggingAccess() && ExpirationEnabled() )
|
||||
ReadOperation(s, entry);
|
||||
}
|
||||
}
|
||||
|
||||
Unref(s); // assign does not consume index
|
||||
|
@ -1679,8 +1615,6 @@ bool TableVal::UpdateTimestamp(Val* index)
|
|||
return false;
|
||||
|
||||
v->SetExpireAccess(network_time);
|
||||
if ( LoggingAccess() && attrs->FindAttr(ATTR_EXPIRE_READ) )
|
||||
ReadOperation(index, v);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1699,25 +1633,10 @@ Val* TableVal::Delete(const Val* index)
|
|||
if ( subnets && ! subnets->Remove(index) )
|
||||
reporter->InternalWarning("index not in prefix table");
|
||||
|
||||
if ( LoggingAccess() )
|
||||
{
|
||||
if ( v )
|
||||
{
|
||||
// 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(
|
||||
new StateAccess(OP_DEL, this, index, 0));
|
||||
}
|
||||
|
||||
delete k;
|
||||
delete v;
|
||||
|
||||
Modified();
|
||||
return va;
|
||||
}
|
||||
|
||||
|
@ -1736,9 +1655,7 @@ Val* TableVal::Delete(const HashKey* k)
|
|||
|
||||
delete v;
|
||||
|
||||
if ( LoggingAccess() )
|
||||
StateAccess::Log(new StateAccess(OP_DEL, this, k));
|
||||
|
||||
Modified();
|
||||
return va;
|
||||
}
|
||||
|
||||
|
@ -1949,6 +1866,7 @@ void TableVal::DoExpire(double t)
|
|||
HashKey* k = 0;
|
||||
TableEntryVal* v = 0;
|
||||
TableEntryVal* v_saved = 0;
|
||||
bool modified = false;
|
||||
|
||||
for ( int i = 0; i < table_incremental_step &&
|
||||
(v = tbl->NextEntry(k, expire_cookie)); ++i )
|
||||
|
@ -2001,18 +1919,18 @@ void TableVal::DoExpire(double t)
|
|||
Unref(index);
|
||||
}
|
||||
|
||||
if ( LoggingAccess() )
|
||||
StateAccess::Log(
|
||||
new StateAccess(OP_EXPIRE, this, k));
|
||||
|
||||
tbl->RemoveEntry(k);
|
||||
Unref(v->Value());
|
||||
delete v;
|
||||
modified = true;
|
||||
}
|
||||
|
||||
delete k;
|
||||
}
|
||||
|
||||
if ( modified )
|
||||
Modified();
|
||||
|
||||
if ( ! v )
|
||||
{
|
||||
expire_cookie = 0;
|
||||
|
@ -2124,10 +2042,7 @@ void TableVal::ReadOperation(Val* index, TableEntryVal* v)
|
|||
// practical issues such as latency, we send one update every half
|
||||
// &read_expire.
|
||||
if ( network_time - v->LastReadUpdate() > timeout / 2 )
|
||||
{
|
||||
StateAccess::Log(new StateAccess(OP_READ_IDX, this, index));
|
||||
v->SetLastReadUpdate(network_time);
|
||||
}
|
||||
}
|
||||
|
||||
Val* TableVal::DoClone(CloneState* state)
|
||||
|
@ -2307,21 +2222,8 @@ RecordVal::~RecordVal()
|
|||
void RecordVal::Assign(int field, Val* new_val, Opcode op)
|
||||
{
|
||||
Val* old_val = AsNonConstRecord()->replace(field, new_val);
|
||||
|
||||
if ( LoggingAccess() && op != OP_NONE )
|
||||
{
|
||||
if ( new_val && new_val->IsMutableVal() )
|
||||
new_val->AsMutableVal()->AddProperties(GetProperties());
|
||||
|
||||
StringVal* index = new StringVal(Type()->AsRecordType()->FieldName(field));
|
||||
StateAccess::Log(
|
||||
new StateAccess(
|
||||
op == OP_INCR ? OP_INCR_IDX : OP_ASSIGN_IDX,
|
||||
this, index, new_val, old_val));
|
||||
Unref(index); // The logging may keep a cached copy.
|
||||
}
|
||||
|
||||
Unref(old_val);
|
||||
Modified();
|
||||
}
|
||||
|
||||
Val* RecordVal::Lookup(int field) const
|
||||
|
@ -2627,19 +2529,6 @@ bool VectorVal::Assign(unsigned int index, Val* element, Opcode op)
|
|||
else
|
||||
val.vector_val->resize(index + 1);
|
||||
|
||||
if ( LoggingAccess() && op != OP_NONE )
|
||||
{
|
||||
if ( element->IsMutableVal() )
|
||||
element->AsMutableVal()->AddProperties(GetProperties());
|
||||
|
||||
Val* ival = val_mgr->GetCount(index);
|
||||
|
||||
StateAccess::Log(new StateAccess(op == OP_INCR ?
|
||||
OP_INCR_IDX : OP_ASSIGN_IDX,
|
||||
this, ival, element, val_at_index));
|
||||
Unref(ival);
|
||||
}
|
||||
|
||||
Unref(val_at_index);
|
||||
|
||||
// Note: we do *not* Ref() the element, if any, at this point.
|
||||
|
@ -2647,6 +2536,7 @@ bool VectorVal::Assign(unsigned int index, Val* element, Opcode op)
|
|||
// to do it similarly.
|
||||
(*val.vector_val)[index] = element;
|
||||
|
||||
Modified();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue