Skip to content

Commit c9c8c6a

Browse files
committed
API - ensure shutdown is only called once
1 parent 02604f8 commit c9c8c6a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

app/api/include/api/sonicpi_api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ class SonicPiAPI
338338
std::shared_ptr<kissnet::tcp_socket> m_bootDaemonSock;
339339

340340
std::mutex m_osc_mtx;
341+
bool m_shutdown_engaged = false;
341342
LogOption m_logOption;
342343

343344

app/api/src/sonicpi_api.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,24 @@ SonicPiAPI::~SonicPiAPI()
302302

303303
void SonicPiAPI::Shutdown()
304304
{
305-
LOG(INFO, "Shutdown");
305+
if(m_shutdown_engaged)
306+
{
307+
LOG(INFO, "Shutdown already initiated...");
308+
return;
309+
}
310+
311+
LOG(INFO, "Initiating Shutdown");
312+
306313
std::lock_guard<std::mutex> lg(m_osc_mtx);
307314

315+
if(m_shutdown_engaged)
316+
{
317+
LOG(INFO, "Shutdown already initiated..");
318+
return;
319+
}
320+
321+
m_shutdown_engaged = true;
322+
308323
switch(m_state)
309324
{
310325
case State::Reset :

0 commit comments

Comments
 (0)