Closed shaohk closed 2 months ago
We essentially just parse net/tcp, can you provide the relevant /proc/net/tcp content in this situation?
@shaohk Are you implying that you suspect the contents of /proc/netstat
are changing mid-flight when procfs reads that file? I would be skeptical of that, since it is read with io.ReadAll
(limited to 1 MiB) via the internal/util.ReadFileNoStat function.
I couldn't reproduce this with the aforementioned snippet running for a thousand times. @shaohk Are you still able to reproduce this with the latest release?
https://github.com/prometheus/procfs/blob/ff0ad85f7e8bcd5c677d99143f14a2a3aab533aa/net_tcp.go#L28
I read tcp connections by procfs like this
When I execute multiple times, I find that the same TCP connection appears twice. eg:
But, When I execute multiple netstat command, there won't be the phenomenon mentioned above. eg:
And I find netstat source code, find the code that
netstat sets the setvbuf to _IOFBF mode when opening the net/tcp file. But golang procfs doesn't set this.
How can we ensure consistency when reading net/tcp in Golang?