# HG changeset patch # User Paul Boddie # Date 1712095111 -7200 # Node ID eff120c8f9e3bf38da7de6b28ae296f8b261af46 # Parent bc1d11f419631919e85cbe4a320ed7d046c088c4 Tidy up current pipe region handling, particularly when the region is exhausted. diff -r bc1d11f41963 -r eff120c8f9e3 libfsclient/lib/src/client.cc --- a/libfsclient/lib/src/client.cc Tue Apr 02 23:16:23 2024 +0200 +++ b/libfsclient/lib/src/client.cc Tue Apr 02 23:58:31 2024 +0200 @@ -118,9 +118,11 @@ } else { + bool initial = (file->memory == NULL); + /* Handle the initial condition with no current region. */ - if (file->memory == NULL) + if (initial) { err = client_current_region(file); if (err) @@ -150,7 +152,10 @@ else { - return client_current_region(file); + if (initial) + return L4_EOK; + else + return client_current_region(file); } } } @@ -552,7 +557,17 @@ if (!client_opened(file)) return -L4_EINVAL; - return pipe_current(file); + long err = pipe_current(file); + + if (err) + return err; + + /* Handle any case where the current region has been exhausted. */ + + if (!file_populated_span(file)) + file->data_current = 0; + + return L4_EOK; }