doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

Blame SOURCES/0246-handle-event-stop-creating-post-create-lock.patch

a60cd7
From 44cb33f417d62210759c1730ca13bb03165c47ad Mon Sep 17 00:00:00 2001
a60cd7
From: Jakub Filak <jfilak@redhat.com>
a60cd7
Date: Tue, 19 Jul 2016 20:33:06 +0200
a60cd7
Subject: [PATCH] handle-event: stop creating post-create lock
a60cd7
a60cd7
Since the post-create synchronization has been moved to abrtd and
a60cd7
abrt-server, there is no need to crate the post-create.lock file.
a60cd7
a60cd7
Resolves #1132459
a60cd7
a60cd7
Signed-off-by: Jakub Filak <jfilak@redhat.com>
a60cd7
---
a60cd7
 src/daemon/abrt-handle-event.c | 58 ------------------------------------------
a60cd7
 1 file changed, 58 deletions(-)
a60cd7
a60cd7
diff --git a/src/daemon/abrt-handle-event.c b/src/daemon/abrt-handle-event.c
a60cd7
index 8870901..caed577 100644
a60cd7
--- a/src/daemon/abrt-handle-event.c
a60cd7
+++ b/src/daemon/abrt-handle-event.c
a60cd7
@@ -318,51 +318,6 @@ end:
a60cd7
     return retval;
a60cd7
 }
a60cd7
 
a60cd7
-static void create_lockfile(void)
a60cd7
-{
a60cd7
-    char pid_str[sizeof(long)*3 + 4];
a60cd7
-    sprintf(pid_str, "%lu", (long)getpid());
a60cd7
-    char *lock_filename = concat_path_file(g_settings_dump_location, "post-create.lock");
a60cd7
-
a60cd7
-    /* Someone else's post-create may take a long-ish time to finish.
a60cd7
-     * For example, I had a failing email sending there, it took
a60cd7
-     * a minute to time out.
a60cd7
-     * That's why timeout is large (100 seconds):
a60cd7
-     */
a60cd7
-    int count = 100;
a60cd7
-    while (1)
a60cd7
-    {
a60cd7
-        /* Return values:
a60cd7
-         * -1: error (in this case, errno is 0 if error message is already logged)
a60cd7
-         *  0: failed to lock (someone else has it locked)
a60cd7
-         *  1: success
a60cd7
-         */
a60cd7
-        int r = create_symlink_lockfile(lock_filename, pid_str);
a60cd7
-    if (r > 0)
a60cd7
-            break;
a60cd7
-    if (r < 0)
a60cd7
-            error_msg_and_die("Can't create '%s'", lock_filename);
a60cd7
-    if (--count == 0)
a60cd7
-        {
a60cd7
-            /* Someone else's post-create process is alive but stuck.
a60cd7
-             * Don't wait forever.
a60cd7
-             */
a60cd7
-            error_msg("Stale lock '%s', removing it", lock_filename);
a60cd7
-            xunlink(lock_filename);
a60cd7
-            break;
a60cd7
-        }
a60cd7
-        sleep(1);
a60cd7
-    }
a60cd7
-    free(lock_filename);
a60cd7
-}
a60cd7
-
a60cd7
-static void delete_lockfile(void)
a60cd7
-{
a60cd7
-    char *lock_filename = concat_path_file(g_settings_dump_location, "post-create.lock");
a60cd7
-    xunlink(lock_filename);
a60cd7
-    free(lock_filename);
a60cd7
-}
a60cd7
-
a60cd7
 static char *do_log(char *log_line, void *param)
a60cd7
 {
a60cd7
     /* We pipe output of events to our log.
a60cd7
@@ -428,23 +383,10 @@ int main(int argc, char **argv)
a60cd7
             make_run_event_state_forwarding(run_state);
a60cd7
         run_state->logging_callback = do_log;
a60cd7
         if (post_create)
a60cd7
-        {
a60cd7
             run_state->post_run_callback = is_crash_a_dup;
a60cd7
-            /*
a60cd7
-             * The post-create event cannot be run concurrently for more problem
a60cd7
-             * directories. The problem is in searching for duplicates process
a60cd7
-             * in case when two concurrently processed directories are duplicates
a60cd7
-             * of each other. Both of the directories are marked as duplicates
a60cd7
-             * of each other and are deleted.
a60cd7
-             */
a60cd7
-            create_lockfile();
a60cd7
-        }
a60cd7
 
a60cd7
         int r = run_event_on_dir_name(run_state, dump_dir_name, event_name);
a60cd7
 
a60cd7
-        if (post_create)
a60cd7
-            delete_lockfile();
a60cd7
-
a60cd7
         const bool no_action_for_event = (r == 0 && run_state->children_count == 0);
a60cd7
 
a60cd7
         free_run_event_state(run_state);
a60cd7
-- 
a60cd7
1.8.3.1
a60cd7