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

Make trickle multithread version signal safe #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lano1106
Copy link
Contributor

Because, select(),poll(), read(), write() and many other overloaded functions are
normally reentrant from signal handlers, we need to block all signals while we hold
mutex or else we can deadlock.

Modified Makefile.am because while make did not build libtrickle.so,
'make install' was trying to install it. I'm really shooting in the dark for
autoconf problem so maybe it is not the best way to resolve the problem.

Because, select(),poll(), read(), write() and many other overloaded functions are
normally reentrant from signal handlers, we need to block all signals while we hold
mutex or else we can deadlock.

Modified Makefile.am because while make did not build libtrickle.so,
'make install' was trying to install it. I'm really shooting in the dark for
autoconf problem so maybe it is not the best way to resolve the problem.
@lano1106
Copy link
Contributor Author

There is still some rework to do.

oset should be private to every thread. thread B could overwrite oset while thread A has the mutex.

With the help of a set of macros, oset is now an automatic variable
on the stack of each thread instead of an unprotected global var.

The modif compiles but is not tested yet. I will launch an endurance
test and report back every few days how things go.
Need to be explicit on where to find the symbol. When called, the libpthread may or may not be loaded.
I have seen segfaut inside the call to safe_vprintf() from errx() when dlsym fail.
@lano1106
Copy link
Contributor Author

I have been using this patch for over a month with the bitcoin client and trickle has never been that stable.

I am 100% confident that this patch is ok.

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.

1 participant