public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] alfred: handle failing write() in unix sockets
@ 2013-08-09 15:20 Simon Wunderlich
  2013-08-12  9:42 ` Simon Wunderlich
  0 siblings, 1 reply; 2+ messages in thread
From: Simon Wunderlich @ 2013-08-09 15:20 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Simon Wunderlich

This is not really critical, but some compilers seem to complain about
that.

Reported-by: Braden Aran <bradenaran@gmail.com>
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
---
 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)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH] alfred: handle failing write() in unix sockets
  2013-08-09 15:20 [B.A.T.M.A.N.] [PATCH] alfred: handle failing write() in unix sockets Simon Wunderlich
@ 2013-08-12  9:42 ` Simon Wunderlich
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Wunderlich @ 2013-08-12  9:42 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

On Fri, Aug 09, 2013 at 05:20:17PM +0200, Simon Wunderlich wrote:
> This is not really critical, but some compilers seem to complain about
> that.
> 
> Reported-by: Braden Aran <bradenaran@gmail.com>
> Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>

Applied in revision 4a77be4.

Cheers,
	Simon

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-12  9:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-09 15:20 [B.A.T.M.A.N.] [PATCH] alfred: handle failing write() in unix sockets Simon Wunderlich
2013-08-12  9:42 ` Simon Wunderlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox