1.1 --- a/libfsclient/include/fsclient/client.h Thu May 20 00:01:53 2021 +0200
1.2 +++ b/libfsclient/include/fsclient/client.h Mon Jun 07 00:50:14 2021 +0200
1.3 @@ -56,7 +56,7 @@
1.4
1.5 /* Notification operations. */
1.6
1.7 -long client_set_blocking(file_t *file, int can_block);
1.8 +long client_set_blocking(file_t *file, notify_flags_t flags);
1.9 long client_subscribe(file_t *file, notify_flags_t flags);
1.10 long client_unsubscribe(file_t *file);
1.11 long client_wait(file_t *file);
2.1 --- a/libfsclient/include/fsclient/file.h Thu May 20 00:01:53 2021 +0200
2.2 +++ b/libfsclient/include/fsclient/file.h Mon Jun 07 00:50:14 2021 +0200
2.3 @@ -65,7 +65,7 @@
2.4
2.5 /* Blocking accesses. */
2.6
2.7 - int can_block;
2.8 + notify_flags_t can_block;
2.9
2.10 } file_t;
2.11
3.1 --- a/libfsclient/lib/src/client.cc Thu May 20 00:01:53 2021 +0200
3.2 +++ b/libfsclient/lib/src/client.cc Mon Jun 07 00:50:14 2021 +0200
3.3 @@ -399,24 +399,24 @@
3.4
3.5 /* Set or unset blocking access for a file. */
3.6
3.7 -long client_set_blocking(file_t *file, int can_block)
3.8 +long client_set_blocking(file_t *file, notify_flags_t flags)
3.9 {
3.10 long err;
3.11
3.12 - if (file->can_block == can_block)
3.13 + if (file->can_block == flags)
3.14 return L4_EOK;
3.15
3.16 // NOTE: Set appropriate flags.
3.17
3.18 - if (can_block)
3.19 - err = client_subscribe(file, 0);
3.20 + if (flags)
3.21 + err = client_subscribe(file, flags);
3.22 else
3.23 err = client_unsubscribe(file);
3.24
3.25 if (err)
3.26 return err;
3.27
3.28 - file->can_block = can_block;
3.29 + file->can_block = flags;
3.30 return L4_EOK;
3.31 }
3.32
4.1 --- a/libfsserver/include/fsserver/pipe_paging.h Thu May 20 00:01:53 2021 +0200
4.2 +++ b/libfsserver/include/fsserver/pipe_paging.h Mon Jun 07 00:50:14 2021 +0200
4.3 @@ -57,6 +57,7 @@
4.4 /* Notification IRQs. */
4.5
4.6 l4_cap_idx_t _irqs[2];
4.7 + notify_flags_t _flags[2];
4.8
4.9 /* Common functionality. */
4.10
4.11 @@ -72,9 +73,9 @@
4.12
4.13 /* Notification support. */
4.14
4.15 - virtual void notify(bool writing);
4.16 + virtual void notify(bool writing, notify_flags_t flags);
4.17
4.18 - virtual l4_cap_idx_t subscribe(bool writing);
4.19 + virtual l4_cap_idx_t subscribe(bool writing, notify_flags_t flags);
4.20
4.21 virtual void unsubscribe(bool writing);
4.22
5.1 --- a/libfsserver/lib/pipes/pipe_pager.cc Thu May 20 00:01:53 2021 +0200
5.2 +++ b/libfsserver/lib/pipes/pipe_pager.cc Mon Jun 07 00:50:14 2021 +0200
5.3 @@ -58,7 +58,7 @@
5.4
5.5 /* Notify the other endpoint. */
5.6
5.7 - _paging->notify(_writing);
5.8 + _paging->notify(_writing, NOTIFY_PEER_CLOSED);
5.9 }
5.10
5.11 /* Support paging. */
5.12 @@ -154,7 +154,9 @@
5.13
5.14 *size = _size;
5.15
5.16 - _paging->notify(_writing);
5.17 + // NOTE: Perhaps employ a distinct event type for metadata updates.
5.18 +
5.19 + _paging->notify(_writing, NOTIFY_CONTENT_AVAILABLE | NOTIFY_SPACE_AVAILABLE);
5.20 return L4_EOK;
5.21 }
5.22
5.23 @@ -164,11 +166,10 @@
5.24
5.25 long PipePager::subscribe(notify_flags_t flags, l4_cap_idx_t *irq)
5.26 {
5.27 - // NOTE: Need to interpret flags.
5.28 - // NOTE: Readers can subscribe to new data (at end), and pipe closed events.
5.29 - // NOTE: Writers can subscribe to new space and pipe closed events.
5.30 + /* Readers can subscribe to new data (at end), and pipe closed events.
5.31 + Writers can subscribe to new space and pipe closed events. */
5.32
5.33 - *irq = _paging->subscribe(_writing);
5.34 + *irq = _paging->subscribe(_writing, flags);
5.35 return L4_EOK;
5.36 }
5.37
6.1 --- a/libfsserver/lib/pipes/pipe_paging.cc Thu May 20 00:01:53 2021 +0200
6.2 +++ b/libfsserver/lib/pipes/pipe_paging.cc Mon Jun 07 00:50:14 2021 +0200
6.3 @@ -44,21 +44,26 @@
6.4 for (unsigned int i = 0; i < 2; i++)
6.5 _regions[i] = NULL;
6.6
6.7 - /* Initialise IRQ objects for notifications. */
6.8 + /* Initialise IRQ objects and flags for notifications. */
6.9
6.10 for (unsigned int i = 0; i < 2; i++)
6.11 + {
6.12 _irqs[i] = L4_INVALID_CAP;
6.13 + _flags[i] = 0;
6.14 + }
6.15 }
6.16
6.17 /* Create an IRQ to subscribe to an endpoint's notifications. */
6.18
6.19 -l4_cap_idx_t PipePaging::subscribe(bool writing)
6.20 +l4_cap_idx_t PipePaging::subscribe(bool writing, notify_flags_t flags)
6.21 {
6.22 int i = writing ? 1 : 0;
6.23
6.24 if (l4_is_invalid_cap(_irqs[i]))
6.25 ipc_create_irq(&_irqs[i]);
6.26
6.27 + _flags[i] = flags;
6.28 +
6.29 return _irqs[i];
6.30 }
6.31
6.32 @@ -72,18 +77,19 @@
6.33 {
6.34 ipc_cap_free_um(_irqs[i]);
6.35 _irqs[i] = L4_INVALID_CAP;
6.36 + _flags[i] = 0;
6.37 }
6.38 }
6.39
6.40 /* Notify the other endpoint. */
6.41
6.42 -void PipePaging::notify(bool writing)
6.43 +void PipePaging::notify(bool writing, notify_flags_t flags)
6.44 {
6.45 /* Let the writer notify the reader, and the other way round. */
6.46
6.47 int i = writing ? 0 : 1;
6.48
6.49 - if (l4_is_valid_cap(_irqs[i]))
6.50 + if (l4_is_valid_cap(_irqs[i]) && (flags & _flags[i]))
6.51 l4_irq_trigger(_irqs[i]);
6.52 }
6.53
6.54 @@ -170,7 +176,7 @@
6.55
6.56 /* Let the writer notify the reader. */
6.57
6.58 - notify(true);
6.59 + notify(true, NOTIFY_CONTENT_AVAILABLE);
6.60
6.61 /* Return the next region's mapper. */
6.62
6.63 @@ -205,7 +211,7 @@
6.64
6.65 /* Let the reader notify the writer. */
6.66
6.67 - notify(false);
6.68 + notify(false, NOTIFY_SPACE_AVAILABLE);
6.69
6.70 /* Return the next region's mapper. */
6.71
7.1 --- a/tests/dstest_pipe_client.cc Thu May 20 00:01:53 2021 +0200
7.2 +++ b/tests/dstest_pipe_client.cc Mon Jun 07 00:50:14 2021 +0200
7.3 @@ -106,7 +106,8 @@
7.4
7.5 /* Make the reader and writer blocking to permit synchronisation. */
7.6
7.7 - if ((err = client_set_blocking(&reader, true)) || (err = client_set_blocking(&writer, true)))
7.8 + if ((err = client_set_blocking(&reader, NOTIFY_CONTENT_AVAILABLE)) ||
7.9 + (err = client_set_blocking(&writer, NOTIFY_SPACE_AVAILABLE)))
7.10 {
7.11 printf("Could not set as blocking: %s\n", l4sys_errtostr(err));
7.12 return 1;