diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2008-12-03 16:56:03 -0500 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2008-12-03 16:56:03 -0500 |
commit | c94a9cb3408d0fb2bec28be7cc966ece0c24e61f (patch) | |
tree | 5f312c3849a48edebc4fc9988cddc078b92f4843 /runtime/staprun/staprun.c | |
parent | 33d34a13b7632fada659a7ea2541c390dd31b541 (diff) | |
download | systemtap-steved-c94a9cb3408d0fb2bec28be7cc966ece0c24e61f.tar.gz systemtap-steved-c94a9cb3408d0fb2bec28be7cc966ece0c24e61f.tar.xz systemtap-steved-c94a9cb3408d0fb2bec28be7cc966ece0c24e61f.zip |
PR6925: tolerate modules left over from previous crashed? stap sessions
Diffstat (limited to 'runtime/staprun/staprun.c')
-rw-r--r-- | runtime/staprun/staprun.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/runtime/staprun/staprun.c b/runtime/staprun/staprun.c index b6d77979..9d647675 100644 --- a/runtime/staprun/staprun.c +++ b/runtime/staprun/staprun.c @@ -136,6 +136,7 @@ static int enable_uprobes(void) static int insert_stap_module(void) { char bufsize_option[128]; + if (snprintf_chk(bufsize_option, 128, "_stp_bufsize=%d", buffer_size)) return -1; return insert_module(modpath, bufsize_option, modoptions); @@ -209,8 +210,17 @@ int init_staprun(void) else if (!attach_mod) { if (need_uprobes && enable_uprobes() != 0) return -1; - if (insert_stap_module() < 0) - return -1; + if (insert_stap_module() < 0) { + /* staprun or stapio might have crashed or been SIGKILL'd, + without first removing the kernel module. This would block + a subsequent rerun attempt. So here we gingerly try to + unload it first. */ + int ret = delete_module (modname, O_NONBLOCK); + err("Retrying, after attempted removal of module %s (rc %d)\n", modname, ret); + /* Then we try an insert a second time. */ + if (insert_stap_module() < 0) + return -1; + } if (send_relocations() < 0) return -1; } |