From: kupcevic@sourceware.org <kupcevic@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/ricci/modules/cluster/clumon/src/daemon ...
Date: 14 Oct 2006 18:00:05 -0000 [thread overview]
Message-ID: <20061014180005.32104.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: kupcevic at sourceware.org 2006-10-14 18:00:02
Modified files:
ricci/modules/cluster/clumon/src/daemon: Communicator.cpp
Monitor.cpp Peer.cpp
main.cpp
Log message:
modclusterd: exit as soon as possible, after exit signal is caught:
- make all sockets non-blocking
- make long waits interruptible
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Communicator.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/Peer.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/clumon/src/daemon/main.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4
--- conga/ricci/modules/cluster/clumon/src/daemon/Communicator.cpp 2006/08/10 22:53:08 1.3
+++ conga/ricci/modules/cluster/clumon/src/daemon/Communicator.cpp 2006/10/14 18:00:02 1.4
@@ -55,6 +55,7 @@
_serv_sock(_port),
_delivery_point(delivery_point)
{
+ _serv_sock.nonblocking(true);
_connect_time = time_sec();
_rand_state = time_mil();
log(String("Communicator created, port ") + _port, LogCommunicator);
@@ -186,7 +187,7 @@
}
// process events
- for (unsigned int i=0; i<socks_num; i++) {
+ for (unsigned int i=0; i<socks_num && !shouldStop(); i++) {
poll_fd& poll_info = poll_data[i];
// server socket
@@ -194,6 +195,7 @@
if (poll_info.revents & POLLIN) {
try {
ClientSocket sock = _serv_sock.accept();
+ sock.nonblocking(true);
String hostname;
for (vector<String>::iterator iter = names.begin();
iter != names.end();
--- conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp 2006/10/13 09:36:16 1.8
+++ conga/ricci/modules/cluster/clumon/src/daemon/Monitor.cpp 2006/10/14 18:00:02 1.9
@@ -132,8 +132,12 @@
log(msg, LogTime);
// wait some time
- struct pollfd nothing;
- poll(¬hing, 0, 5000);
+ for (int i=0; i<10; i++) {
+ if (shouldStop())
+ break;
+ struct pollfd nothing;
+ poll(¬hing, 0, 500);
+ }
}
log("Stopping communicator", LogCommunicator);
_comm.stop();
--- conga/ricci/modules/cluster/clumon/src/daemon/Peer.cpp 2006/08/10 22:53:08 1.2
+++ conga/ricci/modules/cluster/clumon/src/daemon/Peer.cpp 2006/10/14 18:00:02 1.3
@@ -40,14 +40,18 @@
_hostname(hostname),
_in(new String()),
_out(new String())
-{}
+{
+ _sock->nonblocking(true);
+}
Peer::Peer(const String& hostname, unsigned short port) :
_sock(new ClientSocket(hostname, port)),
_hostname(hostname),
_in(new String()),
_out(new String())
-{}
+{
+ _sock->nonblocking(true);
+}
Peer::~Peer()
{}
--- conga/ricci/modules/cluster/clumon/src/daemon/main.cpp 2006/10/13 09:36:16 1.3
+++ conga/ricci/modules/cluster/clumon/src/daemon/main.cpp 2006/10/14 18:00:02 1.4
@@ -102,6 +102,7 @@
log("started");
try {
ServerSocket server(MONITORING_CLIENT_SOCKET);
+ server.nonblocking(true);
Monitor monitor(COMMUNICATION_PORT);
if (!foreground && (geteuid() == 0))
@@ -169,7 +170,7 @@
}
// process events
- for (unsigned int i=0; i<socks_num; i++) {
+ for (unsigned int i=0; i<socks_num && !shutdown_pending; i++) {
poll_fd& poll_info = poll_data[i];
// server socket
@@ -177,6 +178,7 @@
if (poll_info.revents & POLLIN) {
try {
ClientSocket sock = server.accept();
+ sock.nonblocking(true);
clients[sock.get_sock()] = ClientInfo(sock);
} catch ( ... ) {}
}
@@ -187,7 +189,9 @@
if (poll_info.revents & POLLIN) {
ClientInfo& info = clients[poll_info.fd];
try {
- info.str = monitor.request(info.sock.recv());
+ String msg = info.sock.recv();
+ if (msg.size())
+ info.str = monitor.request(msg);
} catch ( ... ) {
clients.erase(poll_info.fd);
}
next reply other threads:[~2006-10-14 18:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-14 18:00 kupcevic [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-11-21 17:39 [Cluster-devel] conga/ricci/modules/cluster/clumon/src/daemon rmccabe
2007-11-21 17:41 rmccabe
2007-11-21 17:42 rmccabe
2007-12-05 16:46 rmccabe
2007-12-05 17:36 rmccabe
2008-05-12 15:15 rmccabe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061014180005.32104.qmail@sourceware.org \
--to=kupcevic@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).