Commit 23bac812 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Fix error with crossing disk boundary

parent a834b990
...@@ -459,7 +459,7 @@ int update_lba(camogm_state *state) ...@@ -459,7 +459,7 @@ int update_lba(camogm_state *state)
if (state->writer_params.lba_current + total_sz <= state->writer_params.lba_end) { if (state->writer_params.lba_current + total_sz <= state->writer_params.lba_end) {
state->writer_params.lba_current += total_sz; state->writer_params.lba_current += total_sz;
} else { } else {
state->writer_params.lba_current = state->writer_params.lba_start; state->writer_params.lba_current = state->writer_params.lba_start + total_sz;
ret = 1; ret = 1;
} }
......
...@@ -407,6 +407,7 @@ int camogm_end_jpeg(camogm_state *state) ...@@ -407,6 +407,7 @@ int camogm_end_jpeg(camogm_state *state)
*/ */
void *jpeg_writer(void *thread_args) void *jpeg_writer(void *thread_args)
{ {
int reset_rem;
int chunk_index; int chunk_index;
ssize_t iovlen, l; ssize_t iovlen, l;
bool process = true; bool process = true;
...@@ -443,6 +444,7 @@ void *jpeg_writer(void *thread_args) ...@@ -443,6 +444,7 @@ void *jpeg_writer(void *thread_args)
/* end of dummy read cycle */ /* end of dummy read cycle */
l = 0; l = 0;
reset_rem = 0;
state->writer_params.last_ret_val = 0; state->writer_params.last_ret_val = 0;
chunk_index = get_data_buffers(state, chunks_iovec, FILE_CHUNKS_NUM); chunk_index = get_data_buffers(state, chunks_iovec, FILE_CHUNKS_NUM);
if (chunk_index > 0) { if (chunk_index > 0) {
...@@ -452,6 +454,7 @@ void *jpeg_writer(void *thread_args) ...@@ -452,6 +454,7 @@ void *jpeg_writer(void *thread_args)
if (iovlen < l) { if (iovlen < l) {
D0(fprintf(debug_file, "writev error: %s (returned %i, expected %i)\n", strerror(errno), iovlen, l)); D0(fprintf(debug_file, "writev error: %s (returned %i, expected %i)\n", strerror(errno), iovlen, l));
state->writer_params.last_ret_val = -CAMOGM_FRAME_FILE_ERR; state->writer_params.last_ret_val = -CAMOGM_FRAME_FILE_ERR;
reset_rem = 1;
} else { } else {
// update statistic // update statistic
state->rawdev.last_jpeg_size = l; state->rawdev.last_jpeg_size = l;
...@@ -461,10 +464,11 @@ void *jpeg_writer(void *thread_args) ...@@ -461,10 +464,11 @@ void *jpeg_writer(void *thread_args)
} else { } else {
D0(fprintf(debug_file, "data vector mapping error: %d)\n", chunk_index)); D0(fprintf(debug_file, "data vector mapping error: %d)\n", chunk_index));
state->writer_params.last_ret_val = -CAMOGM_FRAME_FILE_ERR; state->writer_params.last_ret_val = -CAMOGM_FRAME_FILE_ERR;
reset_rem = 1;
} }
// release main thread // release main thread
reset_chunks(state->writer_params.data_chunks, 0); reset_chunks(state->writer_params.data_chunks, reset_rem);
params->data_ready = false; params->data_ready = false;
pthread_cond_signal(&params->main_cond); pthread_cond_signal(&params->main_cond);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment