From fb530b4f92126cbf1802fb711f945c3f34c11fbb Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Mon, 28 Jun 2021 11:10:48 -0400 Subject: 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 --- src/icipc-client.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') 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); -- cgit 1.2.3-korg