From 7591a39cfda66e45e8b2f7993e49bb61d8d89e21 Mon Sep 17 00:00:00 2001 From: Michael Theall Date: Wed, 8 Apr 2020 23:36:29 -0500 Subject: [PATCH] Initialize nifm session for network check --- source/ftpServer.cpp | 13 +++++-------- source/switch/init.c | 2 ++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/source/ftpServer.cpp b/source/ftpServer.cpp index 601f3e4..da0511f 100644 --- a/source/ftpServer.cpp +++ b/source/ftpServer.cpp @@ -165,12 +165,6 @@ std::time_t FtpServer::startTime () void FtpServer::handleNetworkFound () { - { - auto lock = std::scoped_lock (m_lock); - if (m_socket) - return; - } - struct sockaddr_in addr; addr.sin_family = AF_INET; #if defined(_3DS) || defined(__SWITCH__) @@ -216,8 +210,11 @@ void FtpServer::handleNetworkLost () void FtpServer::loop () { - if (platform::networkVisible ()) - handleNetworkFound (); + if (!m_socket) + { + if (platform::networkVisible ()) + handleNetworkFound (); + } // poll listen socket if (m_socket) diff --git a/source/switch/init.c b/source/switch/init.c index 3df6113..31e985f 100644 --- a/source/switch/init.c +++ b/source/switch/init.c @@ -56,6 +56,7 @@ void userAppInit () romfsInit (); plInitialize (); + nifmInitialize (NifmServiceType_User); if (R_FAILED (socketInitialize (&s_socketInitConfig))) return; @@ -76,6 +77,7 @@ void userAppExit () } #endif + nifmExit (); plExit (); romfsExit (); appletUnlockExit ();