[PATCH V3 0/2] libcmpiutil: patch rebase for libvirt-cim 6.2

Hi, Danial Sorry for have sent confusing patches, please use this serial for libcmpiutil. Wenchao Xia (2): libcmpiutil: fix potential debug print crash libcmpiutil: add time and thread info in debug log debug_util.c | 19 ++++++++++++++++++- std_indication.c | 14 ++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-)

v2: Rebased. v3: No change. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> --- std_indication.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/std_indication.c b/std_indication.c index f9dbea4..21df1f5 100644 --- a/std_indication.c +++ b/std_indication.c @@ -141,7 +141,12 @@ static CMPIStatus raise(struct std_indication_ctx *ctx, enabled = is_ind_enabled(ctx, ind_name, &s); if (s.rc != CMPI_RC_OK) { - CU_DEBUG("Problem checking enabled: '%s'", CMGetCharPtr(s.msg)); + if (s.msg != NULL) { + CU_DEBUG("Problem checking enabled: '%s'", + CMGetCharPtr(s.msg)); + } else { + CU_DEBUG("Problem checking enabled, msg is NULL"); + } goto out; } @@ -176,7 +181,12 @@ CMPIStatus stdi_deliver(const CMPIBroker *broker, enabled = is_ind_enabled(args->_ctx, ind_name, &s); if (s.rc != CMPI_RC_OK) { - CU_DEBUG("Problem checking enabled: '%s'", CMGetCharPtr(s.msg)); + if (s.msg != NULL) { + CU_DEBUG("Problem checking enabled: '%s'", + CMGetCharPtr(s.msg)); + } else { + CU_DEBUG("Problem checking enabled, msg is NULL"); + } goto out; } -- 1.7.1

On server we need these information to debug eaiser. v2: format adjusted. v3: call time and thread function only when debug is enabled, which improves performance when debug is shutdown. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> --- debug_util.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/debug_util.c b/debug_util.c index 2912fb6..8c42e9d 100644 --- a/debug_util.c +++ b/debug_util.c @@ -23,6 +23,9 @@ #include <stdlib.h> #include <stdarg.h> #include <stdio.h> +#include <pthread.h> +#include <sys/time.h> +#include <time.h> #include "libcmpiutil.h" @@ -32,6 +35,12 @@ static FILE *log = NULL; void debug_print(char *fmt, ...) { char *log_file = NULL; + pthread_t id; + struct timeval tv; + struct timezone tz; + time_t timep; + struct tm *p; + va_list ap; va_start(ap, fmt); @@ -49,8 +58,16 @@ void debug_print(char *fmt, ...) log_init = 1; } - if (log != NULL) + if (log != NULL) { + gettimeofday(&tv, &tz); + time(&timep); + p=localtime(&timep); + id = pthread_self(); + fprintf(log, "[%d-%02d-%02d %02d:%02d:%02d.%06d] [%ld]: ", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, p->tm_hour, + p->tm_min, p->tm_sec, (int)tv.tv_usec, id); vfprintf(log, fmt, ap); + } va_end(ap); } -- 1.7.1

On Tue, Dec 18, 2012 at 05:14:04PM +0800, Wenchao Xia wrote:
Hi, Danial Sorry for have sent confusing patches, please use this serial for libcmpiutil.
Wenchao Xia (2): libcmpiutil: fix potential debug print crash libcmpiutil: add time and thread info in debug log
debug_util.c | 19 ++++++++++++++++++- std_indication.c | 14 ++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-)
Sorry for the very long delay, yes looks fine, ACK and pushed ! Daniel -- Daniel Veillard | Open Source and Standards, Red Hat veillard@redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (2)
-
Daniel Veillard
-
Wenchao Xia