rpc_port_proxy_##_callback_s callback;
void *user_data;
GList *delegates;
+ GRecMutex mutex;
};
)__c_cb";
rpc_port_parcel_h parcel_received;
int cmd = -1;
+ g_rec_mutex_lock(&handle->mutex);
rpc_port_parcel_create_from_port(&parcel_received, handle->port);
rpc_port_parcel_read_int32(parcel_received, &cmd);
if (cmd != ##_METHOD_Callback) {
dlog_print(DLOG_ERROR, LOG_TAG, "Invalid protocol");
rpc_port_parcel_destroy(parcel_received);
+ g_rec_mutex_unlock(&handle->mutex);
return;
}
__##_process_received_event(&handle->delegates, parcel_received);
rpc_port_parcel_destroy(parcel_received);
dlog_print(DLOG_INFO, LOG_TAG, "[__RPC_PORT__] endpoint(%s), port_name(%s)", endpoint, port_name);
+ g_rec_mutex_unlock(&handle->mutex);
}
)__c_cb";
return NULL;
}
+ g_rec_mutex_init(&handle->mutex);
+
handle->callback = *callback;
handle->user_data = user_data;
if (!h)
return;
+ g_rec_mutex_clear(&h->mutex);
+
if (h->delegates)
g_list_free_full(h->delegates, free);
+
if (h->proxy)
rpc_port_proxy_destroy(h->proxy);
+
if (h->stub_appid)
free(h->stub_appid);
+
free(h);
}
)__c_cb";
const char CB_RECEIVE_BLOCK[] =
R"__c_cb(
+g_rec_mutex_lock(&h->mutex);
do {
rpc_port_parcel_h parcel_received;
$$
$$
rpc_port_parcel_destroy(parcel_received);
} while (0);
+g_rec_mutex_unlock(&h->mutex);
)__c_cb";