Skip to content

server_timer_proc - better handle server test time expiration#1914

Merged
bmah888 merged 3 commits intoesnet:masterfrom
davidBar-On:server_timer_proc-enhancements
Mar 31, 2026
Merged

server_timer_proc - better handle server test time expiration#1914
bmah888 merged 3 commits intoesnet:masterfrom
davidBar-On:server_timer_proc-enhancements

Conversation

@davidBar-On
Copy link
Copy Markdown
Contributor

  • Version of iperf3 (or development branch, such as master or
    3.1-STABLE) to which this pull request applies:
    make

  • Issues fixed (if any): none

  • Brief description of code changes (suitable for use as a commit message):
    Enhancements to server_timer_proc() for better handling of server test time expiration

@bmah888
Copy link
Copy Markdown
Contributor

bmah888 commented Aug 5, 2025

Thanks for the PR! Will review.

@bmah888
Copy link
Copy Markdown
Contributor

bmah888 commented Mar 26, 2026

I tried fixing up a couple merge conflicts so that we can test this a bit with master-branch based code. Let's see how this goes.

@bmah888 bmah888 self-assigned this Mar 26, 2026
Copy link
Copy Markdown
Contributor

@bmah888 bmah888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for the PR and for your patience! I was about to approve and merge this PR but I thought of a (possibly silly) question. The new code you added to server_timer_proc() closes the socket for each test stream and also removes the stream object from the list of streams. That's all great. But I'm trying to figure out how the thread associated with the stream gets cancelled / ended. From what I can tell, this does happen but I can't tell how or where. Can you help me understand this part?

(Yes I should know because I wrote most of the original thread-handling code.)

@davidBar-On
Copy link
Copy Markdown
Contributor Author

I'm trying to figure out how the thread associated with the stream gets cancelled / ended. From what I can tell, this does happen but I can't tell how or where. Can you help me understand this part?

Regarding the question, because the sockets are closed and test->done is set, the worker_run() will terminate either per the test->done or because read/write will fail. That terminates the threads.

Regarding the reason for the PR, I don't remember what was the exact problem, and for some reason I didn't described it, but I believe it was:

  1. server_timer_proc() close the control socket.
  2. select() fail and cleanup_server(test) or client's goto cleanup_and_fail are executed.
  3. The threads are terminated using pthread_cancel().
  4. If a thread is reading/writing when it is canceled than that may cause core dump. The purpose of the PR is to prevent this core dump.

If I remember correctly, I added closing the sockets in server_timer_proc() and did not add threads canceling, since I was not sure if canceling will not cause problems in the code executed after select() fails.

Copy link
Copy Markdown
Contributor

@bmah888 bmah888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good after conflict resolution. Approved, and thanks for answering my questions, will merge this shortly.

@bmah888 bmah888 merged commit 71bbc5e into esnet:master Mar 31, 2026
7 checks passed
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