comparison OrthancServer/ServerContext.cpp @ 2738:3a55b77339ff

fix deadlock in Lua scripts
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Jul 2018 11:19:30 +0200
parents 1b4ba91fe795
children 37583cd183ed
comparison
equal deleted inserted replaced
2737:8ed9893c9230 2738:3a55b77339ff
133 133
134 134
135 void ServerContext::SignalJobSubmitted(const std::string& jobId) 135 void ServerContext::SignalJobSubmitted(const std::string& jobId)
136 { 136 {
137 haveJobsChanged_ = true; 137 haveJobsChanged_ = true;
138 lua_.SignalJobSubmitted(jobId); 138 mainLua_.SignalJobSubmitted(jobId);
139 } 139 }
140 140
141 141
142 void ServerContext::SignalJobSuccess(const std::string& jobId) 142 void ServerContext::SignalJobSuccess(const std::string& jobId)
143 { 143 {
144 haveJobsChanged_ = true; 144 haveJobsChanged_ = true;
145 lua_.SignalJobSuccess(jobId); 145 mainLua_.SignalJobSuccess(jobId);
146 } 146 }
147 147
148 148
149 void ServerContext::SignalJobFailure(const std::string& jobId) 149 void ServerContext::SignalJobFailure(const std::string& jobId)
150 { 150 {
151 haveJobsChanged_ = true; 151 haveJobsChanged_ = true;
152 lua_.SignalJobFailure(jobId); 152 mainLua_.SignalJobFailure(jobId);
153 } 153 }
154 154
155 155
156 void ServerContext::SetupJobsEngine(bool unitTesting, 156 void ServerContext::SetupJobsEngine(bool unitTesting,
157 bool loadJobsFromDatabase) 157 bool loadJobsFromDatabase)
223 area_(area), 223 area_(area),
224 compressionEnabled_(false), 224 compressionEnabled_(false),
225 storeMD5_(true), 225 storeMD5_(true),
226 provider_(*this), 226 provider_(*this),
227 dicomCache_(provider_, DICOM_CACHE_SIZE), 227 dicomCache_(provider_, DICOM_CACHE_SIZE),
228 lua_(*this), 228 mainLua_(*this),
229 filterLua_(*this),
230 luaListener_(*this),
229 #if ORTHANC_ENABLE_PLUGINS == 1 231 #if ORTHANC_ENABLE_PLUGINS == 1
230 plugins_(NULL), 232 plugins_(NULL),
231 #endif 233 #endif
232 done_(false), 234 done_(false),
233 haveJobsChanged_(false), 235 haveJobsChanged_(false),
234 queryRetrieveArchive_(Configuration::GetGlobalUnsignedIntegerParameter("QueryRetrieveSize", 10)), 236 queryRetrieveArchive_(Configuration::GetGlobalUnsignedIntegerParameter("QueryRetrieveSize", 10)),
235 defaultLocalAet_(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC")) 237 defaultLocalAet_(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC"))
236 { 238 {
237 listeners_.push_back(ServerListener(lua_, "Lua")); 239 listeners_.push_back(ServerListener(luaListener_, "Lua"));
238 240
239 SetupJobsEngine(unitTesting, loadJobsFromDatabase); 241 SetupJobsEngine(unitTesting, loadJobsFromDatabase);
240 242
241 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100)); 243 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100));
242 saveJobsThread_ = boost::thread(SaveJobsThread, this, (unitTesting ? 20 : 100)); 244 saveJobsThread_ = boost::thread(SaveJobsThread, this, (unitTesting ? 20 : 100));
697 699
698 plugins_ = &plugins; 700 plugins_ = &plugins;
699 701
700 // TODO REFACTOR THIS 702 // TODO REFACTOR THIS
701 listeners_.clear(); 703 listeners_.clear();
702 listeners_.push_back(ServerListener(lua_, "Lua")); 704 listeners_.push_back(ServerListener(luaListener_, "Lua"));
703 listeners_.push_back(ServerListener(plugins, "plugin")); 705 listeners_.push_back(ServerListener(plugins, "plugin"));
704 } 706 }
705 707
706 708
707 void ServerContext::ResetPlugins() 709 void ServerContext::ResetPlugins()
710 712
711 plugins_ = NULL; 713 plugins_ = NULL;
712 714
713 // TODO REFACTOR THIS 715 // TODO REFACTOR THIS
714 listeners_.clear(); 716 listeners_.clear();
715 listeners_.push_back(ServerListener(lua_, "Lua")); 717 listeners_.push_back(ServerListener(luaListener_, "Lua"));
716 } 718 }
717 719
718 720
719 const OrthancPlugins& ServerContext::GetPlugins() const 721 const OrthancPlugins& ServerContext::GetPlugins() const
720 { 722 {