Pass command exit status via sideband to client.
[paraslash.git] / mood.c
diff --git a/mood.c b/mood.c
index d9ae48bf967e61b0c4c0ca499d75f0b47eb47b96..bafe710c09372a7e8a1f82168324d9a64a0e633e 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2011 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2007-2012 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -17,6 +17,7 @@
 #include "list.h"
 #include "ipc.h"
 #include "mm.h"
+#include "sideband.h"
 
 /**
  * Contains statistical data of the currently admissible audio files.
@@ -364,8 +365,10 @@ static int load_mood(const struct osl_row *mood_row, struct mood **m)
        char *mood_name;
        struct osl_object mood_def;
        struct mood_line_parser_data mlpd = {.line_num = 0};
-       int ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def);
+       int ret;
 
+       *m = NULL;
+       ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def);
        if (ret < 0)
                return ret;
        if (!*mood_name)
@@ -423,8 +426,11 @@ void mood_check_callback(int fd, __a_unused const struct osl_object *query)
 {
        struct para_buffer pb = {
                .max_size = shm_get_shmmax(),
-               .private_data = &fd,
-               .max_size_handler = pass_buffer_as_shm
+               .private_data = &(struct afs_max_size_handler_data) {
+                       .fd = fd,
+                       .band = SBD_OUTPUT
+               },
+               .max_size_handler = afs_max_size_handler
        };
 
        int ret = para_printf(&pb, "checking moods...\n");
@@ -433,7 +439,7 @@ void mood_check_callback(int fd, __a_unused const struct osl_object *query)
        osl_rbtree_loop(moods_table, BLOBCOL_ID, &pb,
                check_mood);
        if (pb.offset)
-               pass_buffer_as_shm(pb.buf, pb.offset, &fd);
+               pass_buffer_as_shm(fd, SBD_OUTPUT, pb.buf, pb.offset);
        free(pb.buf);
 }