aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2014-04-20 17:40:30 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2014-04-20 17:40:30 +0100
commit6fce2811afb366d53af6c234ff06bbb611e03378 (patch)
tree36f538a00fe39673b5f51ed373a69f8aa35f42f5
parent6799335fe963065080cee343cfecb32b58af4651 (diff)
downloadpaludis-6fce2811afb366d53af6c234ff06bbb611e03378.tar.gz
paludis-6fce2811afb366d53af6c234ff06bbb611e03378.tar.xz
I hate std::thread
-rw-r--r--src/clients/cave/resolve_common.cc82
1 files changed, 46 insertions, 36 deletions
diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc
index 835e767..fc89c82 100644
--- a/src/clients/cave/resolve_common.cc
+++ b/src/clients/cave/resolve_common.cc
@@ -261,52 +261,62 @@ namespace
std::ref(ser_stream),
std::cref(*resolved)));
- std::shared_ptr<Sequence<std::string> > args(std::make_shared<Sequence<std::string>>());
+ int result;
- for (args::ArgsSection::GroupsConstIterator g(display_options.begin()), g_end(display_options.end()) ;
- g != g_end ; ++g)
+ try
{
- for (args::ArgsGroup::ConstIterator o(g->begin()), o_end(g->end()) ;
- o != o_end ; ++o)
- if ((*o)->specified())
- {
- const std::shared_ptr<const Sequence<std::string> > f((*o)->forwardable_args());
- std::copy(f->begin(), f->end(), args->back_inserter());
- }
- }
+ std::shared_ptr<Sequence<std::string> > args(std::make_shared<Sequence<std::string>>());
- for (Sequence<std::pair<std::string, std::string> >::ConstIterator p(targets->begin()), p_end(targets->end()) ;
- p != p_end ; ++p)
- args->push_back(p->first);
+ for (args::ArgsSection::GroupsConstIterator g(display_options.begin()), g_end(display_options.end()) ;
+ g != g_end ; ++g)
+ {
+ for (args::ArgsGroup::ConstIterator o(g->begin()), o_end(g->end()) ;
+ o != o_end ; ++o)
+ if ((*o)->specified())
+ {
+ const std::shared_ptr<const Sequence<std::string> > f((*o)->forwardable_args());
+ std::copy(f->begin(), f->end(), args->back_inserter());
+ }
+ }
- int result;
- if (program_options.a_display_resolution_program.specified())
- {
- std::string command(program_options.a_display_resolution_program.argument());
+ for (Sequence<std::pair<std::string, std::string> >::ConstIterator p(targets->begin()), p_end(targets->end()) ;
+ p != p_end ; ++p)
+ args->push_back(p->first);
- if (keys_if_import)
- for (Map<std::string, std::string>::ConstIterator k(keys_if_import->begin()),
- k_end(keys_if_import->end()) ;
- k != k_end ; ++k)
- {
- args->push_back("--unpackaged-repository-params");
- args->push_back(k->first + "=" + k->second);
- }
+ if (program_options.a_display_resolution_program.specified())
+ {
+ std::string command(program_options.a_display_resolution_program.argument());
- for (Sequence<std::string>::ConstIterator a(args->begin()), a_end(args->end()) ;
- a != a_end ; ++a)
- command = command + " " + args::escape(*a);
+ if (keys_if_import)
+ for (Map<std::string, std::string>::ConstIterator k(keys_if_import->begin()),
+ k_end(keys_if_import->end()) ;
+ k != k_end ; ++k)
+ {
+ args->push_back("--unpackaged-repository-params");
+ args->push_back(k->first + "=" + k->second);
+ }
- Process process((ProcessCommand(command)));
- process
- .send_input_to_fd(ser_stream, -1, "PALUDIS_SERIALISED_RESOLUTION_FD");
+ for (Sequence<std::string>::ConstIterator a(args->begin()), a_end(args->end()) ;
+ a != a_end ; ++a)
+ command = command + " " + args::escape(*a);
- result = process.run().wait();
+ Process process((ProcessCommand(command)));
+ process
+ .send_input_to_fd(ser_stream, -1, "PALUDIS_SERIALISED_RESOLUTION_FD");
+
+ result = process.run().wait();
+ }
+ else
+ result = DisplayResolutionCommand().run(env, args, resolved);
+
+ ser_thread.join();
+ }
+ catch (...)
+ {
+ ser_thread.join();
+ throw;
}
- else
- result = DisplayResolutionCommand().run(env, args, resolved);
- ser_thread.join();
return result;
}