diff options
author | Julian Bouzas <julian.bouzas@collabora.com> | 2021-06-28 11:10:48 -0400 |
---|---|---|
committer | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2021-07-28 13:19:02 +0300 |
commit | fb530b4f92126cbf1802fb711f945c3f34c11fbb (patch) | |
tree | c6377ac72d1cd21d7ae344a615d1c7cb268f66e5 | |
parent | 90bc52450f7a65f5489ae6a499ac7bb8c8781f23 (diff) |
tests: examples: print error if buffer is not valid in wpipc-client
If we lose connection with the server while a request was pending, the request
callback is still triggered but with NULL buffer.
Signed-off-by: George Kiagiadakis <george.kiagiadakis@collabora.com>
-rw-r--r-- | src/icipc-client.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/icipc-client.c b/src/icipc-client.c index aa71b1f..587878c 100644 --- a/src/icipc-client.c +++ b/src/icipc-client.c @@ -24,11 +24,16 @@ reply_handler (struct icipc_sender *self, const uint8_t *buffer, size_t size, vo { struct client_data *data = p; const char *error = NULL; - const struct spa_pod *pod = icipc_client_send_request_finish (self, buffer, size, &error); - if (!pod) - printf ("error: %s\n", error ? error : "unknown"); - else - printf ("success!\n"); + + if (buffer) { + const struct spa_pod *pod = icipc_client_send_request_finish (self, buffer, size, &error); + if (!pod) + printf ("error: %s\n", error ? error : "unknown"); + else + printf ("success!\n"); + } else { + printf ("error: lost connection with server\n"); + } /* signal reply received */ pthread_mutex_lock (&data->mutex); |