sssd_dbus_connection.c revision d87e960c17d7598781cf032d06ba03a3ecadbfa2
919ca0cd7bf1dee3c8021e1c80bd699c7a386001Andrew Forrest Simo Sorce <ssorce@redhat.com>
919ca0cd7bf1dee3c8021e1c80bd699c7a386001Andrew Forrest Stephen Gallagher <sgallagh@redhat.com>
919ca0cd7bf1dee3c8021e1c80bd699c7a386001Andrew Forrest Copyright (C) 2009 Red Hat
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley This program is free software; you can redistribute it and/or modify
919ca0cd7bf1dee3c8021e1c80bd699c7a386001Andrew Forrest it under the terms of the GNU General Public License as published by
919ca0cd7bf1dee3c8021e1c80bd699c7a386001Andrew Forrest the Free Software Foundation; either version 3 of the License, or
919ca0cd7bf1dee3c8021e1c80bd699c7a386001Andrew Forrest (at your option) any later version.
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley This program is distributed in the hope that it will be useful,
919ca0cd7bf1dee3c8021e1c80bd699c7a386001Andrew Forrest but WITHOUT ANY WARRANTY; without even the implied warranty of
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley GNU General Public License for more details.
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley You should have received a copy of the GNU General Public License
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley along with this program. If not, see <http://www.gnu.org/licenses/>.
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Rileystatic int sbus_auto_reconnect(struct sbus_connection *conn);
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Rileystatic void sbus_dispatch(struct tevent_context *ev,
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley conn = talloc_get_type(data, struct sbus_connection);
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley DEBUG(SSSDBG_TRACE_ALL, "dbus conn: %p\n", dbus_conn);
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley DEBUG(SSSDBG_TRACE_FUNC, "SBUS is reconnecting. Deferring.\n");
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley /* Currently trying to reconnect, defer dispatch for 30ms */
36a02738d49e7ba01c12b9e37beb841cb277417dKohei Tamura new_event = tevent_add_timer(ev, conn, tv, sbus_dispatch, conn);
36a02738d49e7ba01c12b9e37beb841cb277417dKohei Tamura DEBUG(SSSDBG_FATAL_FAILURE,"Could not defer dispatch!\n");
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley if ((!dbus_connection_get_is_connected(dbus_conn)) &&
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley /* Attempt to reconnect automatically */
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley DEBUG(SSSDBG_CRIT_FAILURE, "Performing auto-reconnect\n");
36a02738d49e7ba01c12b9e37beb841cb277417dKohei Tamura DEBUG(SSSDBG_FATAL_FAILURE, "Cannot start auto-reconnection.\n");
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley (!dbus_connection_get_is_connected(dbus_conn))) {
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley DEBUG(SSSDBG_MINOR_FAILURE,"Connection is not open for dispatching.\n");
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley * Free the connection object.
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley * This will invoke the destructor for the connection
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley /* Dispatch only once each time through the mainloop to avoid
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley * starving other features
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley ret = dbus_connection_get_dispatch_status(dbus_conn);
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley /* If other dispatches are waiting, queue up the dispatch function
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley * for the next loop.
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley ret = dbus_connection_get_dispatch_status(dbus_conn);
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley new_event = tevent_add_timer(ev, conn, tv, sbus_dispatch, conn);
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley DEBUG(SSSDBG_OP_FAILURE,"Could not add dispatch event!\n");
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley /* TODO: Calling exit here is bad */
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley/* dbus_connection_wakeup_main
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley * D-BUS makes a callback to the wakeup_main function when
36a02738d49e7ba01c12b9e37beb841cb277417dKohei Tamura * it has data available for dispatching.
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley * In order to avoid blocking, this function will create a now()
36a02738d49e7ba01c12b9e37beb841cb277417dKohei Tamura * timed event to perform the dispatch during the next iteration
3b96b9949ee573b761bdb4e5cc8cf7582c2747c2Rich Riley * through the mainloop
int connection_type,
int ret;
return EIO;
return ret;
return ret;
if (!dbret) {
return EIO;
if (!dbret) {
return EIO;
return EOK;
int ret;
if (!dbus_conn) {
return EIO;
return ret;
* Referencing conn->dbus.conn */
void *user_data)
const char *msg_method;
const char *path;
const char *msg_interface;
const char *sender;
if (!user_data) {
return DBUS_HANDLER_RESULT_NEED_MEMORY;
return DBUS_HANDLER_RESULT_HANDLED;
struct sbus_request);
const char *msg_method;
const char *msg_interface;
if (!method) {
goto fail;
} else if (!handler_fn) {
goto fail;
goto fail;
goto fail;
goto fail;
if (handler_data) {
fail:
NULL);
int ret;
goto failed;
while (iter) {
iter);
if (!dbret) {
goto failed;
if (!te) {
return EIO;
if (!te) {
return EIO;
return EOK;
int max_retries,
void *pvt)
int timeout_ms,
void *pvt,
if (!dbret) {
return ENOMEM;
if (pending_reply) {
if (!dbret) {
return ENOMEM;
if(pending) {
return EOK;
return EAGAIN;
int timeout_ms,
void *pvt,
if (!dbus_conn) {
return ENOTCONN;
unsigned long uid,
void *data)
return TRUE;
return FALSE;