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

Use uint64 sysctl when retrieving vfs.bufspace on FreeBSD #512

Merged
merged 1 commit into from
Apr 13, 2018
Merged

Use uint64 sysctl when retrieving vfs.bufspace on FreeBSD #512

merged 1 commit into from
Apr 13, 2018

Conversation

danielnelson
Copy link
Contributor

On some system using a the uint32 function returns the error "cannot allocate memory". influxdata/telegraf#3750

It appears that the size of this field can vary, and sometimes requires additional space. From man 3 sysctl:

The information is copied into the buffer specified by oldp. The size of
the buffer is given by the location specified by oldlenp before the call,
and that location gives the amount of data copied after a successful call
and after a call that returns with the error code ENOMEM. If the amount
of data available is greater than the size of the buffer supplied, the
call supplies as much data as fits in the buffer provided and returns
with the error code ENOMEM.
If the old value is not desired, oldp and
oldlenp should be set to NULL.

It is possible that we should use func SysctlRaw instead as it checks the size of the field using the method described here:

The size of the available data can be determined by calling sysctl() with
the NULL argument for oldp. The size of the available data will be
returned in the location pointed to by oldlenp. For some operations, the
amount of space may change often. For these operations, the system
attempts to round up so that the returned size is large enough for a call
to return the data shortly thereafter.

I have not made this larger change.

On some system using a the uint32 function would return the error
"cannot allocate memory".
@shirou
Copy link
Owner

shirou commented Apr 13, 2018

Thanks a lot! I confirmed this works on my FreeBSD environment.

@shirou shirou merged commit a5c2888 into shirou:master Apr 13, 2018
@danielnelson danielnelson deleted the fix-vfs-bufspace-cannot-allocate-memory branch April 20, 2018 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants