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

Signal handler doesn't get called when signal is raised in a worker thread #1

Closed
VioletGiraffe opened this issue Feb 3, 2014 · 5 comments

Comments

@VioletGiraffe
Copy link

coffeecatch works great as long as the signal is raised on the main thread. But if it's a worker thread, it doesn't work. Is there a workaround?

@xroche
Copy link
Owner

xroche commented Feb 3, 2014

Humm, weird, this should always work. What do you mean by "if it's a worker thread, it doesn't work" ? Are you calling the exact same native method from within Java code, protected by coffeecatch handlers ? (Typically in HTTrack on Android, the coffeecatch code is always used in a worker thread)

@VioletGiraffe
Copy link
Author

Now that you've asked, I'm not sure if that's not just me being silly. I'll doublecheck that the method in question is actually called from within coffeecatch-protected section. I'll update you as soon as I figure it out.

Thanks for a quick response and a great tool!

@VioletGiraffe
Copy link
Author

You're right, that was my mistake, I didn't wrap all the native methods with COFFEE_TRY.
By the way, would it be possible to get some kind of stack trace in the CATCH block? coffeecatch_get_message only gives the faulty method name, but not callstack.

@xroche
Copy link
Owner

xroche commented Feb 4, 2014

Simply use coffeecatch_throw_exception(), or better, the COFFEE_TRY_JNI() macro:

void my_native_function(JNIEnv* env, jobject object, jint *retcode) {
  COFFEE_TRY_JNI(env, *retcode = call_dangerous_function(env, object));
}

@VioletGiraffe
Copy link
Author

That would be cool to use, but I need my own handler because I need to write to my own log.

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

No branches or pull requests

2 participants