|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH for-4.6] xenstored: log tdb message via xenstored's logging mechanisms
On Thu, Jan 08, 2015 at 01:04:26PM +0000, Ian Campbell wrote:
> 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@xxxxxxxxxx>
> > > > ---
> > > > 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.
>
Yeah. I was more annoyed by the different styles in used. :-)
Wei.
> Ian.
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |