[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140320094138.14878.13459.stgit@localhost.localdomain>
Date: Thu, 20 Mar 2014 15:11:38 +0530
From: Janani Venkataraman <jananive@...ux.vnet.ibm.com>
To: linux-kernel@...r.kernel.org
Cc: amwang@...hat.com, procps@...elists.org, rdunlap@...otime.net,
james.hogan@...tec.com, aravinda@...ux.vnet.ibm.com, hch@....de,
mhiramat@...hat.com, jeremy.fitzhardinge@...rix.com,
xemul@...allels.com, d.hatayama@...fujitsu.com, coreutils@....org,
kosaki.motohiro@...fujitsu.com, adobriyan@...il.com,
util-linux@...r.kernel.org, tarundsk@...ux.vnet.ibm.com,
vapier@...too.org, roland@...k.frob.com, ananth@...ux.vnet.ibm.com,
gorcunov@...nvz.org, avagin@...nvz.org, oleg@...hat.com,
eparis@...hat.com, suzuki@...ux.vnet.ibm.com, andi@...stfloor.org,
tj@...nel.org, akpm@...ux-foundation.org,
torvalds@...ux-foundation.org
Subject: [PATCH 19/33] Block till request
Block until input arrives on the socket.
Signed-off-by: Janani Venkataraman <jananive@...ux.vnet.ibm.com>
---
src/coredump.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/src/coredump.c b/src/coredump.c
index c992c66..d93f4b2 100644
--- a/src/coredump.c
+++ b/src/coredump.c
@@ -349,6 +349,38 @@ int setup_server(void)
return 0;
}
+/* Blocking on a request */
+int block_on_request(void)
+{
+ fd_set read;
+
+ do {
+ /* Initialise */
+ FD_ZERO(&read);
+ FD_SET(socket_fd, &read);
+
+ gencore_log("[%d]: Waiting on incoming request.\n", pid_log);
+
+ if (select(socket_fd + 1, &read, NULL, NULL, NULL) <= 0) {
+ /*
+ * EINTR just means a signal is caught and hence, we need not
+ * terminate for this error.
+ */
+ if (errno != EINTR) {
+ gencore_log("[%d]: Error while waiting for connection requests.\n",
+ pid_log, strerror(errno));
+ close(socket_fd);
+ return -1;
+ }
+ }
+
+ } while(FD_ISSET(socket_fd, &read) == 0);
+
+ gencore_log("[%d]: Request found.\n", pid_log);
+
+ return 0;
+}
+
/* Daemon for self dump */
int daemon_dump(void)
{
@@ -386,6 +418,19 @@ int daemon_dump(void)
/* Flush the log */
fflush(fp_log);
+ while (1) {
+
+ /* Blocks on request */
+ ret = block_on_request();
+ if (ret)
+ goto cleanup;
+
+ /* Flush the log */
+ fflush(fp_log);
+ }
+
+ return 0;
+
cleanup:
fclose(fp_log);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists