1.1 --- a/libfsclient/lib/src/file.cc Fri May 10 14:49:52 2024 +0200
1.2 +++ b/libfsclient/lib/src/file.cc Fri May 10 19:00:38 2024 +0200
1.3 @@ -680,16 +680,27 @@
1.4
1.5 /* Access the current region for a pipe endpoint. */
1.6
1.7 -long pipe_current(file_t *pipe)
1.8 +long pipe_current(file_t *pipe, int sync)
1.9 {
1.10 client_Pipe _pipe(pipe->ref);
1.11 - long err = _pipe.current_region(&pipe->data_end, &pipe->size);
1.12 + offset_t data_current;
1.13 + long err = _pipe.current_region(&data_current, &pipe->data_end, &pipe->size);
1.14
1.15 if (err)
1.16 return err;
1.17
1.18 pipe->end_pos = pipe->size;
1.19
1.20 + /* Obtain the current position if synchronising position state. */
1.21 +
1.22 + if (sync)
1.23 + pipe->data_current = data_current;
1.24 +
1.25 + /* Handle any case where the current region has been exhausted. */
1.26 +
1.27 + if (!file_populated_span(pipe))
1.28 + pipe->data_current = 0;
1.29 +
1.30 /* Attach memory if necessary. */
1.31
1.32 if (pipe->memory == NULL)
1.33 @@ -720,6 +731,7 @@
1.34 return err;
1.35
1.36 pipe->end_pos = pipe->size;
1.37 + pipe->data_current = 0;
1.38 pipe->memory = NULL;
1.39
1.40 err = ipc_attach_dataspace(pipe->ref, file_span(pipe), (void **) &pipe->memory);