From: Michael Tokarev <mjt@tls.msk.ru>
To: Gonglei <arei.gonglei@huawei.com>
Cc: "qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/4] pidfile: stop making pidfile error a special case
Date: Fri, 31 Oct 2014 10:16:18 +0300 [thread overview]
Message-ID: <54533742.1000109@msgid.tls.msk.ru> (raw)
In-Reply-To: <5453178B.2040504@huawei.com>
31.10.2014 08:00, Gonglei wrote:
> On 2014/10/30 23:07, Michael Tokarev wrote:
>
>> In case of -daemonize, we write non-zero to the daemon
>> pipe only if pidfile creation failed, so the parent will
>> report error about pidfile problem. There's no need to
>> make special case for this, since all other errors are
>> reported by the child just fine. Let the parent report
>> error and simplify logic in os_daemonize().
>>
>> This way, we don't need os_pidfile_error() function, since
>> it only prints error now, so put the error reporting printf
>> into the only place where qemu_create_pidfile() is called,
>> in vl.c.
>>
>> While at it, fix wrong identation in os_daemonize().
>
> s/identation/identification/
No, the original word was the right one.
>> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
>> ---
>> include/qemu-common.h | 1 -
>> os-posix.c | 29 ++++++-----------------------
>> os-win32.c | 5 -----
>> vl.c | 2 +-
>> 4 files changed, 7 insertions(+), 30 deletions(-)
>>
>> diff --git a/include/qemu-common.h b/include/qemu-common.h
>> index b87e9c2..f862214 100644
>> --- a/include/qemu-common.h
>> +++ b/include/qemu-common.h
>> @@ -357,7 +357,6 @@ char *qemu_find_file(int type, const char *name);
>> void os_setup_early_signal_handling(void);
>> char *os_find_datadir(void);
>> void os_parse_cmd_args(int index, const char *optarg);
>> -void os_pidfile_error(void);
>>
>> /* Convert a byte between binary and BCD. */
>> static inline uint8_t to_bcd(uint8_t val)
>> diff --git a/os-posix.c b/os-posix.c
>> index eada8d4..a3b96d9 100644
>> --- a/os-posix.c
>> +++ b/os-posix.c
>> @@ -221,18 +221,12 @@ void os_daemonize(void)
>> do {
>> len = read(fds[0], &status, 1);
>> } while (len < 0 && errno == EINTR);
>> - if (len != 1) {
>> - exit(1);
>> - }
>
> Does this check need to be removed?
Yes, because...
>
>> - else if (status == 1) {
>> - fprintf(stderr, "Could not acquire pidfile\n");
>> - exit(1);
>> - } else {
>> - exit(0);
>> - }
>> - } else if (pid < 0) {
>> - exit(1);
>> - }
>> +
>> + exit(len == 1 && status == 0 ? 0 : 1);
...it is checked here, note the 'len == 1' part of the condition.
And here comes the wrong original identation -- this part of "else"
was indented once too many:
>> +
>> + } else if (pid < 0) {
>> + exit(1);
>> + }
>>
Thanks,
/mjt
next prev parent reply other threads:[~2014-10-31 15:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-30 15:07 [Qemu-devel] [PATCH 0/4] cleanup -daemonize and pidfile creation a bit Michael Tokarev
2014-10-30 15:07 ` [Qemu-devel] [PATCH 1/4] os-posix: use global daemon_pipe instead of cryptic fds[1] Michael Tokarev
2014-10-31 4:57 ` Gonglei
2014-10-30 15:07 ` [Qemu-devel] [PATCH 2/4] os-posix: replace goto again with a proper loop Michael Tokarev
2014-10-31 4:58 ` Gonglei
2014-10-30 15:07 ` [Qemu-devel] [PATCH 3/4] pidfile: stop making pidfile error a special case Michael Tokarev
2014-10-31 5:00 ` Gonglei
2014-10-31 7:16 ` Michael Tokarev [this message]
2014-10-31 7:33 ` Gonglei
2014-10-31 7:41 ` Michael Tokarev
2014-10-31 7:58 ` Gonglei
2014-10-31 8:02 ` Michael Tokarev
2014-10-31 8:10 ` Gonglei
2014-10-30 15:07 ` [Qemu-devel] [PATCH 4/4] os-posix: reorder parent notification for -daemonize Michael Tokarev
2014-10-31 5:02 ` Gonglei
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=54533742.1000109@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).