[-]
[+]
|
Changed |
_service:tar_git:libgbinder.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -6,7 +6,7 @@
<service name="tar_git">
<param name="url">https://github.com/mer-hybris/libgbinder.git</param>
<param name="branch">master</param>
- <param name="revision">885d27c12c52eab96cf8155636bf2d3d0fca05f5</param>
+ <param name="revision">84efc32ac09925b166843a7a60592c378689ccd3</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.32.tar.bz2/LICENSE
^
|
@@ -1,5 +1,5 @@
Copyright (C) 2018-2022 Jolla Ltd.
-Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
+Copyright (C) 2023 Slava Monich <slava@monich.com>
You may use this file under the terms of BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.32.tar.bz2/Makefile
^
|
@@ -16,7 +16,7 @@
VERSION_MAJOR = 1
VERSION_MINOR = 1
-VERSION_RELEASE = 31
+VERSION_RELEASE = 32
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.32.tar.bz2/debian/changelog
^
|
@@ -1,3 +1,9 @@
+libgbinder (1.1.32) unstable; urgency=low
+
+ * Improved reliability of unit tests
+
+ -- Slava Monich <slava@monich.com> Mon, 23 Jan 2023 11:48:00 +0200
+
libgbinder (1.1.31) unstable; urgency=low
* Fixed serialization issues on big-endian
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.32.tar.bz2/debian/copyright
^
|
@@ -1,5 +1,5 @@
Copyright (C) 2018-2022 Jolla Ltd.
-Copyright (C) 2018-2022 Slava Monich <slava.monich@jolla.com>
+Copyright (C) 2023 Slava Monich <slava@monich.com>
You may use this file under the terms of BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.32.tar.bz2/unit/unit_proxy_object/unit_proxy_object.c
^
|
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2021-2022 Jolla Ltd.
- * Copyright (C) 2021-2022 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -246,6 +245,7 @@
test_param_cancel(
gpointer req)
{
+ GDEBUG("Cancelling request");
gbinder_remote_request_complete(req, NULL, -ECANCELED);
return G_SOURCE_REMOVE;
}
@@ -296,11 +296,12 @@
GBinderClient* client,
GBinderRemoteReply* reply,
int status,
- void* unused)
+ void* loop)
{
g_assert(!reply);
g_assert_cmpint(status, == ,-ECANCELED);
GDEBUG("Transaction cancelled");
+ g_main_loop_quit((GMainLoop*)loop);
}
static
@@ -340,6 +341,7 @@
GBinderIpc* ipc_obj;
GBinderIpc* ipc_proxy;
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
+ GMainLoop* loop2 = g_main_loop_new(NULL, FALSE);
int fd_obj, fd_proxy, n = 0;
test_config_init(&config, NULL);
@@ -363,7 +365,7 @@
req = gbinder_client_new_request(client);
gbinder_local_request_append_int32(req, TX_PARAM_DONT_REPLY);
gbinder_client_transact(client, TX_CODE, 0, req, test_param_canceled,
- NULL, NULL);
+ NULL, loop2);
gbinder_local_request_unref(req);
req = gbinder_client_new_request(client);
@@ -373,9 +375,8 @@
gbinder_local_request_unref(req);
test_run(&test_opt, loop);
-
- /* Depending on how callbacks are scheduled, n could be 1 or 2 */
- g_assert_cmpint(n, > ,0);
+ test_run(&test_opt, loop2);
+ g_assert_cmpint(n, == ,2);
test_binder_unregister_objects(fd_obj);
test_binder_unregister_objects(fd_proxy);
@@ -388,6 +389,7 @@
test_binder_exit_wait(&test_opt, loop);
test_config_deinit(&config);
g_main_loop_unref(loop);
+ g_main_loop_unref(loop2);
}
static
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.32.tar.bz2/unit/unit_servicemanager_aidl/unit_servicemanager_aidl.c
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2020-2022 Jolla Ltd.
- * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -98,6 +98,7 @@
typedef struct service_manager_aidl {
GBinderLocalObject parent;
GHashTable* objects;
+ GMutex mutex;
} ServiceManagerAidl;
#define SERVICE_MANAGER_AIDL_TYPE (service_manager_aidl_get_type())
@@ -109,23 +110,23 @@
static
GBinderLocalReply*
servicemanager_aidl_handler(
- GBinderLocalObject* obj,
+ ServiceManagerAidl* self,
GBinderRemoteRequest* req,
guint code,
- guint flags,
- int* status,
- void* user_data)
+ int* status)
{
- ServiceManagerAidl* self = user_data;
+ GBinderLocalObject* obj = &self->parent;
GBinderLocalReply* reply = NULL;
GBinderReader reader;
GBinderRemoteObject* remote_obj;
guint32 num;
char* str;
- g_assert(!flags);
- g_assert_cmpstr(gbinder_remote_request_interface(req), == ,SVCMGR_IFACE);
+ GDEBUG("%s %u", gbinder_remote_request_interface(req), code);
*status = -1;
+
+ /* Lock */
+ g_mutex_lock(&self->mutex);
switch (code) {
case GET_SERVICE_TRANSACTION:
case CHECK_SERVICE_TRANSACTION:
@@ -178,33 +179,39 @@
GDEBUG("Unhandled command %u", code);
break;
}
+ g_mutex_unlock(&self->mutex);
+ /* Unlock */
+
return reply;
}
static
-ServiceManagerAidl*
-servicemanager_aidl_new(
- const char* dev)
+GBinderLocalReply*
+servicemanager_aidl_handle_looper_transaction(
+ GBinderLocalObject* obj,
+ GBinderRemoteRequest* req,
+ guint code,
+ guint flags,
+ int* status)
{
- ServiceManagerAidl* self = g_object_new(SERVICE_MANAGER_AIDL_TYPE, NULL);
- GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
- GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
- const int fd = gbinder_driver_fd(ipc->driver);
-
- gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
- servicemanager_aidl_handler, self);
- test_binder_register_object(fd, obj, SVCMGR_HANDLE);
- gbinder_ipc_register_local_object(ipc, obj);
- gbinder_ipc_unref(ipc);
- return self;
+ return !g_strcmp0(gbinder_remote_request_interface(req), SVCMGR_IFACE) ?
+ servicemanager_aidl_handler(SERVICE_MANAGER_AIDL(obj),
+ req, code, status) :
+ GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl_parent_class)->
+ handle_looper_transaction(obj, req, code, flags, status);
}
static
-void
-servicemanager_aidl_free(
- ServiceManagerAidl* self)
-{
- gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(self));
+GBINDER_LOCAL_TRANSACTION_SUPPORT
+servicemanager_aidl_can_handle_transaction(
+ GBinderLocalObject* self,
+ const char* iface,
+ guint code)
+{
+ /* Handle servicemanager transactions on the looper thread */
+ return !g_strcmp0(iface, SVCMGR_IFACE) ? GBINDER_LOCAL_TRANSACTION_LOOPER :
+ GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl_parent_class)->
+ can_handle_transaction(self, iface, code);
}
static
@@ -214,6 +221,7 @@
{
ServiceManagerAidl* self = SERVICE_MANAGER_AIDL(object);
+ g_mutex_clear(&self->mutex);
g_hash_table_destroy(self->objects);
G_OBJECT_CLASS(service_manager_aidl_parent_class)->finalize(object);
}
@@ -223,6 +231,7 @@
service_manager_aidl_init(
ServiceManagerAidl* self)
{
+ g_mutex_init(&self->mutex);
self->objects = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify) gbinder_remote_object_unref);
}
@@ -233,6 +242,28 @@
ServiceManagerAidlClass* klass)
{
G_OBJECT_CLASS(klass)->finalize = service_manager_aidl_finalize;
+ klass->can_handle_transaction =
+ servicemanager_aidl_can_handle_transaction;
+ klass->handle_looper_transaction =
+ servicemanager_aidl_handle_looper_transaction;
+}
+
+static
+ServiceManagerAidl*
+servicemanager_aidl_new(
+ const char* dev)
+{
+ ServiceManagerAidl* self = g_object_new(SERVICE_MANAGER_AIDL_TYPE, NULL);
+ GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
+ const int fd = gbinder_driver_fd(ipc->driver);
+
+ gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
+ NULL, NULL);
+ test_binder_register_object(fd, obj, SVCMGR_HANDLE);
+ gbinder_ipc_register_local_object(ipc, obj);
+ gbinder_ipc_unref(ipc);
+ return self;
}
/*==========================================================================*
@@ -317,7 +348,7 @@
test_binder_unregister_objects(fd);
gbinder_local_object_unref(obj);
- servicemanager_aidl_free(smsvc);
+ gbinder_local_object_unref(GBINDER_LOCAL_OBJECT(smsvc));
gbinder_servicemanager_unref(sm);
gbinder_ipc_unref(ipc);
@@ -400,7 +431,7 @@
test_binder_unregister_objects(fd);
gbinder_local_object_unref(obj);
- servicemanager_aidl_free(smsvc);
+ gbinder_local_object_unref(GBINDER_LOCAL_OBJECT(smsvc));
gbinder_servicemanager_unref(sm);
gbinder_ipc_unref(ipc);
@@ -468,7 +499,7 @@
test_binder_unregister_objects(fd);
gbinder_local_object_unref(obj);
- servicemanager_aidl_free(svc);
+ gbinder_local_object_unref(GBINDER_LOCAL_OBJECT(svc));
gbinder_servicemanager_unref(sm);
gbinder_ipc_unref(ipc);
@@ -532,7 +563,7 @@
test_binder_unregister_objects(fd);
gbinder_local_object_unref(obj);
- servicemanager_aidl_free(smsvc);
+ gbinder_local_object_unref(GBINDER_LOCAL_OBJECT(smsvc));
gbinder_servicemanager_unref(sm);
gbinder_ipc_unref(ipc);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.32.tar.bz2/unit/unit_servicemanager_aidl2/unit_servicemanager_aidl2.c
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2020-2022 Jolla Ltd.
- * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -58,6 +58,22 @@
return 0;
}
+GType
+gbinder_servicemanager_aidl3_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl3 */
+ g_assert_not_reached();
+ return 0;
+}
+
+GType
+gbinder_servicemanager_aidl4_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl4 */
+ g_assert_not_reached();
+ return 0;
+}
+
/*==========================================================================*
* Test service manager
*==========================================================================*/
@@ -77,6 +93,7 @@
typedef struct service_manager_aidl2 {
GBinderLocalObject parent;
GHashTable* objects;
+ GMutex mutex;
} ServiceManagerAidl2;
#define SERVICE_MANAGER_AIDL2_TYPE (service_manager_aidl2_get_type())
@@ -88,24 +105,23 @@
static
GBinderLocalReply*
servicemanager_aidl2_handler(
- GBinderLocalObject* obj,
+ ServiceManagerAidl2* self,
GBinderRemoteRequest* req,
guint code,
- guint flags,
- int* status,
- void* user_data)
+ int* status)
{
- ServiceManagerAidl2* self = user_data;
+ GBinderLocalObject* obj = &self->parent;
GBinderLocalReply* reply = NULL;
GBinderReader reader;
GBinderRemoteObject* remote_obj;
guint32 num, allow_isolated, dumpsys_priority;
char* str;
- g_assert(!flags);
GDEBUG("%s %u", gbinder_remote_request_interface(req), code);
- g_assert_cmpstr(gbinder_remote_request_interface(req), == ,SVCMGR_IFACE);
*status = -1;
+
+ /* Lock */
+ g_mutex_lock(&self->mutex);
switch (code) {
case GET_SERVICE_TRANSACTION:
case CHECK_SERVICE_TRANSACTION:
@@ -163,25 +179,39 @@
GDEBUG("Unhandled command %u", code);
break;
}
+ g_mutex_unlock(&self->mutex);
+ /* Unlock */
+
return reply;
}
static
-ServiceManagerAidl2*
-servicemanager_aidl2_new(
- const char* dev)
+GBinderLocalReply*
+servicemanager_aidl2_handle_looper_transaction(
+ GBinderLocalObject* obj,
+ GBinderRemoteRequest* req,
+ guint code,
+ guint flags,
+ int* status)
{
- ServiceManagerAidl2* self = g_object_new(SERVICE_MANAGER_AIDL2_TYPE, NULL);
- GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
- GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
- const int fd = gbinder_driver_fd(ipc->driver);
+ return !g_strcmp0(gbinder_remote_request_interface(req), SVCMGR_IFACE) ?
+ servicemanager_aidl2_handler(SERVICE_MANAGER_AIDL2(obj),
+ req, code, status) :
+ GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl2_parent_class)->
+ handle_looper_transaction(obj, req, code, flags, status);
+}
- gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
- servicemanager_aidl2_handler, self);
- test_binder_register_object(fd, obj, SVCMGR_HANDLE);
- gbinder_ipc_register_local_object(ipc, obj);
- gbinder_ipc_unref(ipc);
- return self;
+static
+GBINDER_LOCAL_TRANSACTION_SUPPORT
+servicemanager_aidl2_can_handle_transaction(
+ GBinderLocalObject* self,
+ const char* iface,
+ guint code)
+{
+ /* Handle servicemanager transactions on the looper thread */
+ return !g_strcmp0(iface, SVCMGR_IFACE) ? GBINDER_LOCAL_TRANSACTION_LOOPER :
+ GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl2_parent_class)->
+ can_handle_transaction(self, iface, code);
}
static
@@ -191,6 +221,7 @@
{
ServiceManagerAidl2* self = SERVICE_MANAGER_AIDL2(object);
+ g_mutex_clear(&self->mutex);
g_hash_table_destroy(self->objects);
G_OBJECT_CLASS(service_manager_aidl2_parent_class)->finalize(object);
}
@@ -200,6 +231,7 @@
service_manager_aidl2_init(
ServiceManagerAidl2* self)
{
+ g_mutex_init(&self->mutex);
self->objects = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify) gbinder_remote_object_unref);
}
@@ -210,6 +242,28 @@
ServiceManagerAidl2Class* klass)
{
G_OBJECT_CLASS(klass)->finalize = service_manager_aidl2_finalize;
+ klass->can_handle_transaction =
+ servicemanager_aidl2_can_handle_transaction;
+ klass->handle_looper_transaction =
+ servicemanager_aidl2_handle_looper_transaction;
+}
+
+static
+ServiceManagerAidl2*
+servicemanager_aidl2_new(
+ const char* dev)
+{
+ ServiceManagerAidl2* self = g_object_new(SERVICE_MANAGER_AIDL2_TYPE, NULL);
+ GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
+ const int fd = gbinder_driver_fd(ipc->driver);
+
+ gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
+ NULL, NULL);
+ test_binder_register_object(fd, obj, SVCMGR_HANDLE);
+ gbinder_ipc_register_local_object(ipc, obj);
+ gbinder_ipc_unref(ipc);
+ return self;
}
/*==========================================================================*
@@ -272,7 +326,7 @@
{
test_binder_br_dead_binder_obj(test->fd, test->object);
gbinder_local_object_unref(test->object);
- gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(test->service));
+ gbinder_local_object_unref(GBINDER_LOCAL_OBJECT(test->service));
gbinder_servicemanager_unref(test->client);
test_binder_exit_wait(&test_opt, test->loop);
remove(test->config_file);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.32.tar.bz2/unit/unit_servicemanager_aidl3/unit_servicemanager_aidl3.c
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2020-2022 Jolla Ltd.
- * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -59,6 +59,22 @@
return 0;
}
+GType
+gbinder_servicemanager_aidl2_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl2 */
+ g_assert_not_reached();
+ return 0;
+}
+
+GType
+gbinder_servicemanager_aidl4_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl4 */
+ g_assert_not_reached();
+ return 0;
+}
+
/*==========================================================================*
* Test service manager
*==========================================================================*/
@@ -78,6 +94,7 @@
typedef struct service_manager_aidl3 {
GBinderLocalObject parent;
GHashTable* objects;
+ GMutex mutex;
} ServiceManagerAidl3;
#define SERVICE_MANAGER_AIDL3_TYPE (service_manager_aidl3_get_type())
@@ -89,24 +106,23 @@
static
GBinderLocalReply*
servicemanager_aidl3_handler(
- GBinderLocalObject* obj,
+ ServiceManagerAidl3* self,
GBinderRemoteRequest* req,
guint code,
- guint flags,
- int* status,
- void* user_data)
+ int* status)
{
- ServiceManagerAidl3* self = user_data;
+ GBinderLocalObject* obj = &self->parent;
GBinderLocalReply* reply = NULL;
GBinderReader reader;
GBinderRemoteObject* remote_obj;
guint32 allow_isolated, dumpsys_priority;
char* str;
- g_assert(!flags);
GDEBUG("%s %u", gbinder_remote_request_interface(req), code);
- g_assert_cmpstr(gbinder_remote_request_interface(req), == ,SVCMGR_IFACE);
*status = -1;
+
+ /* Lock */
+ g_mutex_lock(&self->mutex);
switch (code) {
case GET_SERVICE_TRANSACTION:
case CHECK_SERVICE_TRANSACTION:
@@ -172,25 +188,39 @@
GDEBUG("Unhandled command %u", code);
break;
}
+ g_mutex_unlock(&self->mutex);
+ /* Unlock */
+
return reply;
}
static
-ServiceManagerAidl3*
-servicemanager_aidl3_new(
- const char* dev)
+GBinderLocalReply*
+servicemanager_aidl3_handle_looper_transaction(
+ GBinderLocalObject* obj,
+ GBinderRemoteRequest* req,
+ guint code,
+ guint flags,
+ int* status)
{
- ServiceManagerAidl3* self = g_object_new(SERVICE_MANAGER_AIDL3_TYPE, NULL);
- GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
- GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
- const int fd = gbinder_driver_fd(ipc->driver);
+ return !g_strcmp0(gbinder_remote_request_interface(req), SVCMGR_IFACE) ?
+ servicemanager_aidl3_handler(SERVICE_MANAGER_AIDL3(obj),
+ req, code, status) :
+ GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl3_parent_class)->
+ handle_looper_transaction(obj, req, code, flags, status);
+}
- gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
- servicemanager_aidl3_handler, self);
- test_binder_register_object(fd, obj, SVCMGR_HANDLE);
- gbinder_ipc_register_local_object(ipc, obj);
- gbinder_ipc_unref(ipc);
- return self;
+static
+GBINDER_LOCAL_TRANSACTION_SUPPORT
+servicemanager_aidl3_can_handle_transaction(
+ GBinderLocalObject* self,
+ const char* iface,
+ guint code)
+{
+ /* Handle servicemanager transactions on the looper thread */
+ return !g_strcmp0(iface, SVCMGR_IFACE) ? GBINDER_LOCAL_TRANSACTION_LOOPER :
+ GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl3_parent_class)->
+ can_handle_transaction(self, iface, code);
}
static
@@ -200,6 +230,7 @@
{
ServiceManagerAidl3* self = SERVICE_MANAGER_AIDL3(object);
+ g_mutex_clear(&self->mutex);
g_hash_table_destroy(self->objects);
G_OBJECT_CLASS(service_manager_aidl3_parent_class)->finalize(object);
}
@@ -209,6 +240,7 @@
service_manager_aidl3_init(
ServiceManagerAidl3* self)
{
+ g_mutex_init(&self->mutex);
self->objects = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify) gbinder_remote_object_unref);
}
@@ -219,6 +251,28 @@
ServiceManagerAidl3Class* klass)
{
G_OBJECT_CLASS(klass)->finalize = service_manager_aidl3_finalize;
+ klass->can_handle_transaction =
+ servicemanager_aidl3_can_handle_transaction;
+ klass->handle_looper_transaction =
+ servicemanager_aidl3_handle_looper_transaction;
+}
+
+static
+ServiceManagerAidl3*
+servicemanager_aidl3_new(
+ const char* dev)
+{
+ ServiceManagerAidl3* self = g_object_new(SERVICE_MANAGER_AIDL3_TYPE, NULL);
+ GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
+ const int fd = gbinder_driver_fd(ipc->driver);
+
+ gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
+ NULL, NULL);
+ test_binder_register_object(fd, obj, SVCMGR_HANDLE);
+ gbinder_ipc_register_local_object(ipc, obj);
+ gbinder_ipc_unref(ipc);
+ return self;
}
/*==========================================================================*
@@ -281,7 +335,7 @@
{
test_binder_br_dead_binder_obj(test->fd, test->object);
gbinder_local_object_unref(test->object);
- gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(test->service));
+ gbinder_local_object_unref(GBINDER_LOCAL_OBJECT(test->service));
gbinder_servicemanager_unref(test->client);
test_binder_exit_wait(&test_opt, test->loop);
remove(test->config_file);
|
[-]
[+]
|
Changed |
_service:tar_git:libgbinder-1.1.32.tar.bz2/unit/unit_servicemanager_aidl4/unit_servicemanager_aidl4.c
^
|
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2020-2022 Jolla Ltd.
- * Copyright (C) 2020-2022 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
@@ -60,6 +59,14 @@
return 0;
}
+GType
+gbinder_servicemanager_aidl2_get_type()
+{
+ /* Dummy function to avoid pulling in gbinder_servicemanager_aidl2 */
+ g_assert_not_reached();
+ return 0;
+}
+
/*==========================================================================*
* Test service manager
*==========================================================================*/
@@ -79,6 +86,7 @@
typedef struct service_manager_aidl4 {
GBinderLocalObject parent;
GHashTable* objects;
+ GMutex mutex;
} ServiceManagerAidl4;
#define SERVICE_MANAGER_AIDL4_TYPE (service_manager_aidl4_get_type())
@@ -90,24 +98,23 @@
static
GBinderLocalReply*
servicemanager_aidl4_handler(
- GBinderLocalObject* obj,
+ ServiceManagerAidl4* self,
GBinderRemoteRequest* req,
guint code,
- guint flags,
- int* status,
- void* user_data)
+ int* status)
{
- ServiceManagerAidl4* self = user_data;
+ GBinderLocalObject* obj = &self->parent;
GBinderLocalReply* reply = NULL;
GBinderReader reader;
GBinderRemoteObject* remote_obj;
guint32 allow_isolated, dumpsys_priority;
char* str;
- g_assert(!flags);
GDEBUG("%s %u", gbinder_remote_request_interface(req), code);
- g_assert_cmpstr(gbinder_remote_request_interface(req), == ,SVCMGR_IFACE);
*status = -1;
+
+ /* Lock */
+ g_mutex_lock(&self->mutex);
switch (code) {
case GET_SERVICE_TRANSACTION:
case CHECK_SERVICE_TRANSACTION:
@@ -179,25 +186,39 @@
GDEBUG("Unhandled command %u", code);
break;
}
+ g_mutex_unlock(&self->mutex);
+ /* Unlock */
+
return reply;
}
static
-ServiceManagerAidl4*
-servicemanager_aidl4_new(
- const char* dev)
+GBinderLocalReply*
+servicemanager_aidl4_handle_looper_transaction(
+ GBinderLocalObject* obj,
+ GBinderRemoteRequest* req,
+ guint code,
+ guint flags,
+ int* status)
{
- ServiceManagerAidl4* self = g_object_new(SERVICE_MANAGER_AIDL4_TYPE, NULL);
- GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
- GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
- const int fd = gbinder_driver_fd(ipc->driver);
+ return !g_strcmp0(gbinder_remote_request_interface(req), SVCMGR_IFACE) ?
+ servicemanager_aidl4_handler(SERVICE_MANAGER_AIDL4(obj),
+ req, code, status) :
+ GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl4_parent_class)->
+ handle_looper_transaction(obj, req, code, flags, status);
+}
- gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
- servicemanager_aidl4_handler, self);
- test_binder_register_object(fd, obj, SVCMGR_HANDLE);
- gbinder_ipc_register_local_object(ipc, obj);
- gbinder_ipc_unref(ipc);
- return self;
+static
+GBINDER_LOCAL_TRANSACTION_SUPPORT
+servicemanager_aidl4_can_handle_transaction(
+ GBinderLocalObject* self,
+ const char* iface,
+ guint code)
+{
+ /* Handle servicemanager transactions on the looper thread */
+ return !g_strcmp0(iface, SVCMGR_IFACE) ? GBINDER_LOCAL_TRANSACTION_LOOPER :
+ GBINDER_LOCAL_OBJECT_CLASS(service_manager_aidl4_parent_class)->
+ can_handle_transaction(self, iface, code);
}
static
@@ -207,6 +228,7 @@
{
ServiceManagerAidl4* self = SERVICE_MANAGER_AIDL4(object);
+ g_mutex_clear(&self->mutex);
g_hash_table_destroy(self->objects);
G_OBJECT_CLASS(service_manager_aidl4_parent_class)->finalize(object);
}
@@ -216,6 +238,7 @@
service_manager_aidl4_init(
ServiceManagerAidl4* self)
{
+ g_mutex_init(&self->mutex);
self->objects = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify) gbinder_remote_object_unref);
}
@@ -226,6 +249,28 @@
ServiceManagerAidl4Class* klass)
{
G_OBJECT_CLASS(klass)->finalize = service_manager_aidl4_finalize;
+ klass->can_handle_transaction =
+ servicemanager_aidl4_can_handle_transaction;
+ klass->handle_looper_transaction =
+ servicemanager_aidl4_handle_looper_transaction;
+}
+
+static
+ServiceManagerAidl4*
+servicemanager_aidl4_new(
+ const char* dev)
+{
+ ServiceManagerAidl4* self = g_object_new(SERVICE_MANAGER_AIDL4_TYPE, NULL);
+ GBinderLocalObject* obj = GBINDER_LOCAL_OBJECT(self);
+ GBinderIpc* ipc = gbinder_ipc_new(dev, NULL);
+ const int fd = gbinder_driver_fd(ipc->driver);
+
+ gbinder_local_object_init_base(obj, ipc, servicemanager_aidl_ifaces,
+ NULL, NULL);
+ test_binder_register_object(fd, obj, SVCMGR_HANDLE);
+ gbinder_ipc_register_local_object(ipc, obj);
+ gbinder_ipc_unref(ipc);
+ return self;
}
/*==========================================================================*
@@ -288,7 +333,7 @@
{
test_binder_unregister_objects(test->fd);
gbinder_local_object_unref(test->object);
- gbinder_local_object_drop(GBINDER_LOCAL_OBJECT(test->service));
+ gbinder_local_object_unref(GBINDER_LOCAL_OBJECT(test->service));
gbinder_servicemanager_unref(test->client);
test_binder_exit_wait(&test_opt, test->loop);
remove(test->config_file);
|