X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=plocate.cpp;h=7182ee892dfa839b5b50794a4e22582500759996;hb=31641da5750ed2b80697e605bf5b50c0a92264af;hp=a1cd97a4a4645c08880b014d4799f9d4c33182f6;hpb=6cb3631902fd964ad78a78a2b8af4f37d7ec5c7e;p=plocate diff --git a/plocate.cpp b/plocate.cpp index a1cd97a..7182ee8 100644 --- a/plocate.cpp +++ b/plocate.cpp @@ -367,7 +367,7 @@ uint64_t scan_all_docids(const vector &needles, int fd, const Corpus &co string compressed; { - unique_lock lock(mu); + unique_lock lock(mu); queue_added.wait(lock, [&work_queue, &done] { return !work_queue.empty() || done; }); if (done && work_queue.empty()) { return; @@ -397,7 +397,7 @@ uint64_t scan_all_docids(const vector &needles, int fd, const Corpus &co complete_pread(fd, &compressed[0], io_len, offsets[io_docid]); { - unique_lock lock(mu); + unique_lock lock(mu); queue_removed.wait(lock, [&work_queue] { return work_queue.size() < 256; }); // Allow ~2MB of data queued up. work_queue.emplace_back(io_docid, last_docid, move(compressed)); queue_added.notify_one(); // Avoid the thundering herd. @@ -571,7 +571,7 @@ uint64_t do_search_file(const vector &needles, const std::string &filena if (only_count) { printf("0\n"); } - exit(0); + exit(1); } } } @@ -972,7 +972,7 @@ int main(int argc, char **argv) } if (needles.empty()) { fprintf(stderr, "plocate: no pattern to search for specified\n"); - exit(0); + exit(1); } if (dbpaths.empty()) { @@ -1000,4 +1000,6 @@ int main(int argc, char **argv) if (only_count) { printf("%" PRId64 "\n", matched); } + + return matched == 0; }