Skip to content

Commit

Permalink
GH-985 Fix FC_ASSERT on exit when socket closed
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Nov 12, 2024
1 parent 98b3061 commit 46ca22d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ class code_cache_async : public code_cache_base {
void wait_on_compile_monitor_message();
std::tuple<size_t, size_t> consume_compile_thread_queue();
void process_queued_compiles();
void write_message(const code_tuple& ct, const eosvmoc_message& message, const std::vector<wrapped_fd>& fds);

};

class code_cache_sync : public code_cache_base {
Expand Down
17 changes: 11 additions & 6 deletions libraries/chain/webassembly/runtimes/eos-vm-oc/code_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,22 @@ void code_cache_async::wait_on_compile_monitor_message() {
});
}

//call with _mtx locked
void code_cache_async::write_message(const code_tuple& ct, const eosvmoc_message& message, const std::vector<wrapped_fd>& fds) {
_outstanding_compiles_and_poison.emplace(ct, false);
++_outstanding_compiles;
if (!write_message_with_fds(_compile_monitor_write_socket, message, fds)) {
wlog("EOS VM failed to communicate to OOP manager");
}
}

//called from non-main thread
void code_cache_async::process_queued_compiles() {
std::lock_guard g(_mtx);
while (_outstanding_compiles < _threads && !_queued_compiles.empty()) {
auto nextup = _queued_compiles.begin();

_outstanding_compiles_and_poison.emplace(nextup->code(), false);
++_outstanding_compiles;
FC_ASSERT(write_message_with_fds(_compile_monitor_write_socket, nextup->msg, nextup->fds_to_pass), "EOS VM failed to communicate to OOP manager");
write_message(nextup->code(), nextup->msg, nextup->fds_to_pass);

_queued_compiles.erase(nextup);
}
Expand Down Expand Up @@ -214,9 +221,7 @@ code_cache_async::get_descriptor_for_code(mode m, uint64_t executing_action_id,
return nullptr;
}

_outstanding_compiles_and_poison.emplace(ct, false);
++_outstanding_compiles;
write_message_with_fds(_compile_monitor_write_socket, msg, fds_to_pass);
write_message(ct, msg, fds_to_pass);
failure = get_cd_failure::temporary; // Compile might not be done yet
return nullptr;
}
Expand Down

0 comments on commit 46ca22d

Please sign in to comment.