mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Add Storage::is_connected BIF
This commit is contained in:
parent
cbc41e298d
commit
58ee8d3c5c
8 changed files with 42 additions and 0 deletions
|
@ -6,6 +6,7 @@ zeek_add_subdir_library(
|
||||||
Component.cc
|
Component.cc
|
||||||
ReturnCode.cc
|
ReturnCode.cc
|
||||||
BIFS
|
BIFS
|
||||||
|
storage.bif
|
||||||
storage-async.bif
|
storage-async.bif
|
||||||
storage-events.bif
|
storage-events.bif
|
||||||
storage-sync.bif)
|
storage-sync.bif)
|
||||||
|
|
24
src/storage/storage.bif
Normal file
24
src/storage/storage.bif
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
##! Functions related to general storage operations. These are not specific to async or sync.
|
||||||
|
|
||||||
|
%%{
|
||||||
|
|
||||||
|
#include "zeek/storage/Backend.h"
|
||||||
|
|
||||||
|
using namespace zeek;
|
||||||
|
using namespace zeek::storage;
|
||||||
|
|
||||||
|
%%}
|
||||||
|
|
||||||
|
module Storage;
|
||||||
|
|
||||||
|
## Checks whether a storage backend is open.
|
||||||
|
##
|
||||||
|
## backend: A handle to the backed to check.
|
||||||
|
##
|
||||||
|
## Returns: T if the backend is open, F if the backend is not open or if the handle
|
||||||
|
## is invalid.
|
||||||
|
function Storage::is_open%(backend: opaque of Storage::BackendHandle%) : bool
|
||||||
|
%{
|
||||||
|
auto b = storage::detail::BackendHandleVal::CastFromAny(backend);
|
||||||
|
return zeek::val_mgr->Bool(b.has_value());
|
||||||
|
%}
|
|
@ -160,6 +160,7 @@ scripts/base/init-frameworks-and-bifs.zeek
|
||||||
build/scripts/base/bif/bloom-filter.bif.zeek
|
build/scripts/base/bif/bloom-filter.bif.zeek
|
||||||
build/scripts/base/bif/cardinality-counter.bif.zeek
|
build/scripts/base/bif/cardinality-counter.bif.zeek
|
||||||
build/scripts/base/bif/top-k.bif.zeek
|
build/scripts/base/bif/top-k.bif.zeek
|
||||||
|
build/scripts/base/bif/storage.bif.zeek
|
||||||
build/scripts/base/bif/storage-async.bif.zeek
|
build/scripts/base/bif/storage-async.bif.zeek
|
||||||
build/scripts/base/bif/storage-events.bif.zeek
|
build/scripts/base/bif/storage-events.bif.zeek
|
||||||
build/scripts/base/bif/storage-sync.bif.zeek
|
build/scripts/base/bif/storage-sync.bif.zeek
|
||||||
|
|
|
@ -160,6 +160,7 @@ scripts/base/init-frameworks-and-bifs.zeek
|
||||||
build/scripts/base/bif/bloom-filter.bif.zeek
|
build/scripts/base/bif/bloom-filter.bif.zeek
|
||||||
build/scripts/base/bif/cardinality-counter.bif.zeek
|
build/scripts/base/bif/cardinality-counter.bif.zeek
|
||||||
build/scripts/base/bif/top-k.bif.zeek
|
build/scripts/base/bif/top-k.bif.zeek
|
||||||
|
build/scripts/base/bif/storage.bif.zeek
|
||||||
build/scripts/base/bif/storage-async.bif.zeek
|
build/scripts/base/bif/storage-async.bif.zeek
|
||||||
build/scripts/base/bif/storage-events.bif.zeek
|
build/scripts/base/bif/storage-events.bif.zeek
|
||||||
build/scripts/base/bif/storage-sync.bif.zeek
|
build/scripts/base/bif/storage-sync.bif.zeek
|
||||||
|
|
|
@ -509,6 +509,7 @@
|
||||||
0.000000 MetaHookPost LoadFile(0, ./storage-async.bif.zeek, <...>/storage-async.bif.zeek) -> -1
|
0.000000 MetaHookPost LoadFile(0, ./storage-async.bif.zeek, <...>/storage-async.bif.zeek) -> -1
|
||||||
0.000000 MetaHookPost LoadFile(0, ./storage-events.bif.zeek, <...>/storage-events.bif.zeek) -> -1
|
0.000000 MetaHookPost LoadFile(0, ./storage-events.bif.zeek, <...>/storage-events.bif.zeek) -> -1
|
||||||
0.000000 MetaHookPost LoadFile(0, ./storage-sync.bif.zeek, <...>/storage-sync.bif.zeek) -> -1
|
0.000000 MetaHookPost LoadFile(0, ./storage-sync.bif.zeek, <...>/storage-sync.bif.zeek) -> -1
|
||||||
|
0.000000 MetaHookPost LoadFile(0, ./storage.bif.zeek, <...>/storage.bif.zeek) -> -1
|
||||||
0.000000 MetaHookPost LoadFile(0, ./store, <...>/store.zeek) -> -1
|
0.000000 MetaHookPost LoadFile(0, ./store, <...>/store.zeek) -> -1
|
||||||
0.000000 MetaHookPost LoadFile(0, ./store.bif.zeek, <...>/store.bif.zeek) -> -1
|
0.000000 MetaHookPost LoadFile(0, ./store.bif.zeek, <...>/store.bif.zeek) -> -1
|
||||||
0.000000 MetaHookPost LoadFile(0, ./strings.bif.zeek, <...>/strings.bif.zeek) -> -1
|
0.000000 MetaHookPost LoadFile(0, ./strings.bif.zeek, <...>/strings.bif.zeek) -> -1
|
||||||
|
@ -822,6 +823,7 @@
|
||||||
0.000000 MetaHookPost LoadFileExtended(0, ./storage-async.bif.zeek, <...>/storage-async.bif.zeek) -> (-1, <no content>)
|
0.000000 MetaHookPost LoadFileExtended(0, ./storage-async.bif.zeek, <...>/storage-async.bif.zeek) -> (-1, <no content>)
|
||||||
0.000000 MetaHookPost LoadFileExtended(0, ./storage-events.bif.zeek, <...>/storage-events.bif.zeek) -> (-1, <no content>)
|
0.000000 MetaHookPost LoadFileExtended(0, ./storage-events.bif.zeek, <...>/storage-events.bif.zeek) -> (-1, <no content>)
|
||||||
0.000000 MetaHookPost LoadFileExtended(0, ./storage-sync.bif.zeek, <...>/storage-sync.bif.zeek) -> (-1, <no content>)
|
0.000000 MetaHookPost LoadFileExtended(0, ./storage-sync.bif.zeek, <...>/storage-sync.bif.zeek) -> (-1, <no content>)
|
||||||
|
0.000000 MetaHookPost LoadFileExtended(0, ./storage.bif.zeek, <...>/storage.bif.zeek) -> (-1, <no content>)
|
||||||
0.000000 MetaHookPost LoadFileExtended(0, ./store, <...>/store.zeek) -> (-1, <no content>)
|
0.000000 MetaHookPost LoadFileExtended(0, ./store, <...>/store.zeek) -> (-1, <no content>)
|
||||||
0.000000 MetaHookPost LoadFileExtended(0, ./store.bif.zeek, <...>/store.bif.zeek) -> (-1, <no content>)
|
0.000000 MetaHookPost LoadFileExtended(0, ./store.bif.zeek, <...>/store.bif.zeek) -> (-1, <no content>)
|
||||||
0.000000 MetaHookPost LoadFileExtended(0, ./strings.bif.zeek, <...>/strings.bif.zeek) -> (-1, <no content>)
|
0.000000 MetaHookPost LoadFileExtended(0, ./strings.bif.zeek, <...>/strings.bif.zeek) -> (-1, <no content>)
|
||||||
|
@ -1469,6 +1471,7 @@
|
||||||
0.000000 MetaHookPre LoadFile(0, ./storage-async.bif.zeek, <...>/storage-async.bif.zeek)
|
0.000000 MetaHookPre LoadFile(0, ./storage-async.bif.zeek, <...>/storage-async.bif.zeek)
|
||||||
0.000000 MetaHookPre LoadFile(0, ./storage-events.bif.zeek, <...>/storage-events.bif.zeek)
|
0.000000 MetaHookPre LoadFile(0, ./storage-events.bif.zeek, <...>/storage-events.bif.zeek)
|
||||||
0.000000 MetaHookPre LoadFile(0, ./storage-sync.bif.zeek, <...>/storage-sync.bif.zeek)
|
0.000000 MetaHookPre LoadFile(0, ./storage-sync.bif.zeek, <...>/storage-sync.bif.zeek)
|
||||||
|
0.000000 MetaHookPre LoadFile(0, ./storage.bif.zeek, <...>/storage.bif.zeek)
|
||||||
0.000000 MetaHookPre LoadFile(0, ./store, <...>/store.zeek)
|
0.000000 MetaHookPre LoadFile(0, ./store, <...>/store.zeek)
|
||||||
0.000000 MetaHookPre LoadFile(0, ./store.bif.zeek, <...>/store.bif.zeek)
|
0.000000 MetaHookPre LoadFile(0, ./store.bif.zeek, <...>/store.bif.zeek)
|
||||||
0.000000 MetaHookPre LoadFile(0, ./strings.bif.zeek, <...>/strings.bif.zeek)
|
0.000000 MetaHookPre LoadFile(0, ./strings.bif.zeek, <...>/strings.bif.zeek)
|
||||||
|
@ -1782,6 +1785,7 @@
|
||||||
0.000000 MetaHookPre LoadFileExtended(0, ./storage-async.bif.zeek, <...>/storage-async.bif.zeek)
|
0.000000 MetaHookPre LoadFileExtended(0, ./storage-async.bif.zeek, <...>/storage-async.bif.zeek)
|
||||||
0.000000 MetaHookPre LoadFileExtended(0, ./storage-events.bif.zeek, <...>/storage-events.bif.zeek)
|
0.000000 MetaHookPre LoadFileExtended(0, ./storage-events.bif.zeek, <...>/storage-events.bif.zeek)
|
||||||
0.000000 MetaHookPre LoadFileExtended(0, ./storage-sync.bif.zeek, <...>/storage-sync.bif.zeek)
|
0.000000 MetaHookPre LoadFileExtended(0, ./storage-sync.bif.zeek, <...>/storage-sync.bif.zeek)
|
||||||
|
0.000000 MetaHookPre LoadFileExtended(0, ./storage.bif.zeek, <...>/storage.bif.zeek)
|
||||||
0.000000 MetaHookPre LoadFileExtended(0, ./store, <...>/store.zeek)
|
0.000000 MetaHookPre LoadFileExtended(0, ./store, <...>/store.zeek)
|
||||||
0.000000 MetaHookPre LoadFileExtended(0, ./store.bif.zeek, <...>/store.bif.zeek)
|
0.000000 MetaHookPre LoadFileExtended(0, ./store.bif.zeek, <...>/store.bif.zeek)
|
||||||
0.000000 MetaHookPre LoadFileExtended(0, ./strings.bif.zeek, <...>/strings.bif.zeek)
|
0.000000 MetaHookPre LoadFileExtended(0, ./strings.bif.zeek, <...>/strings.bif.zeek)
|
||||||
|
@ -2440,6 +2444,7 @@
|
||||||
0.000000 | HookLoadFile ./storage-async.bif.zeek <...>/storage-async.bif.zeek
|
0.000000 | HookLoadFile ./storage-async.bif.zeek <...>/storage-async.bif.zeek
|
||||||
0.000000 | HookLoadFile ./storage-events.bif.zeek <...>/storage-events.bif.zeek
|
0.000000 | HookLoadFile ./storage-events.bif.zeek <...>/storage-events.bif.zeek
|
||||||
0.000000 | HookLoadFile ./storage-sync.bif.zeek <...>/storage-sync.bif.zeek
|
0.000000 | HookLoadFile ./storage-sync.bif.zeek <...>/storage-sync.bif.zeek
|
||||||
|
0.000000 | HookLoadFile ./storage.bif.zeek <...>/storage.bif.zeek
|
||||||
0.000000 | HookLoadFile ./store <...>/store.zeek
|
0.000000 | HookLoadFile ./store <...>/store.zeek
|
||||||
0.000000 | HookLoadFile ./store.bif.zeek <...>/store.bif.zeek
|
0.000000 | HookLoadFile ./store.bif.zeek <...>/store.bif.zeek
|
||||||
0.000000 | HookLoadFile ./strings.bif.zeek <...>/strings.bif.zeek
|
0.000000 | HookLoadFile ./strings.bif.zeek <...>/strings.bif.zeek
|
||||||
|
@ -2753,6 +2758,7 @@
|
||||||
0.000000 | HookLoadFileExtended ./storage-async.bif.zeek <...>/storage-async.bif.zeek
|
0.000000 | HookLoadFileExtended ./storage-async.bif.zeek <...>/storage-async.bif.zeek
|
||||||
0.000000 | HookLoadFileExtended ./storage-events.bif.zeek <...>/storage-events.bif.zeek
|
0.000000 | HookLoadFileExtended ./storage-events.bif.zeek <...>/storage-events.bif.zeek
|
||||||
0.000000 | HookLoadFileExtended ./storage-sync.bif.zeek <...>/storage-sync.bif.zeek
|
0.000000 | HookLoadFileExtended ./storage-sync.bif.zeek <...>/storage-sync.bif.zeek
|
||||||
|
0.000000 | HookLoadFileExtended ./storage.bif.zeek <...>/storage.bif.zeek
|
||||||
0.000000 | HookLoadFileExtended ./store <...>/store.zeek
|
0.000000 | HookLoadFileExtended ./store <...>/store.zeek
|
||||||
0.000000 | HookLoadFileExtended ./store.bif.zeek <...>/store.bif.zeek
|
0.000000 | HookLoadFileExtended ./store.bif.zeek <...>/store.bif.zeek
|
||||||
0.000000 | HookLoadFileExtended ./strings.bif.zeek <...>/strings.bif.zeek
|
0.000000 | HookLoadFileExtended ./strings.bif.zeek <...>/strings.bif.zeek
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
Open result, [code=Storage::OPERATION_FAILED, error_str=Failed to open backend Storage::STORAGE_BACKEND_SQLITE: SQLite call failed: unable to open database file, value=<opaque of BackendHandleVal>]
|
Open result, [code=Storage::OPERATION_FAILED, error_str=Failed to open backend Storage::STORAGE_BACKEND_SQLITE: SQLite call failed: unable to open database file, value=<opaque of BackendHandleVal>]
|
||||||
Open result 2, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<opaque of BackendHandleVal>]
|
Open result 2, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<opaque of BackendHandleVal>]
|
||||||
|
Opened handle is open, T
|
||||||
Put result with bad key type, [code=Storage::KEY_TYPE_MISMATCH, error_str=<uninitialized>, value=<uninitialized>]
|
Put result with bad key type, [code=Storage::KEY_TYPE_MISMATCH, error_str=<uninitialized>, value=<uninitialized>]
|
||||||
|
Closed backend is open, F
|
||||||
Put result on closed handle, [code=Storage::NOT_CONNECTED, error_str=Backend is closed, value=<uninitialized>]
|
Put result on closed handle, [code=Storage::NOT_CONNECTED, error_str=Backend is closed, value=<uninitialized>]
|
||||||
|
|
|
@ -178,6 +178,7 @@ global known_BiFs = set(
|
||||||
"Reporter::warning",
|
"Reporter::warning",
|
||||||
"Spicy::__resource_usage",
|
"Spicy::__resource_usage",
|
||||||
"Spicy::__toggle_analyzer",
|
"Spicy::__toggle_analyzer",
|
||||||
|
"Storage::is_open",
|
||||||
"Storage::Async::__close_backend",
|
"Storage::Async::__close_backend",
|
||||||
"Storage::Async::__erase",
|
"Storage::Async::__erase",
|
||||||
"Storage::Async::__get",
|
"Storage::Async::__get",
|
||||||
|
|
|
@ -24,6 +24,8 @@ event zeek_init() {
|
||||||
|
|
||||||
local b = open_res$value;
|
local b = open_res$value;
|
||||||
|
|
||||||
|
print "Opened handle is open", Storage::is_open(b);
|
||||||
|
|
||||||
local bad_key: count = 12345;
|
local bad_key: count = 12345;
|
||||||
local value = "abcde";
|
local value = "abcde";
|
||||||
local res = Storage::Sync::put(b, [$key=bad_key, $value=value]);
|
local res = Storage::Sync::put(b, [$key=bad_key, $value=value]);
|
||||||
|
@ -31,6 +33,10 @@ event zeek_init() {
|
||||||
|
|
||||||
# Close the backend and then attempt to use the closed handle
|
# Close the backend and then attempt to use the closed handle
|
||||||
Storage::Sync::close_backend(b);
|
Storage::Sync::close_backend(b);
|
||||||
|
|
||||||
|
# Test if the now-closed backend is open.
|
||||||
|
print "Closed backend is open", Storage::is_open(b);
|
||||||
|
|
||||||
local res2 = Storage::Sync::put(b, [$key="a", $value="b"]);
|
local res2 = Storage::Sync::put(b, [$key="a", $value="b"]);
|
||||||
print "Put result on closed handle", res2;
|
print "Put result on closed handle", res2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue