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

Avoid subthread signal handling #1752

Merged
merged 4 commits into from
Sep 13, 2024
Merged

Avoid subthread signal handling #1752

merged 4 commits into from
Sep 13, 2024

Conversation

xTire
Copy link
Contributor

@xTire xTire commented Aug 26, 2024

PLEASE NOTE the following text from the iperf3 license. Submitting a
pull request to the iperf3 repository constitutes "[making]
Enhancements available...publicly":

You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
("Enhancements") to anyone; however, if you choose to make your Enhancements
available either publicly, or directly to Lawrence Berkeley National
Laboratory, without imposing a separate written license agreement for such
Enhancements, then you hereby grant the following license: a non-exclusive,
royalty-free perpetual license to install, use, modify, prepare derivative
works, incorporate into other computer software, distribute, and sublicense
such enhancements or derivative works thereof, in binary and source code form.

The complete iperf3 license is available in the LICENSE file in the
top directory of the iperf3 source tree.

@xTire
Copy link
Contributor Author

xTire commented Aug 28, 2024

as mentioned in #1750 (comment), d312ddc in this PR cause client cannot exit in response to SIGTERM signal.

Since multiple threads responding simultaneously to a signal leading
to race condition, this is used to ensure that only the main thread
handles the signal.
@bmah888 bmah888 self-assigned this Aug 30, 2024
@bmah888 bmah888 added the bug label Aug 30, 2024
@bmah888
Copy link
Contributor

bmah888 commented Aug 30, 2024

Thanks for the pull request! I'm looking this over. Also figuring out how to test this in my environment (the directions in #1750 were clear, I'm just not sure how to best do this with the resources I have available). Probably we'll want to squash and merge these two commits when we merge them to master.

@xTire
Copy link
Contributor Author

xTire commented Aug 31, 2024

as mentioned in #1750 (comment), d312ddc in this PR cause client cannot exit in response to SIGTERM signal.

33a4b96 should fix it

@davidBar-On
Copy link
Contributor

davidBar-On commented Aug 31, 2024

33a4b96 should fix it

I tested this version, and it seems to work o.k.😄 For both the server and the client (using -P4) I tried to kill the main thread or a "worker" thread and in all cases termination was as expected. I guess that anyway it will also be good to also add a mutex() to protect the exit() in iperf_errexit().

@Itis-hard2name
Copy link

The logic for setting SIG_BLOCK in the two code segments is identical. How can we consolidate this into a single function so that both the client and server sides can call this function, making the code look more elegant?
Would you like a suggestion on how to refactor the code to achieve this?

@bmah888
Copy link
Contributor

bmah888 commented Sep 12, 2024

I apologize for the nitpicking to come: It would not have occurred to me to put in the conditional compilations in 33a4b96, because those signal definitions were at least as old as the POSIX.1-1990 standard. (Anecdotally I remember using them on BSD4 systems in the late 1980s.) I almost feel like they're not really needed, and removing them will make the source code a little easier to read and follow. Like if you try to build this on a system that for some reason doesn't have these signal definitions (such as SIGTERM, etc.) it's probably not very UNIX-like. Am I missing something here?

I'm trying to test the code, but I don't really have a suitable environment set up to reproduce the original problem. It seems to work OK in what limited testing I can do though, so that's good.

@xTire
Copy link
Contributor Author

xTire commented Sep 12, 2024

The conditional compilation was added just because the original signal capture function registration was defined like this. This is done simply to not break existing facilities and maintain consistency.

For current Linux systems, I think da21dc2 is enough.

@bmah888
Copy link
Contributor

bmah888 commented Sep 12, 2024

The conditional compilation was added just because the original signal capture function registration was defined like this. This is done simply to not break existing facilities and maintain consistency.

For current Linux systems, I think da21dc2 is enough.

Ah actually after a little research I see the other conditional compilation was originally added as cherry-pick of a part of PR #935. Let's keep 33a4b96 as a part of the PR. Thanks!

src/iperf_api.h Outdated Show resolved Hide resolved
@bmah888
Copy link
Contributor

bmah888 commented Sep 13, 2024

If you can fix the nitpick I just posted about IEPTHREADSIGNALMASK, I'm leaning towards doing a squash-and-merge on all these changes. Thanks!

@bmah888 bmah888 merged commit d5713db into esnet:master Sep 13, 2024
3 checks passed
@bmah888
Copy link
Contributor

bmah888 commented Sep 13, 2024

Thanks! Squash and merged.

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

Successfully merging this pull request may close these issues.

Segmentation fault under running kernel's netfilter concurrency testing
4 participants