]> git.tue.mpg.de Git - paraslash.git/commitdiff
vss: Improve EOF handling.
authorAndre Noll <maan@systemlinux.org>
Mon, 9 Mar 2009 20:55:50 +0000 (21:55 +0100)
committerAndre Noll <maan@systemlinux.org>
Mon, 9 Mar 2009 20:55:50 +0000 (21:55 +0100)
Set the "next" flag only if no more writes to fec clients happen.

vss.c

diff --git a/vss.c b/vss.c
index aa76ca2e852a8314667e67ce39192203fc6a69ce..79c09ba7ffe0a0f78053f25f003868dfa7607577 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -781,7 +781,7 @@ err:
  */
 static void vss_send(struct vss_task *vsst)
 {
-       int i;
+       int i, sent_something = 0;
        struct timeval due;
        struct fec_client *fc, *tmp_fc;
 
@@ -792,8 +792,22 @@ static void vss_send(struct vss_task *vsst)
        if (chk_barrier("data send", &vsst->data_send_barrier,
                        &due, 1) < 0)
                return;
+       list_for_each_entry_safe(fc, tmp_fc, &fec_client_list, node) {
+               if (!next_slice_is_due(fc, NULL))
+                       continue;
+               if (compute_next_fec_slice(fc, vsst) <= 0)
+                       continue;
+               PARA_DEBUG_LOG("sending %d:%d (%u bytes)\n", fc->group.num,
+                       fc->current_slice_num, fc->fcp->max_slice_bytes);
+               fc->fcp->send((char *)fc->enc_buf,
+                       fc->fcp->max_slice_bytes,
+                       fc->fcp->private_data);
+               fc->current_slice_num++;
+               sent_something = 1;
+       }
        if (mmd->current_chunk >= mmd->afd.afhi.chunks_total) { /* eof */
-               mmd->new_vss_status_flags |= VSS_NEXT;
+               if (!sent_something)
+                       mmd->new_vss_status_flags |= VSS_NEXT;
                return;
        }
        compute_chunk_time(mmd->chunks_sent, &mmd->afd.afhi.chunk_tv,
@@ -825,18 +839,6 @@ static void vss_send(struct vss_task *vsst)
                mmd->chunks_sent++;
                mmd->current_chunk++;
        }
-       list_for_each_entry_safe(fc, tmp_fc, &fec_client_list, node) {
-               if (!next_slice_is_due(fc, NULL))
-                       continue;
-               if (compute_next_fec_slice(fc, vsst) <= 0)
-                       continue;
-               PARA_DEBUG_LOG("sending %d:%d (%u bytes)\n", fc->group.num,
-                       fc->current_slice_num, fc->fcp->max_slice_bytes);
-               fc->fcp->send((char *)fc->enc_buf,
-                       fc->fcp->max_slice_bytes,
-                       fc->fcp->private_data);
-               fc->current_slice_num++;
-       }
 }
 
 static void vss_post_select(struct sched *s, struct task *t)