5 #define USTD_BUFFER_TRUNC(offset, bufinfo) \
6 ((offset) & (~(((bufinfo)->subbuf_size*(bufinfo)->n_subbufs)-1)))
8 void finish_consuming_dead_subbuffer(struct buffer_info
*buf
)
10 struct ltt_channel_buf_struct
*ltt_buf
= buf
->bufstruct_mem
;
12 long write_offset
= local_read(<t_buf
->offset
);
13 long consumed_offset
= atomic_long_read(<t_buf
->consumed
);
17 DBG("processing died buffer");
18 DBG("consumed offset is %ld", consumed_offset
);
19 DBG("write offset is %ld", write_offset
);
21 long first_subbuf
= write_offset
/ buf
->subbuf_size
;
22 long last_subbuf
= consumed_offset
/ buf
->subbuf_size
;
24 if(last_subbuf
- first_subbuf
> buf
->n_subbufs
) {
25 DBG("an overflow has occurred, nothing can be recovered");
29 for(i_subbuf
=first_subbuf
; ; i_subbuf
++, i_subbuf
%= buf
->n_subbufs
) {
30 long commit_count
= local_read(<t_buf
->commit_count
[i_subbuf
]);
32 unsigned long valid_length
= buf
->subbuf_size
;
33 long n_subbufs_order
= get_count_order(buf
->n_subbufs
);
34 long commit_count_mask
= (~0UL >> n_subbufs_order
);
36 /* check if subbuf was fully written */
37 if (((commit_count
- buf
->subbuf_size
) & commit_count_mask
)
38 - (USTD_BUFFER_TRUNC(consumed_offset
, buf
) >> n_subbufs_order
)
40 struct ltt_subbuffer_header
*header
= (struct ltt_subbuffer_header
*)((char *)buf
->mem
)+i_subbuf
*buf
->subbuf_size
;
41 valid_length
= buf
->subbuf_size
- header
->lost_size
;
44 patient_write(buf
->file_fd
, buf
->mem
+ i_subbuf
* buf
->subbuf_size
, buf
->subbuf_size
);
46 if(i_subbuf
== last_subbuf
)
This page took 0.054885 seconds and 4 git commands to generate.