-
Notifications
You must be signed in to change notification settings - Fork 61
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
Cleanup resources better during Client Reset and closing Realms. #1515
Conversation
# Conflicts: # CHANGELOG.md
# Conflicts: # packages/test-sync/src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/AppConfigurationTests.kt
PosixFilePermission.OWNER_READ | ||
) | ||
) | ||
// Use the File API as it works across Windows and POSIX. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or does it ... since you disabled the test on windows because it doesn't work 🤪
...es/library-sync/src/commonMain/kotlin/io/realm/kotlin/mongodb/internal/SyncedRealmContext.kt
Outdated
Show resolved
Hide resolved
...ync/src/commonMain/kotlin/io/realm/kotlin/mongodb/exceptions/ClientResetRequiredException.kt
Show resolved
Hide resolved
...src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt
Outdated
Show resolved
Hide resolved
...src/commonTest/kotlin/io/realm/kotlin/test/mongodb/common/SyncClientResetIntegrationTests.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix 🎉 minor comments
@@ -906,7 +906,7 @@ after_client_reset(void* userdata, realm_t* before_realm, | |||
realm_t* after_realm_ptr = realm_from_thread_safe_reference(after_realm, &scheduler); | |||
auto after_pointer = wrap_pointer(env, reinterpret_cast<jlong>(after_realm_ptr), false); | |||
env->CallVoidMethod(static_cast<jobject>(userdata), java_after_callback_function, before_pointer, after_pointer, did_recover); | |||
|
|||
realm_close(after_realm_ptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also close the pointers for Darwin? https://github.com/realm/realm-kotlin/blob/main/packages/cinterop/src/nativeDarwin/kotlin/io/realm/kotlin/internal/interop/RealmInterop.kt#L2534-L2538
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, we probably should. I'm only closing them here because it prevents Windows from removing the file, but you are correct. We should also behave nice on Darwin.
runBlocking { | ||
realmPointerMutex.withLock { | ||
realmReferenceLock.withLock { | ||
if (isClosed()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (isClosed()) { | |
if (isClosed.value) { |
@@ -64,7 +63,7 @@ class FlexibleSyncIntegrationTests { | |||
|
|||
@BeforeTest | |||
fun setup() { | |||
app = TestApp(this::class.simpleName, appName = TEST_APP_FLEX, logLevel = LogLevel.ALL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be helpful to keep it all for CI failures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember having all the logs available was ever useful on CI. Just having the final exception seems to do the trick?
This PR fixes some problems I discovered on Windows.