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

POSIX has made usleep(2) obsolete in favour of nanosleep(2) #1990

Merged
merged 1 commit into from Jan 3, 2021

Conversation

@rsmarples
Copy link
Contributor

@rsmarples rsmarples commented Jan 2, 2021

usleep(2) also has no effect if equal to greater than 1000000
which happens to match HTML_REFERS, but no error was checked.
This caused 100% CPU utiliation constantly following the tail
of the web server access log with default value.

nanosleep(2) has more relaxed limits.
This commit does a like for like replacement and also adds
error checking in case of a similar error in the future.

Signed-off-by: Roy Marples roy@marples.name

usleep(2) also has no effect if equal to greater than 1000000
which happens to match HTML_REFERS, but no error was checked.
This caused 100% CPU utiliation constantly following the tail
of the web server access log with default value.

nanosleep(2) has more relaxed limits.
This commit does a like for like replacement and also adds
error checking in case of a similar error in the future.

Signed-off-by: Roy Marples <roy@marples.name>
@allinurl allinurl merged commit c442db4 into allinurl:master Jan 3, 2021
2 checks passed
2 checks passed
test
Details
push
Details
@allinurl
Copy link
Owner

@allinurl allinurl commented Jan 3, 2021

Merged. Thanks very much for the heads up on this!

@allinurl
Copy link
Owner

@allinurl allinurl commented Jan 3, 2021

Question, were you running goaccess from systemd?

@rsmarples
Copy link
Contributor Author

@rsmarples rsmarples commented Jan 3, 2021

Well, as my prior pull request fixed the build for NetBSD that can safely be a no as systemd is Linux only.

However, I did see the issue you were referring to and all I can say is fix this is highly dependant on libc.
Internally all modern libc will use nanosleep when usleep is called.
However, for NetBSD at least there is an extra check to ensure that EINVAL is returned for >= 1000000 as POSIX dictates whereas glibc and musl at least do not - hence non BSD users don't have much of an issue with this.

@rsmarples rsmarples deleted the rsmarples:nanosleep branch Jan 3, 2021
@allinurl
Copy link
Owner

@allinurl allinurl commented Jan 4, 2021

Got it. Thanks for the info!

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

Successfully merging this pull request may close these issues.

None yet

2 participants