From b859266a264db80fbaef38157fdb21422dd5a3ae Mon Sep 17 00:00:00 2001 From: jjqq Date: Fri, 12 Jan 2018 11:43:12 +0900 Subject: [PATCH] fix incorrect error message of connect There is a confusing error message when failed to connect to tgtd unix domain socket, it could not check the error, instead, it just continue to call write, which in turn cause error `failed to send request hdr to tgt daemon, Transport endpoint is not connected`. ``` err = ipc_mgmt_connect(&fd); if (err < 0) { ``` When ipc_mgmt_connect failed, it returns errno as err, so the err will be a positive value, so when error happens, this check does not works. ``` eprintf("can't connect to tgt daemon, %m\n"); goto out; } err = write(fd, req, sizeof(*req)); ``` In fact, it should report error when connect: `can't connect to tgt daemon, THE REAL REASON` --- usr/tgtadm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/tgtadm.c b/usr/tgtadm.c index 5572c388..318f9fe3 100644 --- a/usr/tgtadm.c +++ b/usr/tgtadm.c @@ -317,7 +317,7 @@ static int ipc_mgmt_req(struct tgtadm_req *req, struct concat_buf *b) req->len = sizeof(*req) + b->size; err = ipc_mgmt_connect(&fd); - if (err < 0) { + if (err != 0) { eprintf("can't connect to tgt daemon, %m\n"); goto out; }