[libbluray-devel] Fix for logging failure on Win32 platform

Petri Hintukainen phintuka at users.sourceforge.net
Wed Mar 27 09:52:54 CET 2013


On su, 2013-03-24 at 17:40 +0200, tourettes wrote:
> 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 );
> >         }

That code in logging.c tries to enable line buffering, but it is not
supported in VS runtime library:

http://msdn.microsoft.com/en-us/library/86cebhfs(v=vs.80).aspx :
"_IOLBF   For some systems, this provides line buffering. However, for
Win32, the behavior is the same as _IOFBF - Full Buffering."

> 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.

I don't think line buffering or any other buffering is needed here,
logging code already uses line buffer internally and writes only
complete lines. Buffering could be turned off with

setvbuf(logfile, NULL, _IONBF, 0);


- Petri



More information about the libbluray-devel mailing list