-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only write debug messages if descriptor is set #2
Conversation
fflush() flushes all open descriptors in case NULL is passed as argument. This patch prevents calls to fflush in case debug file descriptor is not initialized. See also: https://trac.transmissionbt.com/ticket/4531.
I think that I might see where an inconsistency with fflush() with NULL as argument might be originating from. Referencing http://www.opensource.apple.com and possibly older MAC systems the patch for "Fix a potential deadlock in _fwalk in a threaded environment." does not seem applied. So possibly when transmission-daemon compiled on MAC for the few transmissions users who report this bug is compiled with such faulty compiler. http://www.opensource.apple.com/source/Libc/Libc-167/stdio.subproj/fwalk.c http://www.opensource.apple.com/source/Libc/Libc-167/stdio.subproj/refill.c The patch of _fwalk per: committer Peter Avalos pavalos@dragonflybsd.org
|
I don't see why call debugf() in the first place if we know there's nothing to print. Why not something like this: |
For one thing, because I don't like having 47 identical checks scattered over the code when I could have just one (or close to one)... Wrapping the check with macro would've been a better idea if you want to get rid of unnecessary calls that much :) As to the idea itself, you may have a point here performance-wise. |
Applied as 6902710.
Yes, that's what I do in usually (see for example https://github.com/jech/babeld/blob/master/util.h#L123) but since I'm trying to keep this code small (so people can easily include it in their projects), I didn't bother. --jch |
fflush() flushes all open descriptors in case NULL is passed as argument. This patch prevents calls to fflush in case debug file descriptor is not initialized.
See also: https://trac.transmissionbt.com/ticket/4531.