GError* err = nullptr;
GDBusMessage* reply = g_dbus_connection_send_message_with_reply_finish(conn,
res, &err);
-
- if (err && err->code == G_IO_ERROR_CANCELLED) {
- g_error_free(err);
- _E("IO error cancelled");
+ if (reply == nullptr) {
+ if (err) {
+ if (err->code == G_IO_ERROR_CANCELLED)
+ _E("IO error cancelled");
+ g_error_free(err);
+ } else {
+ _E("g_dbus_connection_send_message_with_reply_finish() is failed");
+ }
return;
}
+ auto reply_ptr = std::unique_ptr<GDBusMessage, decltype(g_object_unref)*>(
+ reply, g_object_unref);
auto* ptr = static_cast<std::weak_ptr<FdBroker>*>(user_data);
auto broker = ptr->lock();
if (broker == nullptr) {
}
IEventWatcher* watcher = broker->watcher_;
-
- if (err) {
- // LCOV_EXCL_START
- watcher->OnPortDisconnected(true);
+ if (g_dbus_message_to_gerror(reply, &err)) {
+ _E("Failed to send message. error(%s)", err->message);
g_error_free(err);
+ watcher->OnPortDisconnected(true);
if (broker->cancellable_) {
_W("Cancel the send request");
g_cancellable_cancel(broker->cancellable_);
broker->cancellable_ = nullptr;
}
return;
- // LCOV_EXCL_STOP
- }
-
- if (reply == nullptr) {
- _W("Null reply"); // LCOV_EXCL_LINE
- return; // LCOV_EXCL_LINE
}
GVariant* reply_body = g_dbus_message_get_body(reply);
if (reply_body == nullptr) {
- // LCOV_EXCL_START
_E("g_dbus_message_get_body() is failed");
watcher->OnPortDisconnected();
- g_object_unref(reply);
return;
- // LCOV_EXCL_STOP
}
int ret;
g_variant_get(reply_body, "(i)", &ret);
- g_object_unref(reply);
if (ret != 0) {
_E("Access Denied[sender_appid : %s]", broker->watch_appid_.c_str());
watcher->OnPortRejected(RPC_PORT_ERROR_PERMISSION_DENIED);