[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
81/376: Add some assertions
From: |
Ludovic Courtès |
Subject: |
81/376: Add some assertions |
Date: |
Wed, 28 Jan 2015 22:04:11 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit 1eb0af7ed563c6d77e1b8e36e81ba6ede7e49f5a
Author: Eelco Dolstra <address@hidden>
Date: Thu Jul 24 00:16:06 2014 +0200
Add some assertions
---
src/libutil/monitor-fd.hh | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/libutil/monitor-fd.hh b/src/libutil/monitor-fd.hh
index d8db650..ebfc230 100644
--- a/src/libutil/monitor-fd.hh
+++ b/src/libutil/monitor-fd.hh
@@ -1,6 +1,7 @@
#pragma once
#include <thread>
+#include <atomic>
#include <poll.h>
#include <sys/types.h>
@@ -14,10 +15,12 @@ class MonitorFdHup
{
private:
std::thread thread;
+ std::atomic_bool quit;
public:
MonitorFdHup(int fd)
{
+ quit = false;
thread = std::thread([&]() {
/* Wait indefinitely until a POLLHUP occurs. */
struct pollfd fds[1];
@@ -25,8 +28,10 @@ public:
fds[0].events = 0;
if (poll(fds, 1, -1) == -1) {
if (errno != EINTR) abort(); // can't happen
+ assert(quit);
return; // destructor is asking us to exit
}
+ assert(fds[0].revents & POLLHUP);
/* We got POLLHUP, so send an INT signal to the main thread. */
kill(getpid(), SIGINT);
});
@@ -34,6 +39,7 @@ public:
~MonitorFdHup()
{
+ quit = true;
pthread_kill(thread.native_handle(), SIGINT);
thread.join();
}
- 67/376: nix-daemon: Add trusted-users and allowed-users options, (continued)
- 67/376: nix-daemon: Add trusted-users and allowed-users options, Ludovic Courtès, 2015/01/28
- 56/376: Remove cruft, Ludovic Courtès, 2015/01/28
- 76/376: nix-daemon: Simplify stderr handling, Ludovic Courtès, 2015/01/28
- 71/376: Revert old useBuildHook behaviour, Ludovic Courtès, 2015/01/28
- 65/376: nix-daemon: Only print connection info if we have SO_PEERCRED, Ludovic Courtès, 2015/01/28
- 69/376: Bump, Ludovic Courtès, 2015/01/28
- 62/376: Be more strict about file names in NARs, Ludovic Courtès, 2015/01/28
- 78/376: Pass -pthread only for programs that need it, Ludovic Courtès, 2015/01/28
- 80/376: Remove some dead code, Ludovic Courtès, 2015/01/28
- 72/376: Remove dead code, Ludovic Courtès, 2015/01/28
- 81/376: Add some assertions,
Ludovic Courtès <=
- 82/376: More debugging, Ludovic Courtès, 2015/01/28
- 85/376: tests/remote-builds.nix: Don't try cache.nixos.org, Ludovic Courtès, 2015/01/28
- 79/376: Remove some obsolete files, Ludovic Courtès, 2015/01/28
- 83/376: Fix bogus pass by reference, Ludovic Courtès, 2015/01/28
- 88/376: Refactor, Ludovic Courtès, 2015/01/28
- 87/376: tests/remote-builds.nix: Test failing build, Ludovic Courtès, 2015/01/28
- 89/376: build-remote.pl: Be less verbose on failing builds, Ludovic Courtès, 2015/01/28
- 86/376: nix-store --serve: Only monitor stdin during builds, Ludovic Courtès, 2015/01/28
- 77/376: nix-daemon: Less verbosity, Ludovic Courtès, 2015/01/28
- 74/376: nix-daemon: Use a thread instead of SIGPOLL to catch client disconnects, Ludovic Courtès, 2015/01/28