summaryrefslogtreecommitdiffstats
path: root/src/daemon
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-04-20 14:38:54 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-04-20 14:38:54 +0200
commit3572f658c5829492da1c99eae33b1e9ca9d4518c (patch)
treec1fd709df852246ccf7d5320775f9f65945f7c79 /src/daemon
parent6523896fd4f45ab6672e0eee007ce1bb6757eba4 (diff)
downloadabrt-3572f658c5829492da1c99eae33b1e9ca9d4518c.zip
abrt-3572f658c5829492da1c99eae33b1e9ca9d4518c.tar.gz
abrt-3572f658c5829492da1c99eae33b1e9ca9d4518c.tar.xz
daemon: reload abrt.conf after each poll. Closes 189
Can be optimized a bit by checking stat.st_mtime. Currently, every reload looks like this: 14:37:49.551073 open("/etc/abrt/abrt.conf", O_RDONLY) = 13 14:37:49.551229 fstat(13, {st_mode=S_IFREG|0644, st_size=869, ...}) = 0 14:37:49.551393 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f541037f000 14:37:49.551505 read(13, "# With this option set to \"yes\",\n# only crashes in signed packages will be analyzed.\n# the list of "..., 4096) = 869 14:37:49.551709 read(13, "", 4096) = 0 14:37:49.551812 close(13) = 0 14:37:49.552051 open("/etc/abrt/gpg_keys", O_RDONLY) = 13 14:37:49.552183 fstat(13, {st_mode=S_IFREG|0644, st_size=36, ...}) = 0 14:37:49.552338 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f541037f000 14:37:49.552448 read(13, "/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora\n", 4096) = 36 14:37:49.552591 read(13, "", 4096) = 0 14:37:49.552692 close(13) = 0 14:37:49.552792 munmap(0x7f541037f000, 4096) = 0 Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/abrt-action-save-package-data.c4
-rw-r--r--src/daemon/abrt_conf.c8
-rw-r--r--src/daemon/abrt_conf.h4
-rw-r--r--src/daemon/abrtd.c30
4 files changed, 28 insertions, 18 deletions
diff --git a/src/daemon/abrt-action-save-package-data.c b/src/daemon/abrt-action-save-package-data.c
index 90b16ee..af63ff2 100644
--- a/src/daemon/abrt-action-save-package-data.c
+++ b/src/daemon/abrt-action-save-package-data.c
@@ -275,8 +275,8 @@ int main(int argc, char **argv)
msg_prefix = PROGNAME;
VERB1 log("Loading settings");
- if (load_settings() != 0)
- return 1; /* syntax error (logged already by load_settings) */
+ if (load_abrt_conf() != 0)
+ return 1; /* syntax error (logged already by load_abrt_conf) */
VERB1 log("Initializing rpm library");
rpm_init();
diff --git a/src/daemon/abrt_conf.c b/src/daemon/abrt_conf.c
index 0eb83fb..46d8f44 100644
--- a/src/daemon/abrt_conf.c
+++ b/src/daemon/abrt_conf.c
@@ -28,7 +28,7 @@ unsigned int g_settings_nMaxCrashReportsSize = 1000;
bool g_settings_bProcessUnpackaged = false;
-void free_settings()
+void free_abrt_conf_data()
{
list_free_with_free(g_settings_setOpenGPGPublicKeys);
g_settings_setOpenGPGPublicKeys = NULL;
@@ -108,7 +108,7 @@ static void ParseCommon(map_string_h *settings, const char *conf_filename)
value = g_hash_table_lookup(settings, "MaxCrashReportsSize");
if (value)
{
-//fixme: dont die
+//FIXME: dont die
g_settings_nMaxCrashReportsSize = xatoi_positive(value);
g_hash_table_remove(settings, "MaxCrashReportsSize");
}
@@ -150,9 +150,9 @@ static void LoadGPGKeys()
}
}
-int load_settings()
+int load_abrt_conf()
{
- free_settings();
+ free_abrt_conf_data();
map_string_h *settings = new_map_string();
if (!load_conf_file(CONF_DIR"/abrt.conf", settings, /*skip key w/o values:*/ false))
diff --git a/src/daemon/abrt_conf.h b/src/daemon/abrt_conf.h
index c01f8c4..2208e13 100644
--- a/src/daemon/abrt_conf.h
+++ b/src/daemon/abrt_conf.h
@@ -33,8 +33,8 @@ extern bool g_settings_bOpenGPGCheck;
extern bool g_settings_bProcessUnpackaged;
extern char * g_settings_sWatchCrashdumpArchiveDir;
-int load_settings();
-void free_settings();
+int load_abrt_conf();
+void free_abrt_conf_data();
#ifdef __cplusplus
}
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
index efc8d05..08c95f2 100644
--- a/src/daemon/abrtd.c
+++ b/src/daemon/abrtd.c
@@ -209,12 +209,12 @@ static void handle_signal(int signo)
// Enable for debugging only, malloc/printf are unsafe in signal handlers
//VERB3 log("Got signal %d", signo);
- uint8_t l_sig_caught;
- s_sig_caught = l_sig_caught = signo;
+ uint8_t sig_caught;
+ s_sig_caught = sig_caught = signo;
/* Using local copy of s_sig_caught so that concurrent signal
* won't change it under us */
if (s_signal_pipe_write >= 0)
- write(s_signal_pipe_write, &l_sig_caught, 1);
+ write(s_signal_pipe_write, &sig_caught, 1);
errno = save_errno;
}
@@ -222,7 +222,7 @@ static void handle_signal(int signo)
/* Signal pipe handler */
static gboolean handle_signal_cb(GIOChannel *gio, GIOCondition condition, gpointer ptr_unused)
{
- char signo;
+ uint8_t signo;
gsize len = 0;
g_io_channel_read(gio, &signo, 1, &len);
if (len == 1)
@@ -245,9 +245,8 @@ static gboolean handle_signal_cb(GIOChannel *gio, GIOCondition condition, gpoint
}
}
}
- return TRUE;
}
- return FALSE;
+ return TRUE; /* "please don't remove this event" */
}
/* Inotify handler */
@@ -274,7 +273,7 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
{
perror_msg("Error reading inotify fd");
free(buf);
- return FALSE;
+ return FALSE; /* "remove this event" (huh??) */
}
/* Reconstruct each event and send message to the dbus */
@@ -388,7 +387,7 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
} /* while */
free(buf);
- return TRUE;
+ return TRUE; /* "please don't remove this event" */
}
/* Run main loop with idle timeout.
@@ -396,6 +395,7 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
*/
static void run_main_loop(GMainLoop* loop)
{
+ time_t cur_time = time(NULL);
GMainContext *context = g_main_loop_get_context(loop);
int fds_size = 0;
GPollFD *fds = NULL;
@@ -426,6 +426,14 @@ static void run_main_loop(GMainLoop* loop)
if (s_timeout != 0)
alarm(0);
+ time_t new_time = time(NULL);
+ if (cur_time != new_time)
+ {
+ cur_time = new_time;
+ load_abrt_conf();
+//TODO: react to changes in g_settings_sWatchCrashdumpArchiveDir
+ }
+
some_ready = g_main_context_check(context, max_priority, fds, nfds);
if (some_ready)
g_main_context_dispatch(context);
@@ -538,6 +546,8 @@ int main(int argc, char** argv)
xpipe(s_signal_pipe);
close_on_exec_on(s_signal_pipe[0]);
close_on_exec_on(s_signal_pipe[1]);
+ ndelay_on(s_signal_pipe[0]); /* I/O should not block - */
+ ndelay_on(s_signal_pipe[1]); /* especially writes! they happen in signal handler! */
signal(SIGTERM, handle_signal);
signal(SIGINT, handle_signal);
signal(SIGCHLD, handle_signal);
@@ -589,7 +599,7 @@ int main(int argc, char** argv)
init_daemon_logging();
VERB1 log("Loading settings");
- if (load_settings() != 0)
+ if (load_abrt_conf() != 0)
goto init_error;
sanitize_dump_dir_rights();
@@ -688,7 +698,7 @@ int main(int argc, char** argv)
if (pMainloop)
g_main_loop_unref(pMainloop);
- free_settings();
+ free_abrt_conf_data();
/* Exiting */
if (s_sig_caught && s_sig_caught != SIGALRM && s_sig_caught != SIGCHLD)