Skip to content
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

TODO: fix the fflush() #8

Open
cederom opened this issue Jun 14, 2017 · 0 comments
Open

TODO: fix the fflush() #8

cederom opened this issue Jun 14, 2017 · 0 comments

Comments

@cederom
Copy link
Owner

cederom commented Jun 14, 2017

As reported by @MemphisCZ in #6:

One more suggestion about fflush(0);, in some multitask FREERTOS application this may cause task dead lock, flushing NULL pointer means flush everything. In such OS some kind of opened file descriptors could be just input streams waiting for input data and already locked with their recursive lock. Flush from different task will be waiting for ever until first task will receive something and releases the lock. Would be better to use fflush(stdout); in libswd_memap.c line 270,314,470,505,683,724,875,909. :-]

flushing each time for log output will drastically slow down the logging. Stdout for frequent flush slow as hell, as it will call OS kernel rutins. Would be better to delete it from library as user of that library can set up his stdout with something like:
setvbuf(stdout, NULL, _IONBF, 0);
this will ensure that all log messages will be outputted immediately if he needs this. Or he can use fflush himself in app region.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant