From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [Patch 4/4] chunkd: rationalize startup commentary
Date: Mon, 10 Aug 2009 19:02:39 -0600 [thread overview]
Message-ID: <20090810190239.61bfdf5b@redhat.com> (raw)
The existing comments weren't completely incorrect, but they were
out of date. For example, a lot of code was added between the
write_pid_file and comment about it.
Signed-Off-By: Pete Zaitcev <zaitcev@redhat.com>
diff --git a/server/server.c b/server/server.c
index 2899f6f..3e7016e 100644
--- a/server/server.c
+++ b/server/server.c
@@ -1172,9 +1172,11 @@ int main (int argc, char *argv[])
setlocale(LC_ALL, "C");
/*
- * parse command line
+ * Unfortunately, our initialization order is rather rigid.
+ *
+ * First, parse command line. This way errors in parameters can
+ * be written to stderr, where they belong.
*/
-
aprc = argp_parse(&argp, argc, argv, 0, NULL, NULL);
if (aprc) {
fprintf(stderr, "argp_parse failed: %s\n", strerror(aprc));
@@ -1182,12 +1184,12 @@ int main (int argc, char *argv[])
}
/*
- * open syslog, background outselves, write PID file ASAP
+ * Next, open syslog. From now on, nothing goes to stderr, and
+ * we minimize (or hopefuly eliminate) opening libraries that
+ * do not have a switcheable diagnostic output.
*/
-
if (use_syslog)
openlog(PROGRAM_NAME, LOG_PID, LOG_LOCAL3);
-
if (debugging)
applog(LOG_INFO, "Verbose debug output enabled");
@@ -1207,11 +1209,17 @@ int main (int argc, char *argv[])
SSL_MODE_ENABLE_PARTIAL_WRITE);
/*
- * read master configuration
+ * Next, read master configuration. This should be done as
+ * early as possible, so that tunables are available.
*/
read_config();
chunkd_srv.ourhost = get_hostname();
+ /*
+ * For example, backgrounding and PID file should be done early
+ * (before we do anything that can conflict with other instance),
+ * but not before read_config().
+ */
if (!(chunkd_srv.flags & SFL_FOREGROUND) && (daemon(1, !use_syslog) < 0)) {
syslogerr("daemon");
goto err_out;
@@ -1225,7 +1233,6 @@ int main (int argc, char *argv[])
/*
* properly capture TERM and other signals
*/
-
signal(SIGHUP, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
signal(SIGINT, term_signal);
reply other threads:[~2009-08-11 1:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090810190239.61bfdf5b@redhat.com \
--to=zaitcev@redhat.com \
--cc=hail-devel@vger.kernel.org \
--cc=jeff@garzik.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.