/*
Authors:
Simo Sorce <ssorce@redhat.com>
Stephen Gallagher <sgallagh@redhat.com>
Copyright (C) 2009 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sbus/sssd_dbus.h"
#include "sbus/sssd_dbus_private.h"
#include "sbus/sssd_dbus_meta.h"
struct tevent_timer *te,
{
int ret;
/* Currently trying to reconnect, defer dispatch for 30ms */
}
return;
}
if ((!dbus_connection_get_is_connected(dbus_conn)) &&
(conn->max_retries != 0)) {
/* Attempt to reconnect automatically */
return;
}
return;
}
if ((conn->disconnect) ||
/*
* Free the connection object.
* This will invoke the destructor for the connection
*/
return;
}
/* Dispatch only once each time through the mainloop to avoid
* starving other features
*/
if (ret != DBUS_DISPATCH_COMPLETE) {
}
/* If other dispatches are waiting, queue up the dispatch function
* for the next loop.
*/
if (ret != DBUS_DISPATCH_COMPLETE) {
/* TODO: Calling exit here is bad */
exit(1);
}
}
}
/* dbus_connection_wakeup_main
* D-BUS makes a callback to the wakeup_main function when
* it has data available for dispatching.
* In order to avoid blocking, this function will create a now()
* timed event to perform the dispatch during the next iteration
* through the mainloop
*/
{
tv = tevent_timeval_current();
/* D-BUS calls this function when it is time to do a dispatch */
/* TODO: Calling exit here is bad */
exit(1);
}
}
/*
* integrate_connection_with_event_loop
* Set up a D-BUS connection to use the libevents mainloop
* for handling file descriptor and timed events
*/
struct tevent_context *ev,
int connection_type,
void *client_destructor_data,
struct sbus_connection **_conn)
{
int ret;
return EIO;
}
return EIO;
}
"hash table\n");
return EIO;
}
return EIO;
}
return ret;
}
/* Set up signal handler. */
NULL);
if (dbret == false) {
return EIO;
}
return ret;
}
{
/* Set up DBusWatch functions */
if (!dbret) {
"Error setting up D-BUS connection watch functions\n");
return EIO;
}
/* Set up DBusTimeout functions */
if (!dbret) {
"Error setting up D-BUS server timeout functions\n");
/* FIXME: free resources? */
return EIO;
}
/* Set up dispatch handler */
/* Set up any method_contexts passed in */
/* Attempt to dispatch immediately in case of opportunistic
* services connecting before the handlers were all up.
* If there are no messages to be dispatched, this will do
* nothing.
*/
return EOK;
}
struct sbus_connection **_conn)
{
int ret;
/* Open a shared D-BUS connection to the address */
if (!dbus_conn) {
"Failed to open connection: name=%s, message=%s\n",
return EIO;
}
/* FIXME: release resources */
}
/* Store the address for later reconnection */
return ret;
}
{
/* Private connections must be closed explicitly */
}
/* Shared and system bus connections are destroyed when their last
reference is removed */
}
else {
/* Critical Error! */
"Critical Error, connection_type is neither shared nor private!\n");
return -1;
}
/* Remove object path */
/* TODO: Remove object paths */
return 0;
}
/*
* sbus_get_connection
* Utility function to retrieve the DBusConnection object
* from a sbus_connection
*/
{
}
{
return;
}
/*******************************
* Referencing conn->dbus.conn */
/* Unregister object paths */
/* Disable watch functions */
/* Disable timeout functions */
/* Disable dispatch status function */
/* Disable wakeup main function */
/* Finalize the connection */
/* Unreferenced conn->dbus_conn *
******************************/
}
struct tevent_timer *te,
{
int ret;
/* We successfully reconnected. Set up mainloop integration. */
goto failed;
}
/* Re-register object paths */
/* Reset retries to 0 to resume dispatch processing */
/* Notify the owner of this connection that the
* reconnection was successful
*/
return;
}
/* Reconnection failed, try again in a few seconds */
"Failed to open connection: name=%s, message=%s\n",
/* Check if we've passed our last chance or if we've lost track of
* our retry count somehow
*/
}
/* Wait 3 seconds before the second reconnect attempt */
}
/* Wait 10 seconds before the third reconnect attempt */
}
else {
/* Wait 30 seconds before all subsequent reconnect attempts */
}
if (!te) {
}
}
/* This function will free and recreate the sbus_connection,
* calling functions need to be aware of this (and whether
* they have attached a talloc destructor to the
* sbus_connection.
*/
{
/* Return EIO (to tell the calling process it
* needs to create a new connection from scratch
*/
return EIO;
}
if (!te) {
return EIO;
}
return EOK;
}
/* Max retries */
int max_retries,
void *pvt)
{
}
int timeout_ms,
void *pvt,
{
if (!dbret) {
/*
* Critical Failure
* Insufficient memory to send message
*/
return ENOMEM;
}
if (pending_reply) {
/* Set up the reply handler */
if (!dbret) {
/*
* Critical Failure
* Insufficient memory to create pending call notify
*/
return ENOMEM;
}
if(pending) {
*pending = pending_reply;
}
return EOK;
}
/* If pending_reply is NULL, the connection was not
* open for sending.
*/
/* TODO: Create a callback into the reconnection logic so this
* request is invoked when the connection is re-established
*/
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 timeout_ms,
void *pvt,
{
if (!dbus_conn) {
return ENOTCONN;
}
}
{
}
unsigned long uid,
void *data)
{
return TRUE;
}
return FALSE;
}
{
}
{
/* Should never happen! */
return NULL;
}
return conn->client_destructor_data;
}