summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2014-04-29 23:39:45 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-05-13 21:46:41 +0200
commit393099fb7caa2c128277e26ba3463aa7f95a0ebb (patch)
tree1f9785c0a4edec910e345d587be57ddfe20b2ec2
parent87729e3a6c56383642a8d3a86b2856487f2ee064 (diff)
downloadsssd-393099fb7caa2c128277e26ba3463aa7f95a0ebb.tar.gz
sssd-393099fb7caa2c128277e26ba3463aa7f95a0ebb.tar.xz
sssd-393099fb7caa2c128277e26ba3463aa7f95a0ebb.zip
SBUS: Split out dbus_conn_send
Split dbus_conn_send out of sbus_conn_send to be able to call DBus messages without having a full sbus connection. This function is available to the sbus code only, consumers of sbus (responders and providers) should use sbus_conn_send. Reviewed-by: Pavel Březina <pbrezina@redhat.com> Reviewed-by: Stef Walter <stefw@redhat.com>
-rw-r--r--src/sbus/sssd_dbus_connection.c56
-rw-r--r--src/sbus/sssd_dbus_private.h11
2 files changed, 45 insertions, 22 deletions
diff --git a/src/sbus/sssd_dbus_connection.c b/src/sbus/sssd_dbus_connection.c
index f27474745..7ea70efa5 100644
--- a/src/sbus/sssd_dbus_connection.c
+++ b/src/sbus/sssd_dbus_connection.c
@@ -701,32 +701,16 @@ bool sbus_conn_disconnecting(struct sbus_connection *conn)
return false;
}
-/*
- * Send a message across the SBUS
- * If requested, the DBusPendingCall object will
- * be returned to the caller.
- *
- * This function will return EAGAIN in the event
- * that the connection is not open for
- * communication.
- */
-int sbus_conn_send(struct sbus_connection *conn,
- DBusMessage *msg,
- int timeout_ms,
- DBusPendingCallNotifyFunction reply_handler,
- void *pvt,
- DBusPendingCall **pending)
+int sss_dbus_conn_send(DBusConnection *dbus_conn,
+ DBusMessage *msg,
+ int timeout_ms,
+ DBusPendingCallNotifyFunction reply_handler,
+ void *pvt,
+ DBusPendingCall **pending)
{
DBusPendingCall *pending_reply;
- DBusConnection *dbus_conn;
dbus_bool_t dbret;
- dbus_conn = sbus_get_connection(conn);
- if (!dbus_conn) {
- DEBUG(SSSDBG_CRIT_FAILURE, "D-BUS not connected\n");
- return ENOTCONN;
- }
-
dbret = dbus_connection_send_with_reply(dbus_conn, msg,
&pending_reply,
timeout_ms);
@@ -770,6 +754,34 @@ int sbus_conn_send(struct sbus_connection *conn,
return EAGAIN;
}
+/*
+ * Send a message across the SBUS
+ * If requested, the DBusPendingCall object will
+ * be returned to the caller.
+ *
+ * This function will return EAGAIN in the event
+ * that the connection is not open for
+ * communication.
+ */
+int sbus_conn_send(struct sbus_connection *conn,
+ DBusMessage *msg,
+ int timeout_ms,
+ DBusPendingCallNotifyFunction reply_handler,
+ void *pvt,
+ DBusPendingCall **pending)
+{
+ DBusConnection *dbus_conn;
+
+ dbus_conn = sbus_get_connection(conn);
+ if (!dbus_conn) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "D-BUS not connected\n");
+ return ENOTCONN;
+ }
+
+ return sss_dbus_conn_send(dbus_conn, msg, timeout_ms,
+ reply_handler, pvt, pending);
+}
+
void sbus_conn_send_reply(struct sbus_connection *conn, DBusMessage *reply)
{
dbus_connection_send(conn->dbus.conn, reply, NULL);
diff --git a/src/sbus/sssd_dbus_private.h b/src/sbus/sssd_dbus_private.h
index 4916700b5..58b385b71 100644
--- a/src/sbus/sssd_dbus_private.h
+++ b/src/sbus/sssd_dbus_private.h
@@ -115,4 +115,15 @@ sbus_request_invoke_or_finish(struct sbus_request *dbus_req,
void *handler_data,
sbus_method_invoker_fn invoker_fn);
+/* A low-level, private variant of sbus_conn_send that accepts just
+ * DBusConnection. It should never be used outside sbus code, responders
+ * and back ends should use sbus_conn_send!
+ */
+int sss_dbus_conn_send(DBusConnection *dbus_conn,
+ DBusMessage *msg,
+ int timeout_ms,
+ DBusPendingCallNotifyFunction reply_handler,
+ void *pvt,
+ DBusPendingCall **pending);
+
#endif /* _SSSD_DBUS_PRIVATE_H_ */