5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek Simo Sorce <ssorce@redhat.com>
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek Stephen Gallagher <sgallagh@redhat.com>
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek Copyright (C) 2009 Red Hat
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek This program is free software; you can redistribute it and/or modify
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek it under the terms of the GNU General Public License as published by
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek the Free Software Foundation; either version 3 of the License, or
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek (at your option) any later version.
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek This program is distributed in the hope that it will be useful,
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek GNU General Public License for more details.
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek You should have received a copy of the GNU General Public License
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozekstatic int sbus_auto_reconnect(struct sbus_connection *conn);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozekstatic void sbus_dispatch(struct tevent_context *ev,
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek conn = talloc_get_type(data, struct sbus_connection);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek DEBUG(SSSDBG_TRACE_ALL, "dbus conn: %p\n", dbus_conn);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek DEBUG(SSSDBG_TRACE_FUNC, "SBUS is reconnecting. Deferring.\n");
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek /* Currently trying to reconnect, defer dispatch for 30ms */
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek new_event = tevent_add_timer(ev, conn, tv, sbus_dispatch, conn);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek DEBUG(SSSDBG_FATAL_FAILURE,"Could not defer dispatch!\n");
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek if ((!dbus_connection_get_is_connected(dbus_conn)) &&
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek /* Attempt to reconnect automatically */
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Performing auto-reconnect\n");
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek DEBUG(SSSDBG_FATAL_FAILURE, "Cannot start auto-reconnection.\n");
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek (!dbus_connection_get_is_connected(dbus_conn))) {
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek DEBUG(SSSDBG_MINOR_FAILURE,"Connection is not open for dispatching.\n");
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek * Free the connection object.
4e5e846de22407f825fe3b4040d79606818a2419Jakub Hrozek * This will invoke the destructor for the connection
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek /* Dispatch only once each time through the mainloop to avoid
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek * starving other features
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek ret = dbus_connection_get_dispatch_status(dbus_conn);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek /* If other dispatches are waiting, queue up the dispatch function
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek * for the next loop.
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek ret = dbus_connection_get_dispatch_status(dbus_conn);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek new_event = tevent_add_timer(ev, conn, tv, sbus_dispatch, conn);
5eda23c28c582b43b2a0a165b1750f3875c0fa84Jakub Hrozek DEBUG(SSSDBG_OP_FAILURE,"Could not add dispatch event!\n");
int connection_type,
return EIO;
return EIO;
return EIO;
return EIO;
return ret;
NULL);
if (dbret == false) {
return EIO;
return ret;
if (!dbret) {
return EIO;
if (!dbret) {
return EIO;
return EOK;
if (!dbus_conn) {
return EIO;
return ret;
* Referencing conn->dbus.conn */
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;