From: Ian Campbell <Ian.Campbell@citrix.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: Philipp Hahn <hahn@univention.de>,
ian.jackson@eu.citrix.com, xen-devel@lists.xen.org
Subject: Re: [PATCH for-4.6] xenstored: log tdb message via xenstored's logging mechanisms
Date: Thu, 8 Jan 2015 13:04:26 +0000 [thread overview]
Message-ID: <1420722266.19787.70.camel@citrix.com> (raw)
In-Reply-To: <20150108125732.GS28680@zion.uk.xensource.com>
On Thu, 2015-01-08 at 12:57 +0000, Wei Liu wrote:
> On Thu, Jan 08, 2015 at 12:33:29PM +0000, Ian Campbell wrote:
> > ping.
> >
> > On Mon, 2014-12-15 at 13:18 +0000, Ian Campbell wrote:
> > > TDB provides us with a callback for this purpose. Use it in both
> > > xenstored and xs_tdb_dump.
> > >
> > > While at it make the existing log() macro tollerate memory failures.
> > >
> > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> > > ---
> > > tools/xenstore/xenstored_core.c | 39 +++++++++++++++++++++++++++++++++------
> > > tools/xenstore/xs_tdb_dump.c | 12 +++++++++++-
> > > 2 files changed, 44 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
> > > index 4eaff57..3fd9a20 100644
> > > --- a/tools/xenstore/xenstored_core.c
> > > +++ b/tools/xenstore/xenstored_core.c
> > > @@ -89,9 +89,14 @@ static void check_store(void);
> > > #define log(...) \
> > > do { \
> > > char *s = talloc_asprintf(NULL, __VA_ARGS__); \
> > > - trace("%s\n", s); \
> > > - syslog(LOG_ERR, "%s", s); \
> > > - talloc_free(s); \
> > > + if (s) { \
> > > + trace("%s\n", s); \
> > > + syslog(LOG_ERR, "%s", s); \
> > > + talloc_free(s); \
> > > + } else { \
> > > + trace("talloc failure during logging\n"); \
> > > + syslog(LOG_ERR, "talloc failure during logging\n"); \
> > > + } \
>
> talloc_free can tolerate NULL pointer.
Good point, I'll fix. I think I'll also change the message to more
clearly indicate an allocation failure, since that is what has actually
happened.
> > > } while (0)
> > >
> [...]
> > > + tdb_ctx = tdb_open_ex(tdbname, 0, tdb_flags, O_RDWR, 0,
> > > + &tdb_logger, NULL);
> [...]
> > > + tdb_ctx = tdb_open_ex(tdbname, 7919, tdb_flags, O_RDWR|O_CREAT,
> > > + 0640, &tdb_logger, NULL);
> [...]
> > > + tdb = tdb_open_ex(talloc_strdup(NULL, argv[1]), 0, 0, O_RDONLY, 0,
> > > + tdb_logger, NULL);
>
> Should be &tdb_logger?
tdb_logger is a function, so it's not strictly required, but it is good
form (and a hint to the reader) plus inconsistent with the others, so
I'll change.
Ian.
next prev parent reply other threads:[~2015-01-08 13:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-15 13:18 [PATCH for-4.6] xenstored: log tdb message via xenstored's logging mechanisms Ian Campbell
2015-01-08 12:33 ` Ian Campbell
2015-01-08 12:57 ` Wei Liu
2015-01-08 13:04 ` Ian Campbell [this message]
2015-01-08 13:06 ` Wei Liu
2015-01-08 13:10 ` Ian Campbell
2015-01-08 13:22 ` Wei Liu
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=1420722266.19787.70.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=hahn@univention.de \
--cc=ian.jackson@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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.