Skip to content

Commit

Permalink
Don't use sig_atomic_t on Windows.
Browse files Browse the repository at this point in the history
We don't setup signal handler on Windows, so we can replace
`volatil sig_atomic_t` by simple `bool`.
  • Loading branch information
mgautierfr committed Aug 30, 2024
1 parent 6ea97c3 commit 9a3a68c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/server/kiwix-serve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,9 @@ inline std::string normalizeRootUrl(std::string rootUrl)
return rootUrl.empty() ? rootUrl : "/" + rootUrl;
}

#ifndef _WIN32
volatile sig_atomic_t waiting = false;
volatile sig_atomic_t libraryMustBeReloaded = false;

#ifndef _WIN32
void handle_sigterm(int signum)
{
if ( waiting == false ) {
Expand Down Expand Up @@ -144,6 +143,9 @@ void setup_sighandlers()
set_signal_handler(SIGINT, &handle_sigterm);
set_signal_handler(SIGHUP, &handle_sighup);
}
#else
bool waiting = false;
bool libraryMustBeReloaded = false;
#endif

uint64_t fileModificationTime(const std::string& path)
Expand Down Expand Up @@ -422,7 +424,11 @@ int main(int argc, char** argv)

if ( monitorLibrary ) {
curLibraryFileTimestamp = newestFileTimestamp(libraryPaths);
#ifndef _WIN32
libraryMustBeReloaded += curLibraryFileTimestamp > libraryFileTimestamp;
#else
libraryMustBeReloaded |= curLibraryFileTimestamp > libraryFileTimestamp;
#endif
}

if ( libraryMustBeReloaded && !libraryPaths.empty() ) {
Expand Down

0 comments on commit 9a3a68c

Please sign in to comment.