From 4534b51f5e36aa33e58c49c4939a189a451ea88f Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 10 Oct 2017 14:39:42 +0200 Subject: [PATCH] Use printf instead of cout. `std::cout` stream is not thread safe at all. Printing from different threads can lead to corrupted stream (and no output working). Using `printf` may still lead to interleaved output but nothing will broke. --- src/server/kiwix-serve.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 0c385f4..54c1775 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -320,7 +320,7 @@ static struct MHD_Response* handle_suggest( = MHD_lookup_connection_value(connection, MHD_GET_ARGUMENT_KIND, "term"); std::string term = cTerm == NULL ? "" : cTerm; if (isVerbose.load()) { - std::cout << "Searching suggestions for: \"" << term << "\"" << endl; + printf("Searching suggestions for: \"%s\"\n", term.c_str()); } pthread_mutex_lock(&searchLock); @@ -496,7 +496,7 @@ static struct MHD_Response* handle_content( if (!found) { if (isVerbose.load()) - cout << "Failed to find " << urlStr << endl; + printf("Failed to find %s\n", urlStr.c_str()); content = "\n