aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2014-05-16 15:38:44 -0500
committerPeter Seebach <peter.seebach@windriver.com>2014-05-16 15:40:56 -0500
commitbec11654de69611ae6088d3aaa4a8d6f40265603 (patch)
tree53351133e4a377a3224141e7a504e7c1dd53c980
parent3c716e0bab4f0cfe4be84caa9ce5fd5e3f5e2a23 (diff)
downloadpseudo-bec11654de69611ae6088d3aaa4a8d6f40265603.tar.gz
pseudo-bec11654de69611ae6088d3aaa4a8d6f40265603.tar.bz2
pseudo-bec11654de69611ae6088d3aaa4a8d6f40265603.zip
Shutdown ping
Wait until the server has finished processing all of our messages before exiting. Otherwise, it's possible for a command which sends a no-response message and then exits to be followed by another command which assumes the first one's done, and the second command's messages can get processed first.
-rw-r--r--ChangeLog.txt3
-rw-r--r--pseudo_client.c13
2 files changed, 16 insertions, 0 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 8a817b5..844e177 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -5,6 +5,9 @@
* (seebs) mask out group/other write bits in real filesystem to
reduce risks when assembling a rootfs including world-writeable
directories.
+ * (seebs) send a round-trip message to the server before exiting
+ if any messages have been sent, so the program won't exit before
+ the server processed those messages.
2014-05-15:
* (seebs) drop flags when calling fchmodat() to appease GNU tar.
diff --git a/pseudo_client.c b/pseudo_client.c
index 7330f9d..39f9641 100644
--- a/pseudo_client.c
+++ b/pseudo_client.c
@@ -76,6 +76,9 @@ static int nfds = 0;
static int messages = 0;
static struct timeval message_time = { .tv_sec = 0 };
static int pseudo_inited = 0;
+
+static int sent_messages = 0;
+
int pseudo_nosymlinkexp = 0;
/* note: these are int, not uid_t/gid_t, so I can use 'em with scanf */
@@ -731,6 +734,11 @@ client_ping(void) {
return 0;
}
+static void
+void_client_ping(void) {
+ client_ping();
+}
+
int
pseudo_fd(int fd, int how) {
int newfd;
@@ -1066,6 +1074,11 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path
/* disable wrappers */
pseudo_antimagic();
+ if (!sent_messages) {
+ sent_messages = 1;
+ atexit(void_client_ping);
+ }
+
if (op == OP_RENAME) {
va_list ap;
if (!path) {