esnet / esnet/iperf

libiperf thread safety

Open
#1,587 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
8.8k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

It appears that libiperf may not be thread safe.

If I create a simple test program that starts both a server and client in the same process, but on different threads, there are some inconsistencies observed related to the once-per-second periodic log output time intervals. For example, some of the intervals have the same start and end time, resulting in bogus rate calculations. The final printout at the end of the test is always correct though.

After a little investigation, I think it could be related to the use of static globals in timer.c:
https://github.com/esnet/iperf/blob/a9a55e409d07537c6951f15d30885755d3d3cf29/src/timer.c#L36

A potential solution could be moving these into `struct iperf_test` so that each test has its own complete context, but perhaps there is something I am overlooking.

Other than that, everything seems to work fine. There is also the issue of "i_errno" being shared, but that's to be expected.

Contributor guide

Open the contributing guide

Research direction

Start with the static globals in src/timer.c referenced by the report, then reproduce the issue with a test program running a server and client in different threads in one process. Check the once-per-second periodic log intervals and rate calculations, while confirming the final printout remains correct. Done means concurrent operation no longer produces identical interval times or bogus rates.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.