Skip to content

Conversation

@TerraTech
Copy link

This patch is to handle a fgets() + EOF/EAGAIN race in fgetline(), as well as adding two new switches to tweak its behavior.

I stumbled on this when I changed my log feeder to do something like the following:

{ printf "<custom crafted first log line>\n"; ssh remote gunzip -c logfile; } | pv | goaccess ....

The delay would sometimes cause the fgets() to go in a read loop and never exit in the face of either an EOF or EAGAIN.

The --getline-min-read specifies the minimum number of lines that must be read before it will quickly exit the read loop on an EOF/EAGAIN. This covers the case where the logs being fed is a combination of 'fast' (printf) and 'slow' feeds where the slow feed incurs a remote ssh connection delay. This covers how EOF/EAGAIN is handled as it should honor it after log lines have been fed for it, but be very conservative and wait for the log stream to start. Non-blocking stream reads can get a bit tricky as the onus is on the coder to cover all the corner cases. (I hope that makes sense).

As a belt-n-suspenders approach, it also has a --getline-timeout which will break out of the loop after specified number of seconds. The default is 10, and has worked well for our use case.

Please give it a lookover and let me know what you think. Thanks!

allinurl and others added 30 commits April 12, 2017 20:12
lintian:
I: goaccess: spelling-error-in-binary usr/bin/goaccess occured occurred
I: goaccess: spelling-error-in-binary usr/bin/goaccess Diable Disable
Those resources are converted to C and embedded into the final binary
during the build. There is no point in also installing them to
$(PREFIX)/share/doc/goaccess/
@allinurl
Copy link
Owner

Thanks. I haven't been able to merged this as I'm trying to keep up with some bugs/requests that I plan to squeeze in the next release. I still want to run some tests on my side before merging this commit.

@allinurl allinurl force-pushed the master branch 2 times, most recently from 0550432 to b1332f5 Compare December 22, 2023 22:26
@allinurl allinurl force-pushed the master branch 5 times, most recently from 3d5333b to 6c68a6e Compare January 11, 2024 01:36
@allinurl allinurl force-pushed the master branch 7 times, most recently from 31e2ac1 to c6199f6 Compare May 14, 2024 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet