]> sourceware.org Git - systemtap.git/commitdiff
staprun: Discriminate errors before retrying module insertion
authorJosh Stone <jistone@redhat.com>
Tue, 31 May 2011 21:49:16 +0000 (14:49 -0700)
committerJosh Stone <jistone@redhat.com>
Tue, 31 May 2011 22:09:07 +0000 (15:09 -0700)
* runtime/staprun/staprun_funcs.c(insert_module): Copy the saved_errno
  back into errno when insertion fails.
* runtime/staprun/staprun.c(init_staprun): When the first insertion
  attempt fails, check for EEXIST and then successful module removal
  before trying module insertion again.

runtime/staprun/staprun.c
runtime/staprun/staprun_funcs.c

index 458180a9fcd05f1b0dc6037be61a766207e824fb..4d8310b642bcbb146ccf38bfca6efa16b90eb713 100644 (file)
@@ -226,12 +226,18 @@ int init_staprun(void)
                if (need_uprobes && enable_uprobes() != 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 = remove_module (modname, 0);
-                 err("Retrying, after attempted removal of module %s (rc %d)\n", modname, ret);
+                 if (errno != EEXIST)
+                   return -1;
+
+                 /* 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 = remove_module (modname, 0);
+                 if (ret != 0)
+                   return ret;
+
+                 err("Retrying, after attempted removal of module %s\n", modname);
                  /* Then we try an insert a second time.  */
                  if (insert_stap_module() < 0)
                        return -1;
index 74eef9cec6f7a21739d94f28c60b16ebf695fd61..688726b0d0cf825b19662c261d4e1e0b69953f68 100644 (file)
@@ -136,6 +136,7 @@ int insert_module(
 
        if (ret != 0) {
                err("Error inserting module '%s': %s\n", module_realpath, moderror(saved_errno));
+               errno = saved_errno;
                return -1;
        }
        return 0;
This page took 0.029 seconds and 5 git commands to generate.