summaryrefslogtreecommitdiffstats
path: root/runtime/staprun/relay_old.c
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-04-03 13:32:22 -0700
committerJosh Stone <jistone@redhat.com>2009-04-03 13:47:47 -0700
commit1bcb8a30c3c138373c2b21a5d3820d132dacf162 (patch)
treea3dcbee586e6effe26228d4f4b2f932661295da4 /runtime/staprun/relay_old.c
parenta53e0eeb262399f79c0b1b219c7d5f96c2c10fb4 (diff)
downloadsystemtap-steved-1bcb8a30c3c138373c2b21a5d3820d132dacf162.tar.gz
systemtap-steved-1bcb8a30c3c138373c2b21a5d3820d132dacf162.tar.xz
systemtap-steved-1bcb8a30c3c138373c2b21a5d3820d132dacf162.zip
PR10032: Trigger cleanup after relay thread errors
When the relay threads encounter an error, they now send SIGTERM to the rest of the process before the thread exit, so we get a clean shutdown. For EPIPE in particular, error messages are also suppressed.
Diffstat (limited to 'runtime/staprun/relay_old.c')
-rw-r--r--runtime/staprun/relay_old.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/runtime/staprun/relay_old.c b/runtime/staprun/relay_old.c
index 469a5831..33d2daf3 100644
--- a/runtime/staprun/relay_old.c
+++ b/runtime/staprun/relay_old.c
@@ -239,14 +239,15 @@ static int process_subbufs(struct _stp_buf_info *info,
scb->rmfile = 1;
if (open_oldoutfile(scb->fnum, cpu, scb->rmfile) < 0) {
perr("Couldn't open file for cpu %d, exiting.", cpu);
- exit(1);
+ return -1;
}
scb->wsize = len;
}
if (len) {
if (fwrite_unlocked (subbuf_ptr, len, 1, percpu_tmpfile[cpu]) != 1) {
- _perr("Couldn't write to output file for cpu %d, exiting:", cpu);
- exit(1);
+ if (errno != EPIPE)
+ _perr("Couldn't write to output file for cpu %d, exiting:", cpu);
+ return -1;
}
}
subbufs_consumed++;
@@ -281,14 +282,17 @@ static void *reader_thread(void *data)
if (rc < 0) {
if (errno != EINTR) {
_perr("poll error");
- exit(1);
+ break;
}
err("WARNING: poll warning: %s\n", strerror(errno));
rc = 0;
}
rc = read(proc_fd[cpu], &status[cpu].info, sizeof(struct _stp_buf_info));
- subbufs_consumed = process_subbufs(&status[cpu].info, &scb);
+ rc = process_subbufs(&status[cpu].info, &scb);
+ if (rc < 0)
+ break;
+ subbufs_consumed = rc;
if (subbufs_consumed) {
if (subbufs_consumed > status[cpu].max_backlog)
status[cpu].max_backlog = subbufs_consumed;
@@ -301,6 +305,10 @@ static void *reader_thread(void *data)
if (status[cpu].info.flushing)
pthread_exit(NULL);
} while (1);
+
+ /* Signal the main thread that we need to quit */
+ kill(getpid(), SIGTERM);
+ pthread_exit(NULL);
}
/**