Change in libosmocore[master]: log stderr: Increase output buffering using setvbuf()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Thu Jul 30 19:35:16 UTC 2020


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/19463 )


Change subject: log stderr: Increase output buffering using setvbuf()
......................................................................

log stderr: Increase output buffering using setvbuf()

Change-Id: I59beadb8d1d10a942513efc4c0477701f967237a
---
M src/logging.c
1 file changed, 15 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/63/19463/1

diff --git a/src/logging.c b/src/logging.c
index c14e696..683db97 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -903,6 +903,7 @@
 struct log_target *log_target_create_file(const char *fname)
 {
 	struct log_target *target;
+	int rc;
 
 	target = log_target_create();
 	if (!target)
@@ -913,6 +914,12 @@
 	if (!target->tgt_file.out)
 		return NULL;
 
+	rc = setvbuf(target->tgt_file.out, NULL, _IOFBF, 128*1024);
+	if (rc != 0) {
+		LOGP(DLGLOBAL, LOGL_NOTICE, "Could not increase output buffer size for '%s': %s\n",
+		     fname, strerror(errno));
+	}
+
 	target->output = _file_output;
 
 	target->tgt_file.fname = talloc_strdup(target, fname);
@@ -980,12 +987,20 @@
  *  \returns 0 in case of success; negative otherwise */
 int log_target_file_reopen(struct log_target *target)
 {
+	int rc;
+
 	fclose(target->tgt_file.out);
 
 	target->tgt_file.out = fopen(target->tgt_file.fname, "a");
 	if (!target->tgt_file.out)
 		return -errno;
 
+	rc = setvbuf(target->tgt_file.out, NULL, _IOFBF, 128*1024);
+	if (rc != 0) {
+		LOGP(DLGLOBAL, LOGL_NOTICE, "Could not increase output buffer size for '%s': %s\n",
+		     target->tgt_file.fname, strerror(errno));
+	}
+
 	/* we assume target->output already to be set */
 
 	return 0;

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19463
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I59beadb8d1d10a942513efc4c0477701f967237a
Gerrit-Change-Number: 19463
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200730/adff6a1e/attachment.htm>


More information about the gerrit-log mailing list