Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/hostif/src/hostIf_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,6 @@ int main(int argc, char *argv[])
if(HTTPServerThread)
g_thread_join(HTTPServerThread);
#endif
#if defined(PARODUS_ENABLE)
if(parodus_init_tid)
pthread_join(parodus_init_tid,NULL);
#endif

RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"\n\n----------------------EXITING MAIN PROGRAM----------------------\n");
return 0 ;
Expand Down Expand Up @@ -596,8 +592,10 @@ void quit_handler (int sig_received)
void exit_gracefully (int sig_received)
{
if(isShutdownTriggered == 0) {
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] exit_gracefully called with signal %d\n", __FUNCTION__, __FILE__, sig_received);
if(pthread_mutex_trylock(&graceful_exit_mutex) == 0) {
RDK_LOG(RDK_LOG_NOTICE,LOG_TR69HOSTIF,"[%s:%s] Entering..\n", __FUNCTION__, __FILE__);
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Starting graceful shutdown steps\n", __FUNCTION__, __FILE__);
isShutdownTriggered = 1;
#ifdef T2_EVENT_ENABLED
t2_uninit();
Expand All @@ -613,37 +611,46 @@ void exit_gracefully (int sig_received)
#endif

/*Stop libSoup server and exit Json Thread */
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Stopping HTTP/Json threads\n", __FUNCTION__, __FILE__);
hostIf_HttpServerStop();

// Stop update polling and wait for the worker to exit before further teardown
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Stopping update handler\n", __FUNCTION__, __FILE__);
updateHandler::stop();
updateHandler::join();

updateHandler::join();

RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Stopping XBSStore\n", __FUNCTION__, __FILE__);
XBSStore::getInstance()->stop();

if(logfile) fclose (logfile);
if(logfile) {
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Closing logfile\n", __FUNCTION__, __FILE__);
fclose (logfile);
}

if(paramMgrhash) {
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Destroying paramMgrhash\n", __FUNCTION__, __FILE__);
g_hash_table_destroy(paramMgrhash);
paramMgrhash = NULL;
}
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Stopping IARM IF\n", __FUNCTION__, __FILE__);
hostIf_IARM_IF_Stop();

RDK_LOG(RDK_LOG_NOTICE,LOG_TR69HOSTIF,"[%s:%s] Exiting program gracefully..\n", __FUNCTION__, __FILE__);
if (g_main_loop_is_running(main_loop)) {
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Quitting main loop\n", __FUNCTION__, __FILE__);
g_main_loop_quit(main_loop);
#ifndef NEW_HTTP_SERVER_DISABLE
/*Stop HTTP Server Thread*/
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Stopping HTTP Server Thread\n", __FUNCTION__, __FILE__);
HttpServerStop();
#endif
}
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Unlocking Mutex..\n", __FUNCTION__, __FILE__);
RDK_LOG(RDK_LOG_INFO,LOG_TR69HOSTIF,"[%s:%s] Unlocking Mutex..\n", __FUNCTION__, __FILE__);
pthread_mutex_unlock(&graceful_exit_mutex);
}
}
}


//------------------------------------------------------------------------------
// hostIf_logger: logged the messages
//------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tr69hostif.service
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SyslogIdentifier="tr69hostif"
EnvironmentFile=/etc/device.properties
ExecStartPre=/bin/mkdir -p /opt/tr-181
ExecStart=/bin/sh -c '/usr/bin/tr69hostif -c /etc/mgrlist.conf -p 10999 -s 11999'
ExecStop=/bin/kill -15 $MAINPID
ExecStop=/bin/kill -9 $MAINPID
RestartSec=10s
Restart=always
TimeoutStopSec=5
Expand Down
Loading