BIND 10 trac2875, updated. 9432b2b1b4bbe2053a0bcdef6b95505b3a7dafb7 [2875] Control the execution of subprocesses
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jul 18 09:26:55 UTC 2013
The branch, trac2875 has been updated
via 9432b2b1b4bbe2053a0bcdef6b95505b3a7dafb7 (commit)
from ed5835fe2d9ad196d5287674f9e9448e4dad26e6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 9432b2b1b4bbe2053a0bcdef6b95505b3a7dafb7
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Thu Jul 18 11:26:22 2013 +0200
[2875] Control the execution of subprocesses
Control when the subprocesses should start handling the queries. The
subprocesses are not yet created.
-----------------------------------------------------------------------
Summary of changes:
src/bin/resolver/bench/Makefile.am | 1 +
src/bin/resolver/bench/subprocess.cc | 36 ++++++++++++++++++++++++++++++++++
src/bin/resolver/bench/subprocess.h | 4 ++++
3 files changed, 41 insertions(+)
-----------------------------------------------------------------------
diff --git a/src/bin/resolver/bench/Makefile.am b/src/bin/resolver/bench/Makefile.am
index 109d6a6..1aeaa32 100644
--- a/src/bin/resolver/bench/Makefile.am
+++ b/src/bin/resolver/bench/Makefile.am
@@ -19,6 +19,7 @@ resolver_bench_SOURCES += fake_resolution.h fake_resolution.cc
resolver_bench_SOURCES += dummy_work.h dummy_work.cc
resolver_bench_SOURCES += naive_resolver.h naive_resolver.cc
resolver_bench_SOURCES += subprocess.h subprocess.cc
+resolver_bench_SOURCES += layers.h layers.cc
resolver_bench_LDADD = $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
resolver_bench_LDADD += $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
diff --git a/src/bin/resolver/bench/subprocess.cc b/src/bin/resolver/bench/subprocess.cc
index d3e8c95..295235b 100644
--- a/src/bin/resolver/bench/subprocess.cc
+++ b/src/bin/resolver/bench/subprocess.cc
@@ -19,6 +19,7 @@
#include <sys/wait.h>
#include <cstdlib>
#include <iostream>
+#include <cerrno>
using namespace std;
@@ -62,6 +63,41 @@ Subprocess::~Subprocess() {
assert(result != -1);
}
+void
+Subprocess::send(const void* data, size_t size) {
+ const uint8_t* buffer = (const uint8_t*) data;
+ while (size > 0) {
+ ssize_t result = ::send(channel(), buffer, size, 0);
+ if (result == -1) {
+ assert(errno == EINTR);
+ } else {
+ size -= result;
+ buffer += result;
+ }
+ }
+}
+
+std::string
+Subprocess::read(size_t size) {
+ char target[size + 1];
+ target[size] = '\0';
+ char* position = target;
+ while (size > 0) {
+ ssize_t result = recv(channel(), position, size, 0);
+ if (result == -1) {
+ assert(errno == EINTR);
+ } else if (result == 0) {
+ // EOF. Terminate sting.
+ *position = 0;
+ break;
+ } else {
+ position += result;
+ size -= result;
+ }
+ }
+ return (target); // Convert from char* to string
+}
+
}
}
}
diff --git a/src/bin/resolver/bench/subprocess.h b/src/bin/resolver/bench/subprocess.h
index b3821f1..540f90a 100644
--- a/src/bin/resolver/bench/subprocess.h
+++ b/src/bin/resolver/bench/subprocess.h
@@ -41,6 +41,10 @@ public:
int channel() const {
return (channel_);
}
+ /// \brief Send some data, abort on error.
+ void send(const void* data, size_t amount);
+ /// \brief Read that amount of data (or to EOF). Aborts on error.
+ std::string read(size_t amount);
private:
int channel_;
pid_t pid;
More information about the bind10-changes
mailing list