Bind sqlite3_interrupt() and sqlite3_is_interrupted() to JNI but with caveats regarding mutexing of the JNIEnv cache. Add a loud warning to the JNI 'dist' target that it should be built with JDK8 (a.k.a. Java 1.8) for compatibility reasons.
FossilOrigin-Name: fbf99a2423dd20e4544bdeea85f714e9368ce3b92fefe97efb39a0fb4a557abe
This commit is contained in:
parent
202651fe86
commit
0c07549fd6
@ -317,6 +317,10 @@ dist: \
|
||||
$(bin.version-info) $(sqlite3.canonical.c) \
|
||||
$(package.jar) $(MAKEFILE)
|
||||
@echo "Making end-user deliverables..."
|
||||
@echo "****************************************************************************"; \
|
||||
echo "*** WARNING: be sure to build this with JDK8 (javac 1.8) for compatibility."; \
|
||||
echo "*** reasons!"; $$($(bin.javac) -version); \
|
||||
echo "****************************************************************************"
|
||||
@rm -fr $(dist-dir.top)
|
||||
@mkdir -p $(dist-dir.src)
|
||||
@cp -p $(dist.top.extras) $(dist-dir.top)/.
|
||||
|
@ -2624,6 +2624,20 @@ JDECL(jint,1finalize)(JENV_CSELF, jobject jpStmt){
|
||||
return rc;
|
||||
}
|
||||
|
||||
JDECL(void,1interrupt)(JENV_CSELF, jobject jpDb){
|
||||
sqlite3 * const pDb = PtrGet_sqlite3(jpDb);
|
||||
if( pDb ) sqlite3_interrupt(pDb);
|
||||
}
|
||||
|
||||
JDECL(jboolean,1is_1interrupted)(JENV_CSELF, jobject jpDb){
|
||||
int rc = 0;
|
||||
sqlite3 * const pDb = PtrGet_sqlite3(jpDb);
|
||||
if( pDb ){
|
||||
rc = sqlite3_is_interrupted(pDb);
|
||||
}
|
||||
return rc ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
|
||||
JDECL(jlong,1last_1insert_1rowid)(JENV_CSELF, jobject jpDb){
|
||||
return (jlong)sqlite3_last_insert_rowid(PtrGet_sqlite3(jpDb));
|
||||
|
@ -1120,7 +1120,7 @@ JNIEXPORT jstring JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1db_1filename
|
||||
* Method: sqlite3_db_config
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;IILorg/sqlite/jni/OutputPointer/Int32;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1db_1config__Lorg_sqlite_jni_sqlite3_2IILorg_sqlite_jni_OutputPointer_00024Int32_2
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1db_1config__Lorg_sqlite_jni_sqlite3_2IILorg_sqlite_jni_OutputPointer_Int32_2
|
||||
(JNIEnv *, jclass, jobject, jint, jint, jobject);
|
||||
|
||||
/*
|
||||
@ -1211,6 +1211,22 @@ JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1finalize
|
||||
JNIEXPORT jint JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1initialize
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_interrupt
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1interrupt
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_is_interrupted
|
||||
* Signature: (Lorg/sqlite/jni/sqlite3;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_sqlite_jni_SQLite3Jni_sqlite3_1is_1interrupted
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_sqlite_jni_SQLite3Jni
|
||||
* Method: sqlite3_last_insert_rowid
|
||||
|
@ -557,6 +557,25 @@ public final class SQLite3Jni {
|
||||
|
||||
public static synchronized native int sqlite3_initialize();
|
||||
|
||||
/**
|
||||
Design note/FIXME: we have a problem vis-a-vis 'synchronized'
|
||||
here: we specifically want other threads to be able to cancel a
|
||||
long-running thread, but this routine requires access to C-side
|
||||
global state which does not have a mutex. Making this function
|
||||
synchronized would make it impossible for a long-running job to
|
||||
be cancelled from another thread.
|
||||
|
||||
The mutexing problem here is not within the core lib or Java, but
|
||||
within the cached data held by the JNI binding. The cache holds
|
||||
per-thread state, used by all but a tiny fraction of the JNI
|
||||
binding layer, and access to that state needs to be
|
||||
mutex-protected.
|
||||
*/
|
||||
public static native void sqlite3_interrupt(@NotNull sqlite3 db);
|
||||
|
||||
//! See sqlite3_interrupt() for threading concerns.
|
||||
public static native boolean sqlite3_is_interrupted(@NotNull sqlite3 db);
|
||||
|
||||
public static synchronized native long sqlite3_last_insert_rowid(@NotNull sqlite3 db);
|
||||
|
||||
public static synchronized native String sqlite3_libversion();
|
||||
|
@ -163,6 +163,13 @@ public class Tester1 {
|
||||
/* This function has different mangled names in jdk8 vs jdk19,
|
||||
and this call is here to ensure that the build fails
|
||||
if it cannot find both names. */;
|
||||
|
||||
// These interrupt checks are only to make sure that the JNI binding
|
||||
// has the proper exported symbol names. They don't actually test
|
||||
// anything useful.
|
||||
affirm( !sqlite3_is_interrupted(db) );
|
||||
sqlite3_interrupt(db);
|
||||
affirm( sqlite3_is_interrupted(db) );
|
||||
sqlite3_close_v2(db);
|
||||
affirm(0 == db.getNativePointer());
|
||||
}
|
||||
|
21
manifest
21
manifest
@ -1,5 +1,5 @@
|
||||
C Merge\sthe\sJava\sNative\sInterface\s(JNI)\sbinding\sinto\strunk.
|
||||
D 2023-08-12T21:39:18.053
|
||||
C Bind\ssqlite3_interrupt()\sand\ssqlite3_is_interrupted()\sto\sJNI\sbut\swith\scaveats\sregarding\smutexing\sof\sthe\sJNIEnv\scache.\sAdd\sa\sloud\swarning\sto\sthe\sJNI\s'dist'\starget\sthat\sit\sshould\sbe\sbuilt\swith\sJDK8\s(a.k.a.\sJava\s1.8)\sfor\scompatibility\sreasons.
|
||||
D 2023-08-12T23:47:58.408
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -231,11 +231,11 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c
|
||||
F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9
|
||||
F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282
|
||||
F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8
|
||||
F ext/jni/GNUmakefile 435485ff2005c4bcdea808f5efe6d4ee66a00430c2499dcc4927b20378486bea
|
||||
F ext/jni/GNUmakefile a9e11b92e620058558cbc1a2d49f8ec53c78d6a989b9db0b7d0b649b9f174881
|
||||
F ext/jni/README.md 7a614a2fa6c561205f7a53fd8626cf93a7b5711ff454fc1814517f796df398eb
|
||||
F ext/jni/jar-dist.make f90a553203a57934bf275bed86479485135a52f48ac5c1cfe6499ae07b0b35a4
|
||||
F ext/jni/src/c/sqlite3-jni.c bea6b8691a5fa3a8626a771757bb261208d3c5fc6598266d3b0ee23d88e35632
|
||||
F ext/jni/src/c/sqlite3-jni.h c5f941b057a24ee62942e6e1bf5a7fd527e5004d20d9638e84a9382813c3cf2a
|
||||
F ext/jni/src/c/sqlite3-jni.c 1d3bb5113ba4dd7f8645fcc4c669155931e44e234816f528642a738914dd45a4
|
||||
F ext/jni/src/c/sqlite3-jni.h 11bf3ab9682f5c393e6ac6a3ddb0fdf7b8dd40f7c77f9ef122d3e5c011a5d329
|
||||
F ext/jni/src/org/sqlite/jni/Authorizer.java 1308988f7f40579ea0e4deeaec3c6be971630566bd021c31367fe3f5140db892
|
||||
F ext/jni/src/org/sqlite/jni/AutoExtension.java 18e83f6f463e306df60b2dceb65247d32af1f78af4bbbae9155411a8c6cdb093
|
||||
F ext/jni/src/org/sqlite/jni/BusyHandler.java 1b1d3e5c86cd796a0580c81b6af6550ad943baa25e47ada0dcca3aff3ebe978c
|
||||
@ -254,8 +254,8 @@ F ext/jni/src/org/sqlite/jni/ProgressHandler.java 6f62053a828a572de809828b1ee495
|
||||
F ext/jni/src/org/sqlite/jni/ResultCode.java ba701f20213a5f259e94cfbfdd36eb7ac7ce7797f2c6c7fca2004ff12ce20f86
|
||||
F ext/jni/src/org/sqlite/jni/RollbackHook.java b04c8abcc6ade44a8a57129e33765793f69df0ba909e49ba18d73f4268d92564
|
||||
F ext/jni/src/org/sqlite/jni/SQLFunction.java 09ce81c1c637e31c3a830d4c859cce95d65f5e02ff45f8bd1985b3479381bc46
|
||||
F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 4b6fd22e04e63eb65d8e4e38fda39ecf15ce244d034607517627ce2e766e7e65
|
||||
F ext/jni/src/org/sqlite/jni/Tester1.java 07c14a90427529ceba54b5e8344ca03602f5789dc53c4163ce22f92d8c577a11
|
||||
F ext/jni/src/org/sqlite/jni/SQLite3Jni.java 1652af40fc0acb7a140dbe32e3146f980c37c28454b5115a4d0856cbdbc52696
|
||||
F ext/jni/src/org/sqlite/jni/Tester1.java fc2ec1f1be58474112b9df8284f0157b64872107f446154c3d0bf1742b924d2b
|
||||
F ext/jni/src/org/sqlite/jni/TesterFts5.java 59e22dd24af033ea8827d36225a2f3297908fb6af8818ead8850c6c6847557b1
|
||||
F ext/jni/src/org/sqlite/jni/Tracer.java a5cece9f947b0af27669b8baec300b6dd7ff859c3e6a6e4a1bd8b50f9714775d
|
||||
F ext/jni/src/org/sqlite/jni/UpdateHook.java e58645a1727f8a9bbe72dc072ec5b40d9f9362cb0aa24acfe93f49ff56a9016d
|
||||
@ -2091,9 +2091,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 0a6930a7ff8f8c6ca244d1d654532f3d2a02d77ef67c6cae0c53092743d59ea6 1ba7754045a009d9c94b23ac76b9bb8d9c9cb24d42dcdf1203ee75ac85765d3e
|
||||
R 71919983f1228c04d42d3555e47fba1b
|
||||
T +closed 1ba7754045a009d9c94b23ac76b9bb8d9c9cb24d42dcdf1203ee75ac85765d3e Closed\sby\sintegrate-merge.
|
||||
P 48b13edcec6935bf125b265b41a3e6f7b2407afff89d5b4daa2939e3c5679ca0
|
||||
R 122775c5939e6f1540fadefe535658be
|
||||
U stephan
|
||||
Z 06dd3519c67c3e383d12eeb6b6fbb0d1
|
||||
Z a13d97b8681eef4145a4ab842cd3a9d2
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@ -1 +1 @@
|
||||
48b13edcec6935bf125b265b41a3e6f7b2407afff89d5b4daa2939e3c5679ca0
|
||||
fbf99a2423dd20e4544bdeea85f714e9368ce3b92fefe97efb39a0fb4a557abe
|
Loading…
x
Reference in New Issue
Block a user