-
Notifications
You must be signed in to change notification settings - Fork 316
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
fix core cause of openfortivpn is locked when spawning ppp
is failed.
#135
Conversation
6797fba
to
fd6c3a4
Compare
Hi @Mabin-J, Thanks for your help on making openfortivpn MacOS-compatible, it is appreciated! However I don't understand the goal of your latest pull-requests. Could you open a GitHub issue to clearly state:
This way @mrbaseman, @DimitriPapadopoulos and I can follow your contributions efficiently and merge them while avoiding regressions and bugs. Also, please make sure your commits are clear (e.g. not Thanks! |
Hi @adrienverge. I'll do it. |
fd6c3a4
to
3eb6d7f
Compare
ppp
is failed.
ppp
is failed.ppp
is failed.
Hello @Mabin-J, I would like to understand what exactly this patch does, and I believe I did, but please correct me if I got something wrong. If I understand your code correctly, you do 2 things:
Apart from reassuring myself that I understood the change correctly, I would suggest to rename Thanks for your efforts in improving the MacOS X code in openfortivpn. |
7facc47
to
41aff60
Compare
I checked your comment and #105. But I didn't test in Linux. |
Before #132, I think that Zombie process caused locked thread(if_config_thread). |
It works also in Linux correctly. :) |
ok, this is a different approach now.
|
|
45f5545
to
fb5c520
Compare
@mrbaseman, I finished. |
Dear @Mabin-J in #105 we have come to the conclusion that this PR is a good step forward, not only to fix the locking issue here, but also as a solution for #105. I would kindly ask you to update the commit message once more, so that it also includes this conclusion. I'd suggest the following:
|
fb5c520
to
f49779a
Compare
… failed. This commit reverts the temporary fix from adrienverge#132 (commit 158f489) and instead replaces `GCD semaphores` with `Mach Semaphores`, following the lines of http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/file/8b16790cd73a/src/os/bsd/vm/os_bsd.cpp. By doing so, this commit is also a solution for issue adrienverge#105(GCD semaphores might be unsafe when used in signal handlers): On macOS `named POSIX semaphores`, which are known to be async-signal-safe, are implemented upon `Mach Semaphores`. An analysis of the use of semaphores in openfortivpn has lead to the conclusion that `Mach Semaphores` are just as good as `unnamed POSIX semaphores` which unfortunately are not implemented in macOS. ※ About `Mach Semaphores` - https://books.google.de/books?id=K8vUkpOXhN4C&pg=PA1219&lpg=PA1210&focus=viewport&dq=semaphore_create - https://developer.apple.com/library/content/documentation/Darwin/Conceptual/KernelProgramming/synchronization/synchronization.html
f49779a
to
6370b2a
Compare
This lets macOS use real semaphores instead of the self-pipe. Seems to be the case these are indeed async-signal-safe, unlike GCD/libdispatch semaphores. eclipse/omr#3356 adrienverge/openfortivpn#135
This commit is related with #132 and 158f489 .
It seems that
pthread_cancel
cannot effect todispatch_semaphore_wait
.(
dispatch_semaphore_wait
is used forsem_wait
for macOS, io.c#L41)It seems that
dispatch_semaphore_wait
not use real semaphore.If
pthread_cancel cannot
effect todispatch_semaphore_wait
,if_config
should be returned atsem_wait(&sem_if_config);
(io.c#L509) but it isn't...openfortivpn
is locked that line.#132 is not best solution because when run
sem_post(&sem_if_config);
(io.c#L299), io.c#L510-L534 will be ran.In Linux, when run
pthread_cancel(if_config_thread);
(io.c#L609),sem_wait(&sem_if_config);
(io.c#L509) will be broken andif_config
function will be returned immediately.So I add code for breaking after
sem_wait
whensem_post(&sem_stop_io);
is called.I think that remain this logic before find alternative
dispatch_semaphore
.