Example #1
0
static void
server_timeout_callback (DBusTimeout   *timeout,
                         void          *data)
{
    /* can return FALSE on OOM but we just let it fire again later */
    dbus_timeout_handle (timeout);
}
Example #2
0
static gboolean
pcmk_dbus_timeout_dispatch(gpointer data)
{
    crm_info("Timeout %p expired", data);
    dbus_timeout_handle(data);
    return FALSE;
}
Example #3
0
int bus_loop_dispatch(int fd) {
        int n;
        struct epoll_event event;
        EpollData *d;

        assert(fd >= 0);

        zero(event);

        n = epoll_wait(fd, &event, 1, 0);
        if (n < 0)
                return errno == EAGAIN || errno == EINTR ? 0 : -errno;

        assert_se(d = event.data.ptr);

        if (d->is_timeout) {
                DBusTimeout *t = d->object;

                if (dbus_timeout_get_enabled(t))
                        dbus_timeout_handle(t);
        } else {
                DBusWatch *w = d->object;

                if (dbus_watch_get_enabled(w))
                        dbus_watch_handle(w, bus_events_to_flags(event.events));
        }

        return 0;
}
static gboolean
timeout_handler_dispatch (gpointer      data)
{
	TimeoutHandler *handler = data;
	dbus_timeout_handle (handler->timeout);
	return TRUE;
}
Example #5
0
/**
 * Callback for handling a D-Bus timeout.
 */
static bool
cdbus_callback_handle_timeout(session_t *ps, timeout_t *ptmout) {
  assert(ptmout && ptmout->data);
  if (ptmout && ptmout->data)
    return dbus_timeout_handle(ptmout->data);

  return false;
}
Example #6
0
static Eina_Bool timeout_handler_dispatch(void *data)
{
	struct timeout_handler *to_handler = data;

	dbus_timeout_handle(to_handler->timeout);

	return EINA_FALSE;
}
Example #7
0
static void timeout_cb(void* d) {
	/* E_DEBUG(E_STRLOC ": timeout_cb()\n"); */

	EdbusConnImpl* dc = (EdbusConnImpl*)d;
	E_ASSERT(dc != NULL);
	E_ASSERT(dc->timeout != NULL);

	dbus_timeout_handle(dc->timeout);
}
Example #8
0
static int weston_dbus_dispatch_timeout(void *data)
{
	DBusTimeout *timeout = data;

	if (dbus_timeout_get_enabled(timeout))
		dbus_timeout_handle(timeout);

	return 0;
}
Example #9
0
File: timeout.c Project: dodo/ldbus
static int ldbus_timeout_handle(lua_State *L) {
	DBusTimeout *timeout = check_DBusTimeout(L, 1);
	if (timeout == NULL) {
		lua_pushnil(L);
	} else {
		lua_pushboolean(L, dbus_timeout_handle(timeout));
	}
	return 1;
}
Example #10
0
File: dbus.cpp Project: nyorain/iro
int DBusHandler::Callbacks::dispatchTimeout(void* data)
{
   DBusTimeout* timeout = (DBusTimeout*) data;

   if (dbus_timeout_get_enabled(timeout))
      dbus_timeout_handle(timeout);

   return 0;
}
Example #11
0
void
timeout_handler_cb (hidval data) {
    TimeoutHandler *handler;
    handler = (TimeoutHandler *)data.ptr;
    // Re-add the timeout, as PCB will remove the current one
    // Do this before calling to dbus, incase DBus removes the timeout.
    // We can't touch handler after libdbus has been run for this reason.
    handler->pcb_timer =
        gui->add_timer (timeout_handler_cb, handler->interval, data);
    dbus_timeout_handle (handler->dbus_timeout);
}
Example #12
0
static gboolean timeout_handler_dispatch(gpointer data)
{
	timeout_handler_t *handler = data;

	/* if not enabled should not be polled by the main loop */
	if (dbus_timeout_get_enabled(handler->timeout) != TRUE)
		return FALSE;

	dbus_timeout_handle(handler->timeout);

	return FALSE;
}
Example #13
0
static gboolean timeout_handler_dispatch(gpointer data)
{
	struct timeout_handler *handler = data;

	handler->id = 0;

	/* if not enabled should not be polled by the main loop */
	if (!dbus_timeout_get_enabled(handler->timeout))
		return FALSE;

	dbus_timeout_handle(handler->timeout);

	return FALSE;
}
static void timeout_callback(AvahiTimeout *avahi_timeout, void *userdata) {
    TimeoutData *timeout = userdata;

    assert(avahi_timeout);
    assert(timeout);

    timeout_data_ref(timeout);

    dbus_timeout_handle(timeout->dbus_timeout);
    /* Ignore the return value */

    if (timeout->avahi_timeout)
        update_timeout(timeout);

    timeout_data_unref(timeout);
}
Example #15
0
static void
timeout_handler(EV_P_ struct ev_timer *ev, int revents)
{
	struct timeout *t = (struct timeout *)ev;

	(void)revents;

	lem_debug("timeout");

	(void)dbus_timeout_handle(t->timeout);

	if (dbus_connection_get_dispatch_status(t->conn)
	    == DBUS_DISPATCH_DATA_REMAINS) {
		while (dbus_connection_dispatch(t->conn)
		       == DBUS_DISPATCH_DATA_REMAINS);
	}
}
Example #16
0
/* pa_time_event_cb_t timer event handler */
static void handle_time_event(pa_mainloop_api *ea, pa_time_event* e, const struct timeval *t, void *userdata) {
    struct timeval tv;
    struct timeout_data *d = userdata;

    pa_assert(d);
    pa_assert(d->connection);

    if (dbus_timeout_get_enabled(d->timeout)) {
        /* Restart it for the next scheduled time. We do this before
         * calling dbus_timeout_handle() to make sure that the time
         * event is still around. */
        ea->time_restart(e, pa_timeval_rtstore(&tv,
                                               pa_timeval_load(t) + dbus_timeout_get_interval(d->timeout) * PA_USEC_PER_MSEC,
                                               d->connection->use_rtclock));

        dbus_timeout_handle(d->timeout);
    }
}
Example #17
0
/**
 * ProcessTimeouts() handles DBus timeouts
 *
 * This function must be called with p_sys->lock locked
 *
 * @param intf_thread_t *p_intf This interface thread state
 * @param DBusTimeout **p_timeouts List of timeouts to process
 * @param int i_timeouts Size of p_timeouts
 */
