summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/cluster/nsr-recon/src/recon_driver.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/xlators/cluster/nsr-recon/src/recon_driver.c b/xlators/cluster/nsr-recon/src/recon_driver.c
index 163084958..7f92b6578 100644
--- a/xlators/cluster/nsr-recon/src/recon_driver.c
+++ b/xlators/cluster/nsr-recon/src/recon_driver.c
@@ -86,6 +86,7 @@ recon_create_log (char *member, char *module)
char *p;
char *fpath = NULL;
FILE *fp = NULL;
+ int fd = -1;
(void)mkdir(NSR_LOG_DIR,0777);
(void)asprintf(&dpath,NSR_LOG_DIR"/%s",member);
@@ -98,9 +99,25 @@ recon_create_log (char *member, char *module)
(void)mkdir(dpath,0777);
(void)asprintf(&fpath,"%s/%s",dpath,module);
if (fpath) {
- fp = fopen(fpath,"a");
- if (setvbuf (fp, NULL, _IONBF, 0)) {
- return NULL;
+ fd = open(fpath,O_WRONLY|O_CREAT|O_APPEND|O_SYNC,0666);
+ if (fd >= 0) {
+ fp = fdopen(fd,"a");
+ if (!fp) {
+ close(fd);
+ }
+ }
+ if (fp) {
+ if (setvbuf (fp, NULL, _IONBF, 0)) {
+ /*
+ * Might as well take advantage of it
+ * to log the error.
+ */
+ fprintf (fp,
+ "setvbuf failed for log\n");
+ fprintf (fp,
+ "log output may be async\n");
+ fflush(fp);
+ }
}
free(fpath);
}