Skip to content

Commit

Permalink
add TorService.torFreeAll() method to clean up between restarts
Browse files Browse the repository at this point in the history
This is here as an experiment in case it is useful in Java space.  It is
looking like there are better ways to handle the shutdown, so my guess is
that this will not be useful.

* guardianproject/tor-android#59
* guardianproject/tor-android#61 (comment)
* guardianproject/tor-android#57
  • Loading branch information
eighthave authored and syphyr committed Feb 4, 2022
1 parent e9d0d8d commit e8833f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/feature/api/org_torproject_jni_TorService.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,16 @@ Java_org_torproject_jni_TorService_runMain
{
return RunMain(env, thisObj);
}

JNIEXPORT void JNICALL
Java_org_torproject_jni_TorService_torFreeAll
(JNIEnv *env, jobject _ignore)
{
UNUSED(env);
UNUSED(_ignore);
tor_free_all(0);
}

/**
* Android does not support UNIX Domain Sockets, but we can fake it by sending
* the file descriptor via a java.io.FileDescriptor instance, which can be
Expand Down
9 changes: 9 additions & 0 deletions src/feature/api/org_torproject_jni_TorService.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ JNIEXPORT jint JNICALL
Java_org_torproject_jni_TorService_runMain
(JNIEnv *, jobject);

/*
* Class: org_torproject_jni_TorService
* Method: torFreeAll
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_org_torproject_jni_TorService_torFreeAll
(JNIEnv *, jobject);

/*
* Class: org_torproject_jni_TorService
* Method: prepareFileDescriptor
Expand Down

0 comments on commit e8833f8

Please sign in to comment.