builtin/network, builtin/client_file: Don't start thread in constructor because in there the module is not guaranteed to be available by server->access_module(), which the thread uses
This commit is contained in:
parent
4f0bf40772
commit
674146f8c7
@ -58,10 +58,6 @@ struct Module: public interface::Module, public client_file::Interface
|
||||
m_watch(interface::createFileWatch())
|
||||
{
|
||||
log_d(MODULE, "client_file construct");
|
||||
|
||||
m_thread.reset(interface::createThread(new FileWatchThread(this)));
|
||||
m_thread->set_name("client_file/select");
|
||||
m_thread->start();
|
||||
}
|
||||
|
||||
~Module()
|
||||
@ -82,6 +78,12 @@ struct Module: public interface::Module, public client_file::Interface
|
||||
Event::t("network:packet_received/core:request_file"));
|
||||
m_server->sub_event(this,
|
||||
Event::t("network:packet_received/core:all_files_transferred"));
|
||||
|
||||
// Don't start thread in constructor because in there this module is not
|
||||
// guaranteed to be available by server->access_module()
|
||||
m_thread.reset(interface::createThread(new FileWatchThread(this)));
|
||||
m_thread->set_name("client_file/select");
|
||||
m_thread->start();
|
||||
}
|
||||
|
||||
void event(const Event::Type &type, const Event::Private *p)
|
||||
|
@ -69,10 +69,6 @@ struct Module: public interface::Module, public network::Interface
|
||||
m_listening_socket(interface::createTCPSocket())
|
||||
{
|
||||
log_d(MODULE, "network construct");
|
||||
|
||||
m_thread.reset(interface::createThread(new NetworkThread(this)));
|
||||
m_thread->set_name("network/select");
|
||||
m_thread->start();
|
||||
}
|
||||
|
||||
~Module()
|
||||
@ -101,6 +97,12 @@ struct Module: public interface::Module, public network::Interface
|
||||
m_server->sub_event(this, Event::t("core:start"));
|
||||
m_server->sub_event(this, Event::t("core:unload"));
|
||||
m_server->sub_event(this, Event::t("core:continue"));
|
||||
|
||||
// Don't start thread in constructor because in there this module is not
|
||||
// guaranteed to be available by server->access_module()
|
||||
m_thread.reset(interface::createThread(new NetworkThread(this)));
|
||||
m_thread->set_name("network/select");
|
||||
m_thread->start();
|
||||
}
|
||||
|
||||
void event(const Event::Type &type, const Event::Private *p)
|
||||
|
Loading…
x
Reference in New Issue
Block a user