libustconsumer: check read subuffer return value
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 3 Mar 2011 16:59:42 +0000 (11:59 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 3 Mar 2011 16:59:42 +0000 (11:59 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
libustconsumer/lowlevel.c

index fdc4e24291cb66e4726324b4bec32432f2a13f34..ec3cf89cd539e9bca6670b5f17c93df57bb5537f 100644 (file)
@@ -130,6 +130,7 @@ void finish_consuming_dead_subbuffer(struct ustconsumer_callbacks *callbacks, st
        long consumed_offset = uatomic_read(&ustbuf->consumed);
 
        long i_subbuf;
+       int ret;
 
        DBG("processing dead buffer (%s)", buf->name);
        DBG("consumed offset is %ld (%s)", consumed_offset, buf->name);
@@ -187,13 +188,12 @@ void finish_consuming_dead_subbuffer(struct ustconsumer_callbacks *callbacks, st
                        assert(i_subbuf == (last_subbuf % buf->n_subbufs));
                }
 
-               /* TODO: check on_read_partial_subbuffer return value */
                if(callbacks->on_read_partial_subbuffer)
-                       callbacks->on_read_partial_subbuffer(callbacks, buf, i_subbuf, valid_length);
+                       ret = callbacks->on_read_partial_subbuffer(callbacks, buf, i_subbuf, valid_length);
 
-               /* Manually increment the consumed offset */
-               /* TODO ybrosseau 2011-03-02: Should only be done if the previous read was successful */
-               uatomic_add(&ustbuf->consumed, buf->subbuf_size);
+               /* Increment the consumed offset */
+               if (ret >= 0)
+                       uatomic_add(&ustbuf->consumed, buf->subbuf_size);
 
                if(i_subbuf == last_subbuf % buf->n_subbufs)
                        break;
This page took 0.024195 seconds and 4 git commands to generate.