Commit 2861a1a6 authored by Leigh Stoller's avatar Leigh Stoller

Fix a few things that cropped up while debugging for jails.

* Do not have linktest daemon connect to boss; have it connect to
  local node elvind like all other local agents. Remove the event
  generation code (linktest was sending a KILL event to all other
  linktest programs), and replace with a system() call to tevc, which
  sends the event through the scheduler and exits; this will avoid a
  zillion tcp connctions to boss from the linktest daemon.

* A couple of process group changes to linktest daemon; the daemon
  appeared to be killing itself off.

* Fix to run_linktest.pl; It was just hanging after it completed,
  cause its child ltevent process was still running. Changed to record
  child pid, and kill/close ltevent child before exiting.
parent 7b3247b2
......@@ -26,7 +26,7 @@ all: binaries $(SCRIPT) $(SCRIPT_RUN) weblinktest
include $(TESTBED_SRCDIR)/GNUmakerules
CFLAGS += -DDEBUG
CFLAGS += -DDEBUG -DCLIENT_BINDIR='"$(CLIENT_BINDIR)"'
CFLAGS += -O -g -static -Wall
CFLAGS += -I. -I${OBJDIR} -I$(SRCDIR)/../lib -I$(TESTBED_SRCDIR)/lib/libtb
CFLAGS += `elvin-config --cflags vin4c`
......
......@@ -221,6 +221,8 @@ callback(event_handle_t handle, event_notification_t notification, void *data)
event_notification_get_arguments(handle,
notification, args, sizeof(args));
info("event: %s - %s - %s\n", objname, event, args);
/*
* Dispatch the event.
*/
......@@ -250,7 +252,7 @@ callback(event_handle_t handle, event_notification_t notification, void *data)
*/
if(!linktest_pid) {
pid_t mypid = getpid();
setpgid(mypid,mypid);
setpgid(0, mypid);
/* Finally, execute the linktest script. */
exec_linktest(args, sizeof(args));
......@@ -389,7 +391,7 @@ void send_group_kill() {
* Linktest run. This may include the linktest script
* itself, and any children it forked.
*/
res = kill(-linktest_pid,SIGKILL);
res = killpg(linktest_pid, SIGTERM);
if(res < 0) {
/*
* Not a serious error, likely the process group
......@@ -401,37 +403,18 @@ void send_group_kill() {
static
void send_kill_event() {
event_notification_t notification;
address_tuple_t tuple;
/*
* Construct an address tuple for generating the event.
* Invoke external program; The local elvind is read-only, so to
* send events we have to contact boss, but do not want a zillion
* linktest daemons keeping a connection to boss open. tevc will
* connect, send event, and exit.
*/
tuple = address_tuple_alloc();
if (tuple == NULL) {
error("could not allocate an address tuple");
}
char buf[BUFSIZ];
/*
* Set up event to send a kill...
*/
tuple->objtype = TBDB_OBJECTTYPE_LINKTEST;
tuple->eventtype= TBDB_EVENTTYPE_KILL;
tuple->host = ADDRESSTUPLE_ALL;
tuple->expt = pideid;
/* Generate the event */
notification = event_notification_alloc(handle, tuple);
if (notification == NULL) {
error("could not allocate notification");
}
sprintf(buf, "%s/tevc -e %s now %s %s",
CLIENT_BINDIR, pideid, "linktest", TBDB_EVENTTYPE_KILL);
/* Send the event */
if (event_notify(handle, notification) == 0) {
error("could not send event notification");
if (system(buf) != 0) {
error("Could not invoke tevc to send KILL event\n");
}
/* Clean up */
event_notification_free(handle, notification);
}
......@@ -276,20 +276,26 @@ if(my $pid =fork) {
# Open child process to read in the output from ltevent,
# and just print out the return values for feedback.
#
open ARGS,"$args |" || die("*** $0:\n"." Error running '$args'\n");
while(<ARGS>) {
my $ltpid = open(LTC, "$args |");
if (! $ltpid) {
die("*** $0:\n".
" Error running '$args'\n");
}
while(<LTC>) {
chomp;
if(/(\w+)\s(.*)/) {
my $eventtype = $1;
my $eventargs = $2;
if($eventtype eq $STOPEVENT) {
if ($eventtype eq $STOPEVENT) {
print "Linktest completed normally.\n"
if($verbose);
exit;
} elsif ($eventtype eq $KILLEVENT) {
print "Linktest has been cancelled due to a timeout or unrecoverable error.\n"
if ($verbose);
exit;
last;
}
elsif ($eventtype eq $KILLEVENT) {
print("Linktest has been cancelled due to a timeout ".
"or unrecoverable error.\n")
if ($verbose);
last;
} else {
#
# Print out report messages if in verbose mode.
......@@ -300,9 +306,11 @@ if(my $pid =fork) {
} else {
# parse error, exit.
print "error parsing: " . $_ . "\n";
exit;
last;
}
}
kill('TERM', $ltpid);
close(LTC);
exit;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment