diff options
author | Anuradha <atalur@redhat.com> | 2014-02-10 19:23:42 +0530 |
---|---|---|
committer | Anuradha <atalur@redhat.com> | 2014-02-17 21:27:32 +0530 |
commit | 961ba477f544adcaf641207c6157073214c4f27b (patch) | |
tree | 1a6f01f1716a587dc829de9d1b5eec343555782d /xlators/cluster/nsr-recon/src/recon_driver.c | |
parent | 0d92798e88c5444fb2cc23663b4ea9a345887756 (diff) |
nsr : Changes made in nsr logging functions
1) File pointers for worker and driver logs are now
in their respective ctx, instead of static file
pointer in nsr logging functions.
2) File pointer for recon-main-log now in
nsr_recon_private_t, instead of a static file pointer
in nsr recon logging function.
3) Changed a few fprintf to gflog.
Change-Id: Iab92e20d1691104bad19b7fe044a1d3ce2792ab3
Signed-off-by: Anuradha <atalur@redhat.com>
Diffstat (limited to 'xlators/cluster/nsr-recon/src/recon_driver.c')
-rw-r--r-- | xlators/cluster/nsr-recon/src/recon_driver.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/xlators/cluster/nsr-recon/src/recon_driver.c b/xlators/cluster/nsr-recon/src/recon_driver.c index 778f59413..163084958 100644 --- a/xlators/cluster/nsr-recon/src/recon_driver.c +++ b/xlators/cluster/nsr-recon/src/recon_driver.c @@ -98,7 +98,10 @@ recon_create_log (char *member, char *module) (void)mkdir(dpath,0777); (void)asprintf(&fpath,"%s/%s",dpath,module); if (fpath) { - fp = fopen(fpath,"w"); + fp = fopen(fpath,"a"); + if (setvbuf (fp, NULL, _IONBF, 0)) { + return NULL; + } free(fpath); } free(dpath); @@ -108,9 +111,9 @@ recon_create_log (char *member, char *module) } void -_nsr_driver_log (const char *func, int line, char *member, char *fmt, ...) +_nsr_driver_log (const char *func, int line, char *member, FILE *fp, + char *fmt, ...) { - static FILE *fp = NULL; va_list ap; char *buf = NULL; int retval; @@ -133,9 +136,9 @@ _nsr_driver_log (const char *func, int line, char *member, char *fmt, ...) void _nsr_worker_log (const char *func, int line, char *member, - char *type, uint32_t index, char *fmt, ...) + char *type, uint32_t index, FILE *fp, + char *fmt, ...) { - static FILE *fp = NULL; va_list ap; char *buf = NULL; int retval; @@ -145,7 +148,7 @@ _nsr_worker_log (const char *func, int line, char *member, if (asprintf(&name,"%s-%u",type,index) < 1) { return; } - fp = recon_create_log(member,"recon-main-log"); + fp = recon_create_log (member, name); if (!fp) { return; } @@ -2296,6 +2299,7 @@ nsr_reconciliation_driver(void *arg) nsr_recon_driver_ctx_t **driver_ctx, *ctx; int32_t bm; xlator_t *this = priv->this; + char *con_name, *data_name; driver_ctx = &priv->driver_thread_context; (*driver_ctx) = GF_CALLOC (1, @@ -2308,6 +2312,11 @@ nsr_reconciliation_driver(void *arg) ctx = *driver_ctx; ctx->this = priv->this; ctx->replica_group_size = replica_group_size; + + ctx->fp = recon_create_log (priv->replica_group_members[0], "nsr-driver-log"); + if (!ctx->fp) + return NULL; + if ((pthread_mutex_init(&(ctx->mutex), NULL)) || (pthread_cond_init(&(ctx->cv), NULL))){ nsr_driver_log (this->name, GF_LOG_ERROR, "mutex init error \n"); @@ -2343,8 +2352,22 @@ nsr_reconciliation_driver(void *arg) } for (i=0; i < replica_group_size; i++) { ctx->workers[i].control_worker = &control_s[i]; + if (asprintf(&con_name,"recon-con-%u",i) < 1) { + return NULL; + } + ctx->workers[i].control_worker->fp = recon_create_log + (priv->replica_group_members[0], con_name); + if (!ctx->workers[i].control_worker->fp) + return NULL; ctx->workers[i].data_worker = &data_s[i]; - } + if (asprintf (&data_name,"recon-data-%u",i) <1) { + return NULL; + } + ctx->workers[i].data_worker->fp = recon_create_log + (priv->replica_group_members[0], data_name); + if (!ctx->workers[i].data_worker->fp) + return NULL; + } nsr_driver_log (this->name, GF_LOG_INFO, "creating threads \n"); // Create the worker threads |