On 06/05/2013 03:25 PM, Petr Holasek wrote:
> Hi Denys,
> I have some ideas about rasdaemon abrt hook
> and also following questions.
> Feel free to stop by or ping me, when you'll
> be in office, I'll be there till ~6PM today
> and afternoon tomorrow.
Currently we use Unix domain socket at
to support creation of problem data from crashing python
The socket accepts the following HTTP requests:
DELETE <problem_dir> HTTP/1.1
PUT / HTTP/1.1
DELETE request is straightforward, and anyway, you don't need it.
PUT request has the following form:
PUT / HTTP/1.1<CR><LF>
It appears that we misunderstood HTTP protocol and we should
have used POST instead of PUT. I am going to add POST alias
which works the same as PUT, and remove PUT sometime in the future.
For now, use PUT. The URI in PUT should be just /.
The headers following PUT line are currently ignored.
The body is NUL-delimited (not newline delimited!) set
of name-value pairs which describe the problem.
You can use any names which make sense for your problem
(for example, if someone is reporting an out-of-paper
problem with a printer, sending "printer_name=FOO" would make sense).
Some names *have* to be in the problem:
"type" describes what kind of the problem it is. Say, "Python"
is used by python crashes. You need to invent your own identifier(s)
for the problems you want to report. Say, "mem_error" for ECC/cache
errors, "bus_error" for PCI errors?
This field is used to differentiate abrt's response to a problem.
We don't want ECC errors reported to Bugzilla, right? :)
"reason" is a short, one-line, human-readable description of the problem,
suitable, for example, for showing in the list of problems. Examples
we currently see or use:
"<module>:ZeroDivisionError: integer division or modulo by zero"
"Segmentation fault at address 0x7ff6bf09e010"
"Process %s was killed by signal %s"
time=<unixtime in seconds> will be added automatically unless you supply it.
I looked thru the list of names we use and many don't make sense for you
(say, "uid" makes no sense for ECC errors :), but the following ones
may be useful:
comment=<long, multi-line description of the problem (if "reason" isn't enough)>
As I said, if you have more data to report, create your own name=value pair
to be saved.
Server will respond with
HTTP/1.1 <http_code> <CR><LF>
http_code will be 201 ("Created") on success.
Do you think you can use this interface from rasdaemon?
This patch doesn't change the logic of the program,
it only makes cleanup in is_crash_a_dup() and main()
more consistent, closing a few leaks:
* dump_dir_name is a result of realpath(), but wasn't freed.
* four instances of dd_close() are collapsed to one.
* dump_dir_name in main() also was leaking, fix it.
* printing of "DUP_OF_DIR: dir" is made simpler-looking.
Signed-off-by: Denys Vlasenko <dvlasenk(a)redhat.com>
src/daemon/abrt-handle-event.c | 61 +++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 31 deletions(-)
diff --git a/src/daemon/abrt-handle-event.c b/src/daemon/abrt-handle-event.c
index e4da837..ea932b2 100644
@@ -219,16 +219,15 @@ static int is_crash_a_dup(const char *dump_dir_name, void *param)
struct dump_dir *dd = dd_opendir(dump_dir_name, DD_OPEN_READONLY);
return 0; /* wtf? (error, but will be handled elsewhere later) */
analyzer = dd_load_text(dd, FILENAME_ANALYZER);
- /* dump_dir_name can be relative */
- dump_dir_name = realpath(dump_dir_name, NULL);
+ /* dump_dir_name can be relative */
+ dump_dir_name = realpath(dump_dir_name, NULL);
DIR *dir = opendir(g_settings_dump_location);
if (dir == NULL)
@@ -236,7 +235,7 @@ static int is_crash_a_dup(const char *dump_dir_name, void *param)
/* Scan crash dumps looking for a dup */
//TODO: explain why this is safe wrt concurrent runs
struct dirent *dent;
- while ((dent = readdir(dir)) != NULL)
+ while ((dent = readdir(dir)) != NULL && crash_dump_dup_name == NULL)
continue; /* skip "." and ".." */
@@ -244,6 +243,7 @@ static int is_crash_a_dup(const char *dump_dir_name, void *param)
if (ext && strcmp(ext, ".new") == 0)
continue; /* skip anything named "<dirname>.new" */
+ dd = NULL;
char *dump_dir_name2 = concat_path_file(g_settings_dump_location, dent->d_name);
char *dd_uid = NULL, *dd_analyzer = NULL;
@@ -258,7 +258,6 @@ static int is_crash_a_dup(const char *dump_dir_name, void *param)
dd_uid = dd_load_text_ext(dd, FILENAME_UID, DD_FAIL_QUIETLY_ENOENT);
if (strcmp(uid, dd_uid))
@@ -266,36 +265,35 @@ static int is_crash_a_dup(const char *dump_dir_name, void *param)
dd_analyzer = dd_load_text_ext(dd, FILENAME_ANALYZER, DD_FAIL_QUIETLY_ENOENT);
if (strcmp(analyzer, dd_analyzer))
crash_dump_dup_name = dump_dir_name2;
+ dump_dir_name2 = NULL;
retval = 1; /* "run_event, please stop iterating" */
- goto end;
+ /* sonce crash_dump_dup_name != NULL now, we exit the loop */
static char *do_log(char *log_line, void *param)
- /* We pipe output of events to our log (which usually
- * includes syslog). Otherwise, errors on post-create result in
+ /* We pipe output of events to our log.
+ * Otherwise, errors on post-create result in
* "Corrupted or bad dump DIR, deleting" without adequate explanation why.
@@ -355,13 +353,21 @@ int main(int argc, char **argv)
struct run_event_state *run_state = new_run_event_state();
+ run_state->logging_callback = do_log;
run_state->post_run_callback = is_crash_a_dup;
- run_state->logging_callback = do_log;
int r = run_event_on_dir_name(run_state, dump_dir_name, event_name);
+ /* Needed only if is_crash_a_dup() was called, but harmless
+ * even if it wasn't:
if (r == 0 && run_state->children_count == 0)
error_msg_and_die("No actions are found for event '%s'", event_name);
//TODO: consider this case:
// new dump is created, post-create detects that it is a dup,
@@ -372,24 +378,17 @@ int main(int argc, char **argv)
/* Is crash a dup? (In this case, is_crash_a_dup() should have
* aborted "post-create" event processing as soon as it saw uuid
* and determined that there is another crash with same uuid.
- * In this case it sets state.crash_dump_dup_name)
+ * In this case it sets crash_dump_dup_name)
- if (!crash_dump_dup_name)
- /* No. Was there error on one of processing steps in run_event? */
- if (r != 0)
- return r; /* yes */
+ if (crash_dump_dup_name)
error_msg_and_die("DUP_OF_DIR: %s", crash_dump_dup_name);
- if (post_create)
+ /* Was there error on one of processing steps in run_event? */
+ if (r != 0)
+ return r; /* yes */
+ dump_dir_name = NULL;
/* exit 0 means, that there is no duplicate of dump-dir */