mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
Use consistent hashing method for internal lambda function names
The results of std::hash<std::string> may vary depending on platform. E.g. test suite failed on macOS due to Linux generating different lambda function names.
This commit is contained in:
parent
851a11086d
commit
8575c9daed
2 changed files with 317 additions and 315 deletions
|
@ -14,6 +14,7 @@
|
|||
#include "Traverse.h"
|
||||
#include "Trigger.h"
|
||||
#include "IPAddr.h"
|
||||
#include "digest.h"
|
||||
|
||||
#include "broker/Data.h"
|
||||
|
||||
|
@ -4338,9 +4339,10 @@ LambdaExpr::LambdaExpr(std::unique_ptr<function_ingredients> arg_ing,
|
|||
// Get the body's "string" representation.
|
||||
ODesc d;
|
||||
dummy_func->Describe(&d);
|
||||
const char* desc = d.Description();
|
||||
uint64_t h[2];
|
||||
internal_md5(d.Bytes(), d.Len(), reinterpret_cast<unsigned char*>(h));
|
||||
|
||||
my_name = "lambda_<" + std::to_string(std::hash<std::string>()(std::string(desc))) + ">";
|
||||
my_name = "lambda_<" + std::to_string(h[0]) + ">";
|
||||
|
||||
// Install that in the global_scope
|
||||
ID* id = install_ID(my_name.c_str(), current_module.c_str(), true, false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue