From patchwork Fri Aug 9 15:20:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 3273 Return-Path: Received: from cora.hrz.tu-chemnitz.de (cora.hrz.tu-chemnitz.de [134.109.228.40]) by open-mesh.org (Postfix) with ESMTPS id 679F6602234 for ; Fri, 9 Aug 2013 17:20:20 +0200 (CEST) Received: from p4ffe4ab9.dip0.t-ipconnect.de ([79.254.74.185] helo=pandem0nium) by cora.hrz.tu-chemnitz.de with esmtpsa (TLSv1:DHE-RSA-AES128-SHA:128) (Exim 4.80.1) (envelope-from ) id 1V7oUF-0003w9-FW; Fri, 09 Aug 2013 17:20:19 +0200 Received: from dotslash by pandem0nium with local (Exim 4.80) (envelope-from ) id 1V7oUE-0004oo-BS; Fri, 09 Aug 2013 17:20:18 +0200 From: Simon Wunderlich To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 9 Aug 2013 17:20:17 +0200 Message-Id: <1376061617-18493-1-git-send-email-siwu@hrz.tu-chemnitz.de> X-Mailer: git-send-email 1.7.10.4 X-purgate: clean X-purgate-type: clean X-purgate-ID: 154106::1376061619-0000051A-A6F1B379/0-0/0-0 X-Scan-AV: cora.hrz.tu-chemnitz.de; 2013-08-09 17:20:19; 78576081b4f29e045664135291d2d75a X-Scan-SA: cora.hrz.tu-chemnitz.de; 2013-08-09 17:20:19; 1430cd3bedfbf5272906024641cc46ee X-Spam-Score: -1.0 (-) X-Spam-Report: --- Textanalyse SpamAssassin 3.3.1 (-1.0 Punkte) Fragen an/questions to: Postmaster TU Chemnitz * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP --- Ende Textanalyse Cc: Simon Wunderlich Subject: [B.A.T.M.A.N.] [PATCH] alfred: handle failing write() in unix sockets X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Aug 2013 15:20:20 -0000 This is not really critical, but some compilers seem to complain about that. Reported-by: Braden Aran Signed-off-by: Simon Wunderlich --- unix_sock.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/unix_sock.c b/unix_sock.c index b29f635..c778a61 100644 --- a/unix_sock.c +++ b/unix_sock.c @@ -158,7 +158,7 @@ static int unix_sock_req_data_reply(struct globals *globals, int client_sock, struct alfred_push_data_v0 *push; struct hash_it_t *hashit = NULL; uint8_t buf[MAX_PAYLOAD]; - uint16_t seqno = 0; + uint16_t seqno = 0, ret = 0; /* send some data back through the unix socket */ @@ -184,12 +184,15 @@ static int unix_sock_req_data_reply(struct globals *globals, int client_sock, push->header.length = htons(len); push->tx.seqno = htons(seqno++); - write(client_sock, buf, sizeof(push->header) + len); + if (write(client_sock, buf, sizeof(push->header) + len) < 0) { + ret = -1; + break; + } } close(client_sock); - return 0; + return ret; } static int unix_sock_req_data(struct globals *globals, @@ -234,7 +237,7 @@ int unix_sock_req_data_finish(struct globals *globals, struct transaction_head *head) { struct alfred_status_v0 status; - int send_data = 1; + int ret = 0, send_data = 1; int client_sock; uint16_t id; uint8_t requested_type; @@ -258,10 +261,11 @@ int unix_sock_req_data_finish(struct globals *globals, status.header.length = htons(sizeof(status) - sizeof(status.header)); status.tx.id = htons(id); status.tx.seqno = 1; - write(client_sock, &status, sizeof(status)); + if (write(client_sock, &status, sizeof(status)) < 0) + ret = -1; close(client_sock); - return 0; + return ret; } int unix_sock_read(struct globals *globals)