Skip to content

Commit

Permalink
Updated core to 13.26.0 (#3502)
Browse files Browse the repository at this point in the history
* Updated core to 13.26.0

* Corrected errors

* Set default to true

* Apply suggestions from code review

Co-authored-by: Nikola Irinchev <irinchev@me.com>

---------

Co-authored-by: Nikola Irinchev <irinchev@me.com>
  • Loading branch information
papafe and nirinchev authored Jan 30, 2024
1 parent 71158b7 commit 46a8227
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 32 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
* Fixed several errors that could cause a crash of the sync client. (Core 13.25.0)
* Bad performance of initial Sync download involving many backlinks. (Core 13.25.1)
* Explicitly bumped the minimum version of System.Net.Security to 4.3.2 as 4.3.0 has been marked as vulnerable (more details can be found in the deprecation notice on the [NuGet page](https://www.nuget.org/packages/System.Net.Security/4.3.0)).
* Handle EOPNOTSUPP when using posix_fallocate() and fallback to manually consume space. This should enable android users to open a Realm on restrictive filesystems. (Core 13.26.0)
* Application may crash with incoming_changesets.size() != 0 when a download message is mistaken for a bootstrap message. This can happen if the synchronization session is paused and resumed at a specific time. (Core 13.26.0)
* Fixed errors complaining about missing symbols such as `__atomic_is_lock_free` on ARMv7 Linux (Core 13.26.0)

### Compatibility
* Realm Studio: 13.0.0 or later.

### Internal
* Using Core 13.25.1.
* Using Core 13.26.0.

## 11.6.1 (2023-11-17)

Expand Down
58 changes: 37 additions & 21 deletions Realm/Realm/Handles/AppHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,17 @@ public static extern IntPtr get_user_for_testing(
[MarshalAs(UnmanagedType.LPWStr)] string access_token_buf, IntPtr access_token_len,
out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "shared_app_set_fake_sync_route_for_testing", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr set_fake_sync_route_for_testing(AppHandle app, out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "shared_app_clear_cached_apps", CallingConvention = CallingConvention.Cdecl)]
public static extern void clear_cached_apps(out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "shared_app_get_base_file_path", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr get_base_file_path(AppHandle app, IntPtr buffer, IntPtr buffer_length, out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "shared_app_get_base_uri", CallingConvention = CallingConvention.Cdecl)]
public static extern StringValue get_base_uri(AppHandle app, out NativeException ex);
public static extern IntPtr get_base_uri(AppHandle app, IntPtr buffer, IntPtr buffer_length, out NativeException ex);

[DllImport(InteropConfig.DLL_NAME, EntryPoint = "shared_app_get_id", CallingConvention = CallingConvention.Cdecl)]
public static extern StringValue get_id(AppHandle app, out NativeException ex);
Expand Down Expand Up @@ -307,23 +310,6 @@ public async Task DeleteUserAsync(SyncUserHandle user)
}
}

public void ResetForTesting()
{
NativeMethods.reset_for_testing(this);
}

public SyncUserHandle GetUserForTesting(string id, string refreshToken, string accessToken)
{
var result = NativeMethods.get_user_for_testing(
this,
id, (IntPtr)id.Length,
refreshToken, (IntPtr)refreshToken.Length,
accessToken, (IntPtr)accessToken.Length,
out var ex);
ex.ThrowIfNecessary();
return new SyncUserHandle(result);
}

public string GetBaseFilePath()
{
return MarshalHelpers.GetString((IntPtr buffer, IntPtr length, out bool isNull, out NativeException ex) =>
Expand All @@ -335,9 +321,13 @@ public string GetBaseFilePath()

public Uri GetBaseUri()
{
var value = NativeMethods.get_base_uri(this, out var ex);
ex.ThrowIfNecessary();
return new Uri(value!);
var uriString = MarshalHelpers.GetString((IntPtr buffer, IntPtr length, out bool isNull, out NativeException ex) =>
{
isNull = false;
return NativeMethods.get_base_uri(this, buffer, length, out ex);
})!;

return new Uri(uriString);
}

public string GetId()
Expand All @@ -356,6 +346,32 @@ public bool IsSameInstance(AppHandle other)

protected override void Unbind() => NativeMethods.destroy(handle);

#region Testing
public void ResetForTesting()
{
NativeMethods.reset_for_testing(this);
}

public SyncUserHandle GetUserForTesting(string id, string refreshToken, string accessToken)
{
var result = NativeMethods.get_user_for_testing(
this,
id, (IntPtr)id.Length,
refreshToken, (IntPtr)refreshToken.Length,
accessToken, (IntPtr)accessToken.Length,
out var ex);
ex.ThrowIfNecessary();
return new SyncUserHandle(result);
}

public void SetFakeSyncRouteForTesting()
{
NativeMethods.set_fake_sync_route_for_testing(this, out var ex);
ex.ThrowIfNecessary();
}

#endregion

[MonoPInvokeCallback(typeof(NativeMethods.UserCallback))]
private static void HandleUserCallback(IntPtr tcs_ptr, IntPtr user_ptr, AppError error)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void FlexibleSync_Subscriptions_MatchesGuid([Values(true, false)] bool us
Realm.UseLegacyGuidRepresentation = useLegacyRepresentation;
#pragma warning restore CS0618 // Type or member is obsolete

var config = GetFakeFLXConfig();
var config = GetFakeFLXConfig(setFakeSyncRoute: true);
config.Schema = new[] { typeof(GuidType), typeof(EmbeddedGuidType) };
using var realm = GetRealm(config);

Expand Down Expand Up @@ -310,7 +310,7 @@ public void SynchronizedRealm_DoesntMigrate([Values(true, false)] bool useLegacy

var expected = GetGuidObjects().ToArray();

var config = GetFakeConfig(userId: "sync-guids-test-user");
var config = GetFakeConfig(userId: "sync-guids-test-user", setFakeSyncRoute: true);
config.Schema = new[] { typeof(GuidType), typeof(EmbeddedGuidType) };

TestHelpers.CopyBundledFileToDocuments("sync-guids.realm", config.DatabasePath);
Expand Down
25 changes: 23 additions & 2 deletions Tests/Realm.Tests/Sync/SyncTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ protected User GetFakeUser(App? app = null, string? id = null, string? refreshTo
return new User(handle, app);
}

// This could be useful when opening a "fake" sync realm locally
protected void SetFakeSyncRoute(App? app)
{
app ??= DefaultApp;
app.Handle.SetFakeSyncRouteForTesting();
}

protected async Task<Realm> GetIntegrationRealmAsync(string? partition = null, App? app = null, int timeout = 10000)
{
var config = await GetIntegrationConfigAsync(partition, app);
Expand Down Expand Up @@ -256,15 +263,29 @@ private static T UpdateConfig<T>(T config)
return config;
}

protected PartitionSyncConfiguration GetFakeConfig(App? app = null, string? userId = null, string? optionalPath = null)
protected PartitionSyncConfiguration GetFakeConfig(App? app = null, string? userId = null,
string? optionalPath = null, bool setFakeSyncRoute = true)
{
var user = GetFakeUser(app, userId);

if (setFakeSyncRoute)
{
SetFakeSyncRoute(app);
}

return UpdateConfig(new PartitionSyncConfiguration(Guid.NewGuid().ToString(), user, optionalPath));
}

protected FlexibleSyncConfiguration GetFakeFLXConfig(App? app = null, string? userId = null, string? optionalPath = null)
protected FlexibleSyncConfiguration GetFakeFLXConfig(App? app = null, string? userId = null,
string? optionalPath = null, bool setFakeSyncRoute = true)
{
var user = GetFakeUser(app, userId);

if (setFakeSyncRoute)
{
SetFakeSyncRoute(app);
}

return UpdateConfig(new FlexibleSyncConfiguration(user, optionalPath));
}

Expand Down
2 changes: 1 addition & 1 deletion wrappers/realm-core
Submodule realm-core updated 79 files
+29 −0 CHANGELOG.md
+17 −33 Jenkinsfile
+2 −1 Package.swift
+9 −3 bindgen/spec.yml
+4 −2 dependencies.list
+17 −8 evergreen/config.yml
+48 −2 evergreen/install_baas.sh
+2 −0 evergreen/setup_baas_host_local.sh
+8 −14 how-to-build.md
+30 −0 src/realm.h
+4 −0 src/realm/CMakeLists.txt
+6 −16 src/realm/db.cpp
+2 −3 src/realm/db.hpp
+1 −0 src/realm/error_codes.cpp
+3 −0 src/realm/error_codes.h
+1 −0 src/realm/error_codes.hpp
+1 −0 src/realm/exceptions.cpp
+22 −0 src/realm/exceptions.hpp
+9 −5 src/realm/object-store/audit.mm
+22 −2 src/realm/object-store/c_api/app.cpp
+4 −3 src/realm/object-store/impl/realm_coordinator.cpp
+5 −2 src/realm/object-store/impl/realm_coordinator.hpp
+5 −4 src/realm/object-store/object_store.cpp
+2 −1 src/realm/object-store/object_store.hpp
+24 −8 src/realm/object-store/shared_realm.cpp
+7 −10 src/realm/object-store/shared_realm.hpp
+345 −244 src/realm/object-store/sync/app.cpp
+140 −71 src/realm/object-store/sync/app.hpp
+107 −8 src/realm/object-store/sync/app_utils.cpp
+19 −2 src/realm/object-store/sync/app_utils.hpp
+119 −19 src/realm/object-store/sync/async_open_task.cpp
+14 −4 src/realm/object-store/sync/async_open_task.hpp
+3 −1 src/realm/object-store/sync/generic_network_transport.cpp
+6 −0 src/realm/object-store/sync/impl/sync_client.hpp
+5 −4 src/realm/object-store/sync/sync_manager.cpp
+13 −3 src/realm/object-store/sync/sync_manager.hpp
+101 −14 src/realm/object-store/sync/sync_session.cpp
+22 −11 src/realm/object-store/sync/sync_session.hpp
+2 −2 src/realm/object-store/sync/sync_user.cpp
+6 −4 src/realm/object-store/sync/sync_user.hpp
+2 −0 src/realm/sync/CMakeLists.txt
+39 −4 src/realm/sync/client.cpp
+8 −18 src/realm/sync/client.hpp
+9 −0 src/realm/sync/network/http.cpp
+40 −3 src/realm/sync/network/http.hpp
+19 −4 src/realm/sync/noinst/client_impl_base.cpp
+5 −0 src/realm/sync/noinst/client_impl_base.hpp
+2 −10 src/realm/sync/noinst/migration_store.cpp
+3 −2 src/realm/sync/noinst/migration_store.hpp
+11 −0 src/realm/sync/noinst/protocol_codec.hpp
+109 −0 src/realm/sync/noinst/sync_schema_migration.cpp
+33 −0 src/realm/sync/noinst/sync_schema_migration.hpp
+9 −0 src/realm/sync/protocol.cpp
+16 −4 src/realm/sync/protocol.hpp
+2 −12 src/realm/sync/subscriptions.cpp
+3 −3 src/realm/sync/subscriptions.hpp
+1 −1 src/realm/util/file.cpp
+1 −0 test/object-store/CMakeLists.txt
+69 −9 test/object-store/c_api/c_api.cpp
+0 −6 test/object-store/realm.cpp
+953 −209 test/object-store/sync/app.cpp
+6 −0 test/object-store/sync/flx_migration.cpp
+990 −0 test/object-store/sync/flx_schema_migration.cpp
+40 −3 test/object-store/sync/flx_sync.cpp
+23 −0 test/object-store/sync/session/session.cpp
+95 −40 test/object-store/util/sync/baas_admin_api.cpp
+2 −0 test/object-store/util/sync/baas_admin_api.hpp
+9 −3 test/object-store/util/sync/flx_sync_harness.hpp
+11 −2 test/object-store/util/sync/sync_test_utils.cpp
+2 −0 test/object-store/util/sync/sync_test_utils.hpp
+5 −5 test/object-store/util/test_file.cpp
+1 −1 test/object-store/util/test_file.hpp
+13 −0 test/object-store/util/test_utils.hpp
+10 −4 test/object-store/util/unit_test_transport.cpp
+13 −0 test/object-store/util/unit_test_transport.hpp
+28 −13 test/test_lang_bind_helper.cpp
+135 −0 test/test_util_http.cpp
+10 −4 tools/cmake/GetVersion.cmake
+0 −5 tools/run_baas_docker_image.sh
21 changes: 16 additions & 5 deletions wrappers/src/app_cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ extern "C" {
sync_client_config.custom_encryption_key = std::vector<char>(key.begin(), key.end());
}

SharedApp app = app_config.use_cache
? App::get_shared_app(std::move(config), std::move(sync_client_config))
: App::get_uncached_app(std::move(config), std::move(sync_client_config));
SharedApp app = App::get_app(app_config.use_cache ?
realm::app::App::CacheMode::Enabled : realm::app::App::CacheMode::Disabled,
std::move(config),
std::move(sync_client_config));

return new SharedApp(app);
});
Expand Down Expand Up @@ -250,6 +251,15 @@ extern "C" {
});
}

REALM_EXPORT void shared_app_set_fake_sync_route_for_testing(SharedApp& app,
NativeException::Marshallable& ex)
{
return handle_errors(ex, [&]() {
app->sync_manager()->set_sync_route("realm://www.test.com:1000");
});
}


REALM_EXPORT void shared_app_remove_user(SharedApp& app, SharedSyncUser& user, void* tcs_ptr, NativeException::Marshallable& ex)
{
return handle_errors(ex, [&]() {
Expand Down Expand Up @@ -318,10 +328,11 @@ extern "C" {
});
}

REALM_EXPORT realm_string_t shared_app_get_base_uri(SharedApp& app, NativeException::Marshallable& ex)
REALM_EXPORT size_t shared_app_get_base_uri(SharedApp& app, uint16_t* buffer, size_t buffer_length, NativeException::Marshallable& ex)
{
return handle_errors(ex, [&]() {
return to_capi(app->base_url());
std::string url(app->get_base_url());
return stringdata_to_csharpstringbuffer(url, buffer, buffer_length);
});
}

Expand Down

0 comments on commit 46a8227

Please sign in to comment.