[libbluray-devel] Fix for logging failure on Win32 platform
tourettes
tourettesmp at gmail.com
Sun Mar 24 16:40:01 CET 2013
On 20.3.2013 16:57, tourettes wrote:
> logging.c is using zero as the buffer size for the log stream. It is
> not a valid parameter on Win32 platform:
>
> http://msdn.microsoft.com/en-us/library/86cebhfs(v=vs.80).aspx
>
> "Buffer size in bytes. Allowable range: 2 <= size <= INT_MAX
> (2147483647). Internally, the value supplied for size is rounded down
> to the nearest multiple of 2."
>
> An error will be thrown from the C runtime:
>
> if ((type == _IOFBF) || (type == _IOLBF))
> {
> _VALIDATE_RETURN( ((2 <= size) && (size <= INT_MAX)),
> EINVAL, -1 );
> }
Actually it is not a good idea to use 4096 as the stream buffer size
since it will cause
flushing of log file to happen too rarely to be usable.
As attached a new version of the patch that changes the log stream
buffer size to 2.
-------------- next part --------------
>From 8430d37d60db84e08140a5534d4769286f56b702 Mon Sep 17 00:00:00 2001
From: tourettes <tourettesmp at gmail.com>
Date: Sun, 24 Mar 2013 17:37:56 +0200
Subject: [PATCH] Configure stream buffer size for the log stream
Provide a buffer size parameter for setvbuf(). Currently zero is used and that is not a valid buffer size on Win32 platform.
---
src/util/logging.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/logging.c b/src/util/logging.c
index c8aa488..0085765 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -72,7 +72,7 @@ void bd_debug(const char *file, int line, uint32_t mask, const char *format, ...
FILE *fp = fopen(env, "wb");
if (fp) {
logfile = fp;
- setvbuf(logfile, NULL, _IOLBF, 0);
+ setvbuf(logfile, NULL, _IOLBF, 2);
} else {
fprintf(logfile, "%s:%d: Error opening log file %s\n", __FILE__, __LINE__, env);
}
--
1.8.1.msysgit.1
More information about the libbluray-devel
mailing list