From 12d882918ebdcf0c993837950758575982f8a379 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 15 Jan 2013 19:46:04 +0200 Subject: [PATCH] core: Fix handling mgmt socket write failures If a write to the socket fails we should properly notify the command callback and remove the command from the queue. --- src/shared/mgmt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c index c41454b47..f96897d68 100644 --- a/src/shared/mgmt.c +++ b/src/shared/mgmt.c @@ -27,6 +27,8 @@ #include #include +#include +#include #include @@ -155,8 +157,13 @@ static gboolean can_write_data(GIOChannel *channel, GIOCondition cond, bytes_written = write(mgmt->fd, request->buf, request->len); if (bytes_written < 0) { - g_queue_push_head(mgmt->request_queue, request); - return FALSE; + util_debug(mgmt->debug_callback, mgmt->debug_data, + "write failed: %s", strerror(errno)); + if (request->callback) + request->callback(MGMT_STATUS_FAILED, 0, NULL, + request->user_data); + destroy_request(request, NULL); + return TRUE; } util_debug(mgmt->debug_callback, mgmt->debug_data, -- 2.47.3