From e771f05f3f5b8fe14e9529323fa0610e6e978509 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Sat, 29 Jul 2017 21:46:21 -0700 Subject: [PATCH] Linux build fixes --- src/command_line.cc | 25 ++++++++++++------------ src/project.cc | 4 +++- src/serializer.cc | 7 +++++++ src/serializer.h | 5 ++++- src/threaded_queue.h | 2 +- src/tiny-process-library/process_win.cpp | 4 +++- wscript | 3 +++ 7 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/command_line.cc b/src/command_line.cc index 75868f70..9f3e9f65 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -834,10 +834,10 @@ struct CacheManager { } std::unique_ptr UpdateAndReturnOldFile(std::unique_ptr entry) { - auto& it = files_.find(entry->file->path); + const auto it = files_.find(entry->file->path); if (it != files_.end()) { std::unique_ptr old = std::move(it->second); - it->second = std::move(entry); + files_[entry->file->path] = std::move(entry); return old; } @@ -1252,7 +1252,7 @@ struct InProcessIndexer : IIndexerProcess { ThreadedQueue* messages_; Index_IndexProcess_Request_IndexQueue queue_; std::vector indexer_threads_; - std::atomic num_busy_indexers_ = 0; + std::atomic num_busy_indexers_; Config config_; IQueryDbResponder* responder_; @@ -1264,7 +1264,7 @@ struct InProcessIndexer : IIndexerProcess { FileConsumer::SharedState file_consumer_shared_; explicit InProcessIndexer(IQueryDbResponder* responder, ThreadedQueue* messages) - : messages_(messages), responder_(responder) {} + : messages_(messages), num_busy_indexers_(0), responder_(responder) {} void Restart() override {} // no-op void EnableAutoRestart() override {} // no-op @@ -1285,11 +1285,16 @@ struct InProcessIndexer : IIndexerProcess { } break; } - case IndexProcess_Request::Type::kIndex: { + case IndexProcess_Request::Type::kIndex: { // Dispatch the request so one of the indexers will pick it up. queue_.Enqueue(std::move(*message.index_args)); break; } + case IndexProcess_Request::Type::kInvalid: + case IndexProcess_Request::Type::kQuit: { + LOG_S(ERROR) << "Unhandled IndexProcess_Request::Type " << static_cast(message.type); + break; + } } } @@ -1343,10 +1348,7 @@ struct OutOfProcessIndexer : IIndexerProcess { void SetConfig(const Config& config) override { assert(!config_); config_ = config; - - //std::lock_guard processes_lock(processes_mutex_); - for (auto& process : processes_) - SendMessage(IndexProcess_Request::CreateInitialize(*config_)); + SendMessage(IndexProcess_Request::CreateInitialize(*config_)); } void SendMessage(IndexProcess_Request message) override { @@ -1450,13 +1452,12 @@ struct OutOfProcessIndexer : IIndexerProcess { } }; -constexpr const char* kIpcBufferName = "CqueryIpc"; -constexpr size_t kIpcBufferSize = 1024 * 8; - // Main function for the out-of-process indexer. void IndexProcessMain() { // TODO // querydb process is responsible for owning the buffer. + //constexpr const char* kIpcBufferName = "CqueryIpc"; + //constexpr size_t kIpcBufferSize = 1024 * 8; //MessageQueue queue(Buffer::CreateSharedBuffer(kIpcBufferName, kIpcBufferSize), true /*buffer_has_data*/); std::cerr << "Indexer process starting\n"; diff --git a/src/project.cc b/src/project.cc index b335fa86..67e8d7d0 100644 --- a/src/project.cc +++ b/src/project.cc @@ -412,7 +412,9 @@ void Project::ForAllFilteredFiles(Config* config, std::functionlogSkippedPathsForIndex, "[%d/%d]: Failed %s; skipping %s", i + 1, entries.size(), failure_reason.c_str(), entry.filename.c_str()); + if (config->logSkippedPathsForIndex) { + LOG_S(INFO) << "[" << i + 1 << "/" << entries.size() << "]: Failed " << failure_reason << "; skipping " << entry.filename; + } } } } diff --git a/src/serializer.cc b/src/serializer.cc index 5c361e8b..814591ea 100644 --- a/src/serializer.cc +++ b/src/serializer.cc @@ -34,6 +34,13 @@ void Reflect(Reader& visitor, uint64_t& value) { void Reflect(Writer& visitor, uint64_t& value) { visitor.Uint64(value); } +// long long +void Reflect(Reader& visitor, long long& value) { + value = visitor.GetUint64(); +} +void Reflect(Writer& visitor, long long& value) { + visitor.Uint64(value); +} // bool void Reflect(Reader& visitor, bool& value) { value = visitor.GetBool(); diff --git a/src/serializer.h b/src/serializer.h index 52ccd5a0..1f57cf9d 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -121,6 +121,9 @@ void Reflect(Writer& visitor, int64_t& value); // uint64_t void Reflect(Reader& visitor, uint64_t& value); void Reflect(Writer& visitor, uint64_t& value); +// long long +void Reflect(Reader& visitor, long long& value); +void Reflect(Writer& visitor, long long& value); // bool void Reflect(Reader& visitor, bool& value); void Reflect(Writer& visitor, bool& value); @@ -225,4 +228,4 @@ void ReflectMember(Reader& visitor, const char* name, T& value) { std::string Serialize(IndexFile& file); std::unique_ptr Deserialize(std::string path, std::string serialized, optional expected_version); -void SetTestOutputMode(); \ No newline at end of file +void SetTestOutputMode(); diff --git a/src/threaded_queue.h b/src/threaded_queue.h index e69ac536..3240c801 100644 --- a/src/threaded_queue.h +++ b/src/threaded_queue.h @@ -96,7 +96,7 @@ public: // Get the first element from the queue. Blocks until one is available. // Executes |action| with an acquired |mutex_|. template - T DequeuePlusAction(TAction& action) { + T DequeuePlusAction(TAction action) { std::unique_lock lock(mutex_); waiter_->cv.wait(lock, [&]() { return !priority_.empty() || !queue_.empty(); diff --git a/src/tiny-process-library/process_win.cpp b/src/tiny-process-library/process_win.cpp index 0e59c5e4..0db763c8 100644 --- a/src/tiny-process-library/process_win.cpp +++ b/src/tiny-process-library/process_win.cpp @@ -1,3 +1,4 @@ +#if defined(_WIN32) #include "process.hpp" #include #include @@ -176,7 +177,7 @@ void Process::close_fds() noexcept { stdout_thread.join(); if(stderr_thread.joinable()) stderr_thread.join(); - + if(stdin_fd) close_stdin(); if(stdout_fd) { @@ -268,3 +269,4 @@ void Process::kill(id_type id, bool force) noexcept { } } // TinyProsessLib +#endif diff --git a/wscript b/wscript index 09642cca..7c6c792c 100644 --- a/wscript +++ b/wscript @@ -125,6 +125,7 @@ def build(bld): if sys.platform == 'linux' or sys.platform == 'linux2': lib.append('rt') lib.append('pthread') + lib.append('dl') elif sys.platform == 'darwin': lib.append('pthread') @@ -134,10 +135,12 @@ def build(bld): includes=[ 'third_party/', 'third_party/doctest/', + 'third_party/loguru/', 'third_party/rapidjson/include/', 'third_party/sparsehash/src/', 'third_party/sparsepp/', CLANG_INCLUDE_DIR], + defines=['LOGURU_WITH_STREAMS=1'], lib=lib, libpath=[CLANG_LIB_DIR], rpath=[CLANG_LIB_DIR],