mood_check_callback(): Return negative on errors
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 5 Apr 2015 15:48:57 +0000 (15:48 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 12 Aug 2015 21:23:48 +0000 (23:23 +0200)
mood.c

diff --git a/mood.c b/mood.c
index a98f68b2e44c997843148a0400d84d3ba02710be..fb988b2fa22e02c75dffa73a209fe393c115b0a9 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -410,8 +410,7 @@ static int check_mood(struct osl_row *mood_row, void *data)
        int ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def);
 
        if (ret < 0) {
-               para_printf(pb, "failed to get mood definition: %s\n",
-                       para_strerror(-ret));
+               para_printf(pb, "cannot read mood\n");
                return ret;
        }
        if (!*mood_name) /* ignore dummy row */
@@ -420,8 +419,9 @@ static int check_mood(struct osl_row *mood_row, void *data)
        ret = for_each_line(FELF_READ_ONLY, mood_def.data, mood_def.size,
                parse_mood_line, &mlpd);
        if (ret < 0)
-               para_printf(pb, "%s line %u: %s\n", mood_name, mlpd.line_num,
-                       para_strerror(-ret));
+               para_printf(pb, "mood %s: error in line %u: %s\n", mood_name,
+                       mlpd.line_num, para_strerror(-ret));
+       ret = 1; /* don't fail the loop on invalid mood definitions */
 out:
        osl_close_disk_object(&mood_def);
        return ret;
@@ -433,10 +433,12 @@ out:
  * \param fd The afs socket.
  * \param query Unused.
  *
- * \return Currently this function always returns zero.
+ * \return Negative on fatal errors. Inconsistent mood definitions are not
+ * considered an error.
  */
 int mood_check_callback(int fd, __a_unused const struct osl_object *query)
 {
+       int ret;
        struct para_buffer pb = {
                .max_size = shm_get_shmmax(),
                .private_data = &(struct afs_max_size_handler_data) {
@@ -447,10 +449,10 @@ int mood_check_callback(int fd, __a_unused const struct osl_object *query)
        };
 
        para_printf(&pb, "checking moods...\n");
-       osl_rbtree_loop(moods_table, BLOBCOL_ID, &pb,
-               check_mood);
+       ret = osl(osl_rbtree_loop(moods_table, BLOBCOL_ID, &pb,
+               check_mood));
        flush_and_free_pb(&pb);
-       return 0;
+       return ret;
 }
 
 static int64_t normalized_value(int64_t x, int64_t n, int64_t sum, int64_t qd)