1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-17 21:35:45 +02:00

main: single BeesContext instance per process

After weeks of testing I copied part of a change to main without copying
the rest of the change, leading to an immediate segfault on startup.

So here is the rest of the change:  limit the number of
BeesContexts per process to 1.  This change was discussed at
https://github.com/Zygo/bees/issues/54#issuecomment-360332529 but there
are more reasons to do it now:  the candidates to replace the current
hash table format are less forgiving of sharing hash tables, and it may
even become necessary to have more than one hash table per BeesContext
instance (e.g. to keep datasum and nodatasum data separate).

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2018-10-31 16:42:46 -04:00
parent 9a9dd89177
commit 6e75857d71

View File

@ -32,7 +32,7 @@ using namespace std;
int bees_log_level = 8;
int
void
do_cmd_help(char *argv[])
{
// 80col 01234567890123456789012345678901234567890123456789012345678901234567890123456789
@ -73,7 +73,6 @@ do_cmd_help(char *argv[])
"\n"
// 80col 01234567890123456789012345678901234567890123456789012345678901234567890123456789
<< endl;
return 0;
}
// tracing ----------------------------------------
@ -654,11 +653,11 @@ bees_main(int argc, char *argv[])
BeesNote::set_name("bees");
BEESNOTE("main");
list<shared_ptr<BeesContext>> all_contexts;
shared_ptr<BeesContext> bc;
THROW_CHECK1(invalid_argument, argc, argc >= 0);
// Create a context so we can apply configuration to it
shared_ptr<BeesContext> bc = make_shared<BeesContext>();
string cwd(readlink_or_die("/proc/self/cwd"));
// Defaults
@ -704,7 +703,7 @@ bees_main(int argc, char *argv[])
// Parse options
int c;
while (1) {
while (true) {
int option_index = 0;
c = getopt_long(argc, argv, getopt_list.c_str(), long_options, &option_index);
@ -755,12 +754,17 @@ bees_main(int argc, char *argv[])
break;
case 'h':
do_cmd_help(argv); // fallthrough
default:
return 2;
do_cmd_help(argv);
return EXIT_FAILURE;
}
}
if (optind + 1 != argc) {
BEESLOGERR("Only one filesystem path per bees process");
return EXIT_FAILURE;
}
Chatter::enable_timestamp(chatter_prefix_timestamp);
if (!relative_path().empty()) {
@ -806,18 +810,7 @@ bees_main(int argc, char *argv[])
bc->roots()->set_workaround_btrfs_send(workaround_btrfs_send);
// Create a context and start crawlers
bool did_subscription = false;
while (optind < argc) {
catch_all([&]() {
bc = make_shared<BeesContext>(bc);
bc->set_root_path(argv[optind++]);
did_subscription = true;
});
}
if (!did_subscription) {
BEESLOGWARN("WARNING: no filesystems added");
}
bc->set_root_path(argv[optind++]);
BeesThread status_thread("status", [&]() {
bc->dump_status();
@ -827,7 +820,7 @@ bees_main(int argc, char *argv[])
bc->show_progress();
// That is all.
return 0;
return EXIT_SUCCESS;
}
int
@ -837,7 +830,7 @@ main(int argc, char *argv[])
if (argc < 2) {
do_cmd_help(argv);
return 2;
return EXIT_FAILURE;
}
int rv = 1;