# HG changeset patch # User Paul Boddie # Date 1625527367 -7200 # Node ID 128f6070281eb66f3bef7277d3e37d9fbeba9e07 # Parent 07fdc0fbfdafc4a0e371a6494b39b6f83863a062 Fixed notification message handling. Test message types in the example. diff -r 07fdc0fbfdaf -r 128f6070281e libfsclient/lib/src/notifier.cc --- a/libfsclient/lib/src/notifier.cc Tue Jul 06 01:01:53 2021 +0200 +++ b/libfsclient/lib/src/notifier.cc Tue Jul 06 01:22:47 2021 +0200 @@ -102,7 +102,7 @@ /* Record the flags for the file object. */ - _affected_flags[file] |= flags; + _affected_flags[file] = _affected_flags[file] | flags; _affected.push_back(file); /* Notify any waiting caller. */ @@ -130,14 +130,20 @@ if (l4_ipc_error(msg.tag, l4_utcb())) continue; + /* Interpret gate labels as file objects. */ + + file_t *file = (file_t *) label; + + /* Obtain message details. */ + + ipc_message_open(&msg); + + notify_flags_t flags = ipc_message_get_word(&msg, 0); + /* Reply to notifications. */ ipc_message_reply(&msg); - - /* Interpret gate labels as file objects. */ - - file_t *file = (file_t *) label; - notify_flags_t flags = ipc_message_get_word(&msg, 0); + ipc_message_discard(&msg); /* Register the notification. */ diff -r 07fdc0fbfdaf -r 128f6070281e tests/dstest_pipe_client.cc --- a/tests/dstest_pipe_client.cc Tue Jul 06 01:01:53 2021 +0200 +++ b/tests/dstest_pipe_client.cc Tue Jul 06 01:22:47 2021 +0200 @@ -81,8 +81,7 @@ static void read_pipes(file_t *reader1, file_t *reader2) { offset_t size = 600, totals[] = {0, 0}; - bool active[] = {true, true}; - int num_active = 2; + unsigned int active = 2; long err; file_t *reader; @@ -118,23 +117,19 @@ continue; } - nread = client_read(reader, buffer, size); - - // NOTE: Should really be testing for the condition somehow. - int p = reader == reader1 ? 0 : 1; - if (!nread) + printf("Pipe #%d notified with conditions:%s%s\n", p, reader->notifications & NOTIFY_PEER_CLOSED ? " closed" : "", + reader->notifications & NOTIFY_CONTENT_AVAILABLE ? " content" : ""); + + if (reader->notifications & NOTIFY_PEER_CLOSED) { - if (active[p]) - { - active[p] = false; - num_active--; + active--; + if (!active) + break; + } - if (!num_active) - break; - } - } + nread = client_read(reader, buffer, size); while (nread) {