mirror of
https://github.com/wassname/ray.git
synced 2026-07-15 11:25:40 +08:00
Fix Java test crash due to incorrect destruction order (#9236)
This commit is contained in:
@@ -46,13 +46,6 @@ JNIEXPORT jboolean JNICALL Java_io_ray_runtime_gcs_GlobalStateAccessor_nativeCon
|
||||
return gcs_accessor->Connect();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_io_ray_runtime_gcs_GlobalStateAccessor_nativeDisconnect(
|
||||
JNIEnv *env, jobject o, jlong gcs_accessor_ptr) {
|
||||
auto *gcs_accessor =
|
||||
reinterpret_cast<ray::gcs::GlobalStateAccessor *>(gcs_accessor_ptr);
|
||||
gcs_accessor->Disconnect();
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_io_ray_runtime_gcs_GlobalStateAccessor_nativeGetAllJobInfo(
|
||||
JNIEnv *env, jobject o, jlong gcs_accessor_ptr) {
|
||||
auto *gcs_accessor =
|
||||
|
||||
@@ -50,14 +50,6 @@ Java_io_ray_runtime_gcs_GlobalStateAccessor_nativeDestroyGlobalStateAccessor(JNI
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_io_ray_runtime_gcs_GlobalStateAccessor_nativeConnect(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: io_ray_runtime_gcs_GlobalStateAccessor
|
||||
* Method: nativeDisconnect
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_io_ray_runtime_gcs_GlobalStateAccessor_nativeDisconnect(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: io_ray_runtime_gcs_GlobalStateAccessor
|
||||
* Method: nativeGetAllJobInfo
|
||||
|
||||
@@ -46,11 +46,7 @@ GlobalStateAccessor::GlobalStateAccessor(const std::string &redis_address,
|
||||
promise.get_future().get();
|
||||
}
|
||||
|
||||
GlobalStateAccessor::~GlobalStateAccessor() {
|
||||
Disconnect();
|
||||
io_service_->stop();
|
||||
thread_io_service_->join();
|
||||
}
|
||||
GlobalStateAccessor::~GlobalStateAccessor() { Disconnect(); }
|
||||
|
||||
bool GlobalStateAccessor::Connect() {
|
||||
if (!is_connected_) {
|
||||
@@ -64,6 +60,8 @@ bool GlobalStateAccessor::Connect() {
|
||||
|
||||
void GlobalStateAccessor::Disconnect() {
|
||||
if (is_connected_) {
|
||||
io_service_->stop();
|
||||
thread_io_service_->join();
|
||||
gcs_client_->Disconnect();
|
||||
is_connected_ = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user