[Pkg-voip-commits] [bctoolbox] 45/60: use better way to init file hlog handler size

Bernhard Schmidt berni at moszumanska.debian.org
Sun Oct 15 22:42:28 UTC 2017


This is an automated email from the git hooks/post-receive script.

berni pushed a commit to branch debian/sid
in repository bctoolbox.

commit 98f88619e1ca634f63f84301f7d64115e021cc3d
Author: Benjamin Reis <benjamin.reis at belledonne-communications.com>
Date:   Thu Jun 22 15:26:59 2017 +0200

    use better way to init file hlog handler size
---
 src/logging/logging.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/logging/logging.c b/src/logging/logging.c
index baf90d9..ea56c80 100644
--- a/src/logging/logging.c
+++ b/src/logging/logging.c
@@ -116,12 +116,21 @@ bctbx_log_handler_t* bctbx_create_log_handler(BctbxLogHandlerFunc func, BctbxLog
 bctbx_log_handler_t* bctbx_create_file_log_handler(uint64_t max_size, const char* path, const char* name, FILE* f) {
 	bctbx_log_handler_t* handler = (bctbx_log_handler_t*)bctbx_malloc0(sizeof(bctbx_log_handler_t));
 	bctbx_file_log_handler_t* filehandler = (bctbx_file_log_handler_t*)bctbx_malloc(sizeof(bctbx_file_log_handler_t));
+	char *full_name = bctbx_strdup_printf("%s/%s.log",
+									path,
+									name);
+	struct stat buf;
+	memset(&buf, 0, sizeof(buf));
 	handler->func=bctbx_logv_file;
 	handler->destroy=bctbx_logv_file_destroy;
 	filehandler->max_size = max_size;
 	// init with actual file size
-	fseek(f, 0L, SEEK_END);
-	filehandler->size = ftell(f);
+	if(stat(full_name, &buf) != 0) {
+		fprintf(stderr,"Error while creating file log handler. \n");
+		return NULL;
+	}
+	bctbx_free(full_name);
+	filehandler->size = buf.st_size;
 	filehandler->path = bctbx_strdup(path);
 	filehandler->name = bctbx_strdup(name);
 	filehandler->file = f;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/bctoolbox.git



More information about the Pkg-voip-commits mailing list