summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-02 14:25:23 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-08-02 14:25:23 -0400
commit2a6b74746edbfde0b0f1468cdf153263670c908a (patch)
tree3e09ca56f65ea69e2d41df0a9d25ffb880270820 /node
parent741642ba531e487c18c8139c4a2e9510eed0466d (diff)
downloadinfinitytier-2a6b74746edbfde0b0f1468cdf153263670c908a.tar.gz
infinitytier-2a6b74746edbfde0b0f1468cdf153263670c908a.zip
Netconf service itself works, time to integrate.
Diffstat (limited to 'node')
-rw-r--r--node/Identity.hpp4
-rw-r--r--node/Service.cpp22
-rw-r--r--node/Thread.cpp2
3 files changed, 17 insertions, 11 deletions
diff --git a/node/Identity.hpp b/node/Identity.hpp
index a9f78c8a..1cce4fb0 100644
--- a/node/Identity.hpp
+++ b/node/Identity.hpp
@@ -104,7 +104,7 @@ public:
_keyPair((EllipticCurveKeyPair *)0)
{
if (!fromString(str))
- throw std::invalid_argument("invalid string-serialized identity");
+ throw std::invalid_argument(std::string("invalid string-serialized identity: ") + str);
}
Identity(const std::string &str)
@@ -112,7 +112,7 @@ public:
_keyPair((EllipticCurveKeyPair *)0)
{
if (!fromString(str))
- throw std::invalid_argument("invalid string-serialized identity");
+ throw std::invalid_argument(std::string("invalid string-serialized identity: ") + str);
}
template<unsigned int C>
diff --git a/node/Service.cpp b/node/Service.cpp
index 88a6d15c..c614e4e4 100644
--- a/node/Service.cpp
+++ b/node/Service.cpp
@@ -36,6 +36,7 @@
#include <signal.h>
#include <time.h>
#include <fcntl.h>
+#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -109,7 +110,7 @@ bool Service::send(const Dictionary &msg)
void Service::main()
throw()
{
- char buf[4096];
+ char buf[131072];
fd_set readfds,writefds,exceptfds;
struct timeval tv;
@@ -126,27 +127,30 @@ void Service::main()
pipe(out);
pipe(err);
- long pid = fork();
+ long pid = vfork();
if (pid < 0) {
LOG("service %s terminating: could not fork!",_name.c_str());
return;
} else if (pid) {
- close(in[1]);
- close(out[0]);
- close(err[0]);
+ // Parent
+ close(in[0]);
+ close(out[1]);
+ close(err[1]);
Thread::sleep(500); // give child time to start
_childStdin = in[1];
_childStdout = out[0];
_childStderr = err[0];
fcntl(_childStdout,F_SETFL,O_NONBLOCK);
fcntl(_childStderr,F_SETFL,O_NONBLOCK);
+ _pid = pid;
} else {
- dup2(in[0],STDIN_FILENO);
- dup2(out[1],STDOUT_FILENO);
- dup2(err[1],STDERR_FILENO);
+ // Child
close(in[1]);
close(out[0]);
close(err[0]);
+ dup2(in[0],STDIN_FILENO);
+ dup2(out[1],STDOUT_FILENO);
+ dup2(err[1],STDERR_FILENO);
execl(_path.c_str(),_path.c_str(),_r->homePath.c_str(),(const char *)0);
exit(-1);
}
@@ -169,6 +173,8 @@ void Service::main()
}
}
+ // If we've made it here, _pid is running last we checked.
+
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
diff --git a/node/Thread.cpp b/node/Thread.cpp
index 71cfcaea..f650f6fc 100644
--- a/node/Thread.cpp
+++ b/node/Thread.cpp
@@ -75,7 +75,7 @@ void Thread::join()
void Thread::sleep(unsigned long ms)
{
- usleep(ms);
+ usleep(ms * 1000);
}
void Thread::__intl_run()