static void ProcessTimeouts( intf_thread_t *p_intf,
                             DBusTimeout  **p_timeouts, int i_timeouts )
{
    VLC_UNUSED( p_intf );

    for( int i = 0; i < i_timeouts; i++ )
    {
        timeout_info_t *p_info = NULL;

        p_info = (timeout_info_t*) dbus_timeout_get_data( p_timeouts[i] );

        if( !dbus_timeout_get_enabled( p_info->p_timeout ) )
            continue;

        if( p_info->i_remaining > 0 )
            continue;

        dbus_timeout_handle( p_info->p_timeout );
        p_info->i_remaining = dbus_timeout_get_interval( p_info->p_timeout );
    }
}
Example #18
0
File: dbus.c Project: etix/vlc
/**
 * Process pending D-Bus timeouts.
 *
 * @note Interface lock must be held.
 */
static void process_timeouts(intf_thread_t *intf)
{
    intf_sys_t *sys = intf->p_sys;

    for (int i = 0; i < vlc_array_count(sys->p_timeouts); i++)
    {
        DBusTimeout *to = vlc_array_item_at_index(sys->p_timeouts, i);

        if (!dbus_timeout_get_enabled(to))
            continue;

        mtime_t *expiry = dbus_timeout_get_data(to);
        if (*expiry > mdate())
            continue;

        expiry += UINT64_C(1000) * dbus_timeout_get_interval(to);
        vlc_mutex_unlock(&sys->lock);

        dbus_timeout_handle(to);

        vlc_mutex_lock(&sys->lock);
        i = -1; /* lost track of state, restart from beginning */
    }
}
Example #19
0
void DBus_Timeout(ClientData timeout)
{
   dbus_timeout_handle(timeout);
}
Example #20
0
static void process_timeout(void *eloop_ctx, void *sock_ctx)
{
	DBusTimeout *timeout = sock_ctx;

	dbus_timeout_handle(timeout);
}
Example #21
0
void QDBusConnectionPrivate::timerEvent(QTimerEvent *e)
{
    DBusTimeout *timeout = timeouts[e->timerId()];
    dbus_timeout_handle(timeout);
}
void Integrator::slotTimeout( DBusTimeout *timeout )
{
  dbus_timeout_handle( timeout );
}
Example #23
0
int dbus_selector(char *param, int altsel )
{
   DBusConnection* conn;
   DBusError err;
   int ret = 1; /* default fail */

    watched_chgevt_setup();


        char * destarray[4] = { "test.selector.server", "test.selector.client",
                                "test.unknown.user1", "test.unknown.user2" };
        char * deststr = destarray[0];
        if ( altsel != 0 ) {
            deststr = destarray[1];
            lastregtime = time(NULL);
        }

   printf("Accepting method calls and signals\n");

   // initialise the error
   dbus_error_init(&err);
  
   // connect to the bus and check for errors
   conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
   if (dbus_error_is_set(&err)) {
      fprintf(stderr, "Connection Error (%s)\n", err.message);
      dbus_error_free(&err);
   }
   if (NULL == conn) {
      fprintf(stderr, "Connection Null\n");
      return ret; /* ret=1 fail */
   }

   // request our name on the bus and check for errors
   ret = dbus_bus_request_name(conn, deststr /* "test.selector.server" */, 
                               DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
   if (dbus_error_is_set(&err)) {
      fprintf(stderr, "Name Error (%s)\n", err.message);
      dbus_error_free(&err);
   }
   if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
      fprintf(stderr, "Not Primary Owner (%d)\n", ret);
      return ret; /* ret=1 fail */
   }

   // add a rule for which messages we want to see
   dbus_bus_add_match(conn, "type='signal',interface='test.signal.Type'", &err); 
                                           // see signals from the given interface
   dbus_connection_flush(conn); /* Note: this would block */
   if (dbus_error_is_set(&err)) {
      fprintf(stderr, "Match Error (%s)\n", err.message);
      return ret; /* ret=1 fail */
   }
   printf("Match signal rule sent\n");

    /* setup watch and timeout */
    if (!dbus_connection_set_watch_functions(conn, add_watch, remove_watch,
                                             toggle_watch, NULL, NULL)) {
        printf(" ERROR dbus_connection_set_watch_functions() failed\n");
        return ret; /* ret=1 fail */
    }
    if (!dbus_connection_set_timeout_functions(conn, add_timeout,
                                               remove_timeout, toggle_timeout,
                                               NULL, NULL)) {
        printf(" ERROR dbus_connection_set_timeout_functions() failed\n");
        return ret; /* ret=1 fail */
    }

    /* the selector loop */
    ret = 0; /* default success */
    struct timeval local_to_startv = {0,0}; /* timeout saved locally */
    DBusPendingCall* pending = NULL; /* keep track of the outstanding rpc call */
    while(ret == 0) {

        /* the selector loop stage 1, setup for select() call. 
         * in this stage no dbus watch/timeout change should happen 
         */

        #define DEFAULT_SELECT_LOOP_MS (5500)
        int modified_timeout = 0; /* yes or no */

        fd_set rfds, wfds, efds;
        struct timeval timeoutval = {
                           DEFAULT_SELECT_LOOP_MS/1000, 
                           (DEFAULT_SELECT_LOOP_MS%1000)*1000 };
        int nfds = 1;
        int rc = 0;

        printf("\n");
        FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&efds);
        if ( watched_watch != NULL ) {
            if ( watched_rd_fd ) { 
                FD_SET(watched_rd_fd, &rfds);
                FD_SET(watched_rd_fd, &efds);
                if ( nfds <= watched_rd_fd ) { nfds = watched_rd_fd + 1; } 
                printf(" SELECT nfds %d  rdfd %d\n", nfds, watched_rd_fd);
            }
            if ( watched_wr_fd ) { 
                FD_SET(watched_wr_fd, &wfds);
                FD_SET(watched_wr_fd, &efds);
                if ( nfds <= watched_wr_fd ) { nfds = watched_wr_fd + 1; } 
                printf(" SELECT nfds %d  wrfd %d\n", nfds, watched_wr_fd);
            }
        }
        if ( watched_chgevt_fds[0] != 0 ) {
            FD_SET(watched_chgevt_fds[0], &rfds);
            FD_SET(watched_chgevt_fds[0], &efds);
        }

        if ( watched_timeout != NULL ) {
            struct timeval startv = watched_timeout_start_tv;
            unsigned int setv = watched_timeout_setv;
            unsigned int lastv = watched_timeout_lastv;

            struct timeval tnow = {0,0};
            unsigned int tnowms = 0;
            unsigned int toms = 0;
            unsigned int tdiff = 0;

            gettimeofday(&tnow, NULL);
            tnowms = TIME_TV_TO_MS(tnow);

            if ( startv.tv_sec != local_to_startv.tv_sec || 
                 startv.tv_usec != local_to_startv.tv_sec   ) 
            { /* new timeout */
                local_to_startv = startv;
            }
            if ( lastv > tnowms ) {
                tnowms += TIMEOUT_MOD_MS;
            }
            toms = lastv + setv + 1;
                             /* add 1 to make up for rounding loss */
            if ( toms > tnowms ) {
                tdiff = toms - tnowms; /* ms till timeout */
            }
            if ( tdiff < DEFAULT_SELECT_LOOP_MS ) {
                /* revise timeout value */
                timeoutval.tv_sec = tdiff/1000;
                timeoutval.tv_usec = (tdiff%1000)*1000;
                modified_timeout = 1; /* yes */
            }
        }

        if ( modified_timeout ) {
            printf(" SELECT with nfds %d ... new tiemout %lu.%03lu\n", 
                         nfds, timeoutval.tv_sec, timeoutval.tv_usec/1000);
        } else {
            printf(" SELECT with nfds %d...\n", nfds);
        }

        rc = select(nfds, &rfds, &wfds, &efds, &timeoutval);
        if ( rc < 0 ) {
            printf(" SELECT returned error %d\n", rc);
            break;
        }

        /* the selector loop stage 2, dbus operation. 
         * in this stage dbus watch/timeout could change.
         */

        /* check timeout */
        if ( watched_timeout != NULL ) {
            struct timeval startv = watched_timeout_start_tv;
            unsigned int setv = watched_timeout_setv;
            unsigned int lastv = watched_timeout_lastv;
            struct timeval tnow = {0,0}; unsigned int tnowms = 0, toms = 0;

            gettimeofday(&tnow, NULL);
            tnowms = TIME_TV_TO_MS(tnow);

            if ( startv.tv_sec == local_to_startv.tv_sec && 
                 startv.tv_usec == local_to_startv.tv_sec   ) 
            { /* same timeout */
                if ( lastv > tnowms ) {
                    tnowms += TIMEOUT_MOD_MS;
                }
                toms = lastv + setv + 1;
                             /* add 1 to make up for rounding loss */
                if ( toms >= tnowms ) {
                    watched_timeout_lastv = tnowms%TIMEOUT_MOD_MS;
                    printf(" HANDLING dbus handle timeout %p\n", 
                           watched_timeout);
                    dbus_timeout_handle(watched_timeout);
                    printf(" HANDLING dbus handle timeout %p done\n", 
                           watched_timeout);
                }
            } /* else if not the same timeout as before select() skip for now */
        }

        /* self initiated rpc call */
        if ( altsel ) {
            unsigned int tmnow = time(NULL);
            unsigned int tmdiff = tmnow - lastregtime;
            if ( tmdiff > 10 ) { /* send a rpc evey 10 seconds */

                struct timeval tmn = {0,0}; gettimeofday(&tmn,NULL);
                printf(" RPC call time  %lu.%06lu\n", tmn.tv_sec, tmn.tv_usec);
                tmn0 = tmn;

                dbus_selector_process_post_send(conn, param, &pending);
                lastregtime = tmnow;
            }
        }

        /* select() returned no event */
        if ( rc == 0 ) {
            printf(" SELECT returned rc 0 \n");
            continue;
        }

        /* some event happened according to select() */
        printf(" SELECT returned rc %d \n", rc);
        if ( watched_watch != NULL ) {
            if ( watched_rd_fd ) { 
                if ( FD_ISSET(watched_rd_fd, &rfds) ) {
                    printf(" HANDLING calls watch_handle\n");
                    dbus_watch_handle(watched_watch, DBUS_WATCH_READABLE);
                    printf(" HANDLING calls process_recv\n");
                    dbus_selector_process_recv(conn, pending==NULL?0:1,
                                                     &pending);
                    printf(" HANDLING done process_recv\n");
                }
                if ( FD_ISSET(watched_rd_fd, &efds) ) {
                    printf(" HANDLING EXCEPTION with rd fd %d \n",
                           watched_rd_fd);
                }
            }
            if ( watched_wr_fd ) { 
                if ( FD_ISSET(watched_wr_fd, &wfds) ) {
                    dbus_watch_handle(watched_watch, DBUS_WATCH_WRITABLE);
                }
                if ( FD_ISSET(watched_wr_fd, &efds) ) {
                    printf(" HANDLING EXCEPTION with wr fd %d \n",
                           watched_wr_fd);
                }
            }
        }

        /* chgevt pipe */
        if ( watched_chgevt_fds[0] != 0 && FD_ISSET(watched_chgevt_fds[0], &rfds) ) {
            int chgevt = watched_chgevt_get();
            switch (chgevt) {
            case CHGEVT_ADD_WATCH: 
                printf(" HANDLING chgevt 1 consumed \n"); break;
            case CHGEVT_ADD_TIMEOUT: 
                printf(" HANDLING chgevt 2 consumed \n"); break;
            default: 
                printf(" HANDLING chgevt n=%d consumed \n", chgevt); break;
            }
        }
    }
   return ret;
}
bool DBusTimeout::dispatch() {
    recalculateDueTime();
    dbus_timeout_handle(libdbusTimeout_);
    return true;
}
Example #25
0
static void  asdbus_handle_timer (void *vdata) {
	show_debug(__FILE__,__FUNCTION__,__LINE__,"dbus_timeout_handle data=%p\n", vdata);
	dbus_timeout_handle (vdata);
}