diff mbox series

client: simply return if async start fails

Message ID 1554213100-14864-1-git-send-email-awais_belal@mentor.com
State Changes Requested
Headers show
Series client: simply return if async start fails | expand

Commit Message

Awais Belal April 2, 2019, 1:51 p.m. UTC
The client should return after cleaning up if async
start fails for any reason otherwise the caller will
block because the client app will keep on waiting for
the mutex which will never be triggered.

Signed-off-by: Awais Belal <awais_belal@mentor.com>
---
 tools/client.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/client.c b/tools/client.c
index 6dd378c..a324be7 100644
--- a/tools/client.c
+++ b/tools/client.c
@@ -113,8 +113,12 @@  static int send_file(const char* filename) {
 
 	rc = swupdate_async_start(readimage, printstatus,
 				end, dryrun);
-	if (rc)
+	if (rc) {
 		printf("swupdate_async_start returns %d\n", rc);
+		pthread_mutex_unlock(&mymutex);
+		close(fd);
+		return 1;
+	}
 
 	/* Now block */
 	pthread_mutex_lock(&mymutex);