1.1 --- a/libfsserver/lib/pipes/pipe_opener_resource.cc Wed Aug 04 17:30:14 2021 +0200
1.2 +++ b/libfsserver/lib/pipes/pipe_opener_resource.cc Thu Aug 05 01:28:41 2021 +0200
1.3 @@ -19,6 +19,8 @@
1.4 * Boston, MA 02110-1301, USA
1.5 */
1.6
1.7 +#include <ipc/cap_alloc.h>
1.8 +
1.9 #include "pipe_opener_resource.h"
1.10 #include "pipe_opener_server.h"
1.11 #include "pipe_pager.h"
1.12 @@ -55,11 +57,24 @@
1.13
1.14 /* Each endpoint will have its own pager. */
1.15
1.16 - /* NOTE: Failure to open an endpoint should invalidate both, plus the
1.17 - paging object. Also, any active server thread would need to be
1.18 - cancelled. */
1.19 + long err = open_endpoint(paging, true, writer);
1.20 +
1.21 + if (err)
1.22 + return err;
1.23 +
1.24 + err = open_endpoint(paging, false, reader);
1.25
1.26 - return open_endpoint(paging, false, reader) || open_endpoint(paging, true, writer);
1.27 + /* Failure to open an endpoint should invalidate both, plus the paging
1.28 + object. Also, any active server thread would need to be cancelled. The
1.29 + freeing of the writer capability attempts to do this. */
1.30 +
1.31 + if (err)
1.32 + {
1.33 + ipc_cap_free_um(*writer);
1.34 + return err;
1.35 + }
1.36 +
1.37 + return L4_EOK;
1.38 }
1.39
1.40 /* Start the endpoint server in a new thread. If the thread does not start, the
1.41 @@ -69,6 +84,14 @@
1.42 {
1.43 PipePager *pager = new PipePager(paging, writing);
1.44
1.45 + /* Initialise the first region. */
1.46 +
1.47 + offset_t populated_size, region_size;
1.48 + long err = pager->next_region(&populated_size, ®ion_size);
1.49 +
1.50 + if (err)
1.51 + return err;
1.52 +
1.53 return ResourceServer(pager).start_thread(endpoint);
1.54 }
1.55