[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH tabled] server/server.c (net_write_port): Don't ignore write error.



Better safe than sorry...
Unreported write failures can be unpleasant.
I fixed the one below so that a failure indication
can propagate up the call tree.  You might also want to
report the failure to stderr.

I let my editor automatically update the copyright date
and remove trailing spaces.
If you'd rather separate those from the fix,
let me know and I can adjust and resend.

>From abe4be09fea8194fe0c4187c20ebaa45822c839c Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Thu, 23 Sep 2010 09:38:24 +0200
Subject: [PATCH tabled] server/server.c (net_write_port): Don't ignore write error.


Signed-off-by: Jim Meyering <meyering@xxxxxxxxxx>
---
 server/server.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/server/server.c b/server/server.c
index 7a9fb7a..3398026 100644
--- a/server/server.c
+++ b/server/server.c
@@ -1,6 +1,6 @@

 /*
- * Copyright 2008-2009 Red Hat, Inc.
+ * Copyright 2008-2010 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1613,7 +1613,7 @@ void cld_update_cb(void)
  * server, the management of nodes is not in storage.c, which deals
  * with the interface to Chunk and little more.
  *
- * We don't even bother with registering this callback, just call it by name. 
+ * We don't even bother with registering this callback, just call it by name.
  *
  * The return value is used to re-arm storage rescan mechanism.
  */
@@ -1847,9 +1847,12 @@ static int net_write_port(const char *port_file,
 		       port_file, strerror(rc));
 		return -rc;
 	}
-	fprintf(portf, "%s:%s\n", tabled_srv.ourhost, port);
-	fclose(portf);
-	return 0;
+	if (fprintf(portf, "%s:%s\n", tabled_srv.ourhost, port) < 0) {
+		rc = errno;
+		fclose(portf);
+		return -rc;
+	}
+	return fclose(portf) ? -errno : 0;
 }

 /*
@@ -1959,7 +1962,7 @@ static int net_open_known(const char *portstr, bool is_status)
 			continue;

 		rc = net_open_socket(res->ai_family, res->ai_socktype,
-				     res->ai_protocol, 
+				     res->ai_protocol,
 				     res->ai_addrlen, res->ai_addr, is_status);
 		if (rc < 0)
 			goto err_out;
@@ -2348,4 +2351,3 @@ err_out:
 		closelog();
 	return rc;
 }
-
-- 
1.7.3.234.g7bba3

--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Free Online Dating]     [Linux Kernel]     [Linux SCSI]     [XFree86]

Add to Google Powered by Linux