Beispiel #1
0
static void
timeout_toggle(DBusTimeout *timeout, void *data)
{
	struct timeout *t;

	(void)data;

	lem_debug("timeout = %p, interval = %d, enabled = %s",
	          (void *)timeout,
	          dbus_timeout_get_interval(timeout),
	          dbus_timeout_get_enabled(timeout) ? "true" : "false");

	t = dbus_timeout_get_data(timeout);
	if (dbus_timeout_get_enabled(timeout)) {
		ev_tstamp interval =
			((ev_tstamp)dbus_timeout_get_interval(timeout))/1000.0;

		if (ev_is_active(&t->ev))
			ev_timer_stop(EV_G_ &t->ev);

		ev_timer_set(&t->ev, interval, interval);
		ev_timer_start(EV_G_ &t->ev);
	} else
		ev_timer_stop(EV_G_ &t->ev);
}
Beispiel #2
0
static void timeout_toggled( DBusTimeout *p_timeout, void *p_data )
{
    intf_thread_t *p_intf = (intf_thread_t*) p_data;

    if( dbus_timeout_get_enabled( p_timeout ) )
        wakeup_main_loop( p_intf );
}
static dbus_bool_t addTimeout(DBusTimeout *timeout, void *data)
{
   (void)data;
   dbus_bool_t ret = FALSE;

   if(ARRAY_SIZE(gPollInfo.fds) > (unsigned int)(gPollInfo.nfds))
   {
      const int interval = dbus_timeout_get_interval(timeout);
      if ((0<interval)&&(TRUE==dbus_timeout_get_enabled(timeout)))
      {
         const int tfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
         if (-1!=tfd)
         {
            const struct itimerspec its = { .it_value= {interval/1000, interval%1000} };
            if (-1!=timerfd_settime(tfd, 0, &its, NULL))
            {
               tObjectEntry * const pEntry = &gPollInfo.objects[gPollInfo.nfds];
               pEntry->objtype = OT_TIMEOUT;
               pEntry->timeout = timeout;
               gPollInfo.fds[gPollInfo.nfds].fd = tfd;
               gPollInfo.fds[gPollInfo.nfds].events |= POLLIN;
               ++gPollInfo.nfds;
               ret = TRUE;
            }
            else
            {
               DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout - _settime() failed"), DLT_STRING(strerror(errno)) );
            }
         }
         else
         {
            DLT_LOG(gPclDLTContext, DLT_LOG_ERROR, DLT_STRING("addTimeout - _create() failed"), DLT_STRING(strerror(errno)) );
         }
      }
   }
Beispiel #4
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;
}
Beispiel #5
0
/**
 * UpdateTimeouts() updates the remaining time for each timeout and
 * returns how much time is left until the next timeout.
 *
 * This function must be called with p_sys->lock locked
 *
 * @return int The time remaining until the next timeout, in milliseconds
 * or -1 if there are no timeouts
 *
 * @param intf_thread_t *p_intf This interface thread's state
 * @param mtime_t i_loop_interval The time which has elapsed since the last
 * call to this function
 */
static int UpdateTimeouts( intf_thread_t *p_intf, mtime_t i_loop_interval )
{
    intf_sys_t *p_sys = p_intf->p_sys;
    mtime_t i_next_timeout = LAST_MDATE;
    unsigned int i_timeouts = vlc_array_count( p_sys->p_timeouts );

    if( 0 == i_timeouts )
        return -1;

    for( unsigned int i = 0; i < i_timeouts; i++ )
    {
        timeout_info_t *p_info = NULL;
        DBusTimeout    *p_timeout = NULL;
        mtime_t         i_interval = 0;

        p_timeout = vlc_array_item_at_index( p_sys->p_timeouts, i );
        i_interval = dbus_timeout_get_interval( p_timeout ) * 1000; /* µs */
        p_info = (timeout_info_t*) dbus_timeout_get_data( p_timeout );

        p_info->i_remaining -= __MAX( 0, i_loop_interval ) % i_interval;

        if( !dbus_timeout_get_enabled( p_timeout ) )
            continue;

        /* The correct poll timeout value is the shortest one
         * in the dbus timeouts list */
        i_next_timeout = __MIN( i_next_timeout,
                                __MAX( 0, p_info->i_remaining ) );
    }

    /* next timeout in milliseconds */
    return i_next_timeout / 1000;
}
Beispiel #6
0
static void efl_dbus_timeout_toggled(DBusTimeout *timeout, void *data)
{
	if (dbus_timeout_get_enabled(timeout) == TRUE)
		efl_dbus_timeout_add(timeout, data);
	else
		efl_dbus_timeout_remove(timeout, data);
}
static void timeout_toggled(DBusTimeout *timeout, void *data)
{
	if (dbus_timeout_get_enabled(timeout))
		add_timeout(timeout, data);
	else
		remove_timeout(timeout, data);
}
Beispiel #8
0
Datei: dbus.c Projekt: etix/vlc
/**
 * Computes the time until the next timeout expiration.
 * @note Interface lock must be held.
 * @return The time in milliseconds until the next expiration,
 *         or -1 if there are no pending timeouts.
 */
static int next_timeout(intf_thread_t *intf)
{
    intf_sys_t *sys = intf->p_sys;
    mtime_t next_timeout = LAST_MDATE;
    unsigned count = vlc_array_count(sys->p_timeouts);

    for (unsigned i = 0; i < count; 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 (next_timeout > *expiry)
            next_timeout = *expiry;
    }

    if (next_timeout >= LAST_MDATE)
        return -1;

    next_timeout /= 1000;

    if (next_timeout > INT_MAX)
        return INT_MAX;

    return (int)next_timeout;
}
static dbus_bool_t add_timeout(DBusTimeout *dbus_timeout, void *userdata) {
    TimeoutData *timeout;
    ConnectionData *d = userdata;
    struct timeval tv;
    dbus_bool_t b;

    assert(dbus_timeout);
    assert(d);

    if (!(timeout = avahi_new(TimeoutData, 1)))
        return FALSE;

    timeout->dbus_timeout = dbus_timeout;
    timeout->poll_api = d->poll_api;
    timeout->ref = 1;

    if ((b = dbus_timeout_get_enabled(dbus_timeout)))
        avahi_elapse_time(&tv, dbus_timeout_get_interval(dbus_timeout), 0);

    if (!(timeout->avahi_timeout = d->poll_api->timeout_new(
              d->poll_api,
              b ? &tv : NULL,
              timeout_callback,
              timeout))) {
        avahi_free(timeout);
        return FALSE;
    }

    dbus_timeout_set_data(dbus_timeout, timeout, (DBusFreeFunction) timeout_data_unref);
    return TRUE;
}
static dbus_bool_t add_timeout(DBusTimeout *t, void *data)
{
    if (!dbus_timeout_get_enabled(t))
        return TRUE;

    int ms = dbus_timeout_get_interval(t);
    if ( ms < 0 || ms > TIMEOUT_MAX_MS ) {
        ms = TIMEOUT_MAX_MS;
        if ( ms < 0 || ms > INT_MAX/2-1 ) {
            ms = INT_MAX/2-1;
        }
    }
    if ( ms < 1 ) {
        ms = 1; 
    }

    struct timeval tnow = {0,0};
    gettimeofday(&tnow, NULL);
    unsigned int tnowms = TIME_TV_TO_MS(tnow);

    printf(" TIMEOUT: add dbus timeout %p value %u ms\n", t, ms);

    watched_timeout_start_tv = tnow;
    watched_timeout_setv = ms;
    watched_timeout_lastv = tnowms;
    watched_timeout = t;

    watched_chgevt_send( CHGEVT_ADD_TIMEOUT ); 
    return TRUE;
}
Beispiel #11
0
static void edbus_toggle_timeout(DBusTimeout* timeout, void* data) {
	E_ASSERT(timeout != NULL);

	if(dbus_timeout_get_enabled(timeout))
		edbus_add_timeout(timeout, data);
	else
		edbus_remove_timeout(timeout, data);
}
void DBusTimeout::recalculateDueTime() {
    if(dbus_timeout_get_enabled(libdbusTimeout_)) {
        unsigned int intervalInMs = dbus_timeout_get_interval(libdbusTimeout_);
        dueTimeInMs_ = getCurrentTimeInMs() + intervalInMs;
    } else {
        dueTimeInMs_ = TIMEOUT_INFINITE;
    }
}
Beispiel #13
0
//utility
int adjustTimeout(DBusTimeout* timeout, wl_event_source* source)
{
   unsigned long iv = 0;
   if (dbus_timeout_get_enabled(timeout))
      iv = dbus_timeout_get_interval(timeout);

   return wl_event_source_timer_update(source, iv);
}
Beispiel #14
0
void timeout_toggled( DBusTimeout *timeout, void *data )
{
  int ebx;
  int esi;
  if ( dbus_timeout_get_enabled( &timeout ) )
  {
  }
}
Beispiel #15
0
static int weston_dbus_dispatch_timeout(void *data)
{
	DBusTimeout *timeout = data;

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

	return 0;
}
dbus_bool_t dbusAddTimeout( DBusTimeout *timeout, void *data )
{
  if ( !dbus_timeout_get_enabled(timeout) )
    return true;

  Integrator *itg = static_cast<Integrator*>( data );
  itg->addTimeout( timeout );
  return true;
}
Beispiel #17
0
static void
timeout_toggled (DBusTimeout * timeout, void *data) {
    /* Simply add/remove the timeout completely */
    if (dbus_timeout_get_enabled (timeout)) {
        timeout_add (timeout, data);
    } else {
        timeout_remove (timeout, data);
    }
}
Beispiel #18
0
static dbus_bool_t add_timeout(DBusTimeout *timeout, void *data)
{
	if (!dbus_timeout_get_enabled(timeout))
		return TRUE;

	connection_setup_add_timeout(data, timeout);

	return TRUE;
}
void dbusToggleTimeout( DBusTimeout *timeout, void *data )
{
  Integrator *itg = static_cast<Integrator*>( data );

  if ( dbus_timeout_get_enabled( timeout ) )
    itg->addTimeout( timeout );
  else
    itg->removeTimeout( timeout );
}
Beispiel #20
0
int DBusHandler::Callbacks::dispatchTimeout(void* data)
{
   DBusTimeout* timeout = (DBusTimeout*) data;

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

   return 0;
}
Beispiel #21
0
static int weston_dbus_adjust_timeout(DBusTimeout *timeout,
				      struct wl_event_source *s)
{
	int64_t t = 0;

	if (dbus_timeout_get_enabled(timeout))
		t = dbus_timeout_get_interval(timeout);

	return wl_event_source_timer_update(s, t);
}
Beispiel #22
0
static void connection_setup_add_timeout(struct ctrl_iface_dbus_priv *iface,
					 DBusTimeout *timeout)
{
	if (!dbus_timeout_get_enabled(timeout))
		return;

	eloop_register_timeout(0, dbus_timeout_get_interval(timeout) * 1000,
			       process_timeout, iface, timeout);

	dbus_timeout_set_data(timeout, iface, NULL);
}
void
bus_expire_list_add_link (BusExpireList *list,
                          DBusList      *link)
{
  _dbus_assert (link->data != NULL);
  
  _dbus_list_prepend_link (&list->items, link);

  if (!dbus_timeout_get_enabled (list->timeout))
    bus_expire_timeout_set_interval (list->timeout, 0);
}
Beispiel #24
0
static void
timeout_toggled (DBusTimeout *timeout,
                   void        *data)
{
    /* Because we just exit on OOM, enable/disable is
     * no different from add/remove
     */
    if (dbus_timeout_get_enabled (timeout))
        add_timeout (timeout, data);
    else
        remove_timeout (timeout, data);
}
Beispiel #25
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;
}
Beispiel #26
0
/**
 * Callback for toggling a D-Bus timeout.
 */
static void
cdbus_callback_timeout_toggled(DBusTimeout *timeout, void *data) {
  timeout_t *ptmout = dbus_timeout_get_data(timeout);

  assert(ptmout);
  if (ptmout) {
    ptmout->enabled = dbus_timeout_get_enabled(timeout);
    // Refresh interval as libdbus doc says: "Whenever a timeout is toggled,
    // its interval may change."
    ptmout->interval = dbus_timeout_get_interval(timeout);
  }
}
Beispiel #27
0
static void timeout_toggled( DBusTimeout *p_timeout, void *p_data )
{
    intf_thread_t *p_intf = (intf_thread_t*) p_data;

    msg_Dbg( p_intf, "Toggling dbus timeout" );

    if( dbus_timeout_get_enabled( p_timeout ) )
    {
        msg_Dbg( p_intf, "Timeout is enabled, main loop needs to wake up" );
        wakeup_main_loop( p_intf );
    }
}
dbus_bool_t
bus_expire_list_add (BusExpireList *list,
                     BusExpireItem *item)
{
  dbus_bool_t ret;

  ret = _dbus_list_prepend (&list->items, item);
  if (ret && !dbus_timeout_get_enabled (list->timeout))
    bus_expire_timeout_set_interval (list->timeout, 0);

  return ret;
}
Beispiel #29
0
static void
pcmk_dbus_timeout_toggle(DBusTimeout *timeout, void *data){
    bool enabled = dbus_timeout_get_enabled(timeout);

    crm_trace("Toggling timeout for %p to %s", timeout, enabled?"off":"on");

    if(enabled) {
        pcmk_dbus_timeout_add(timeout, data);
    } else {
        pcmk_dbus_timeout_remove(timeout, data);
    }
}
static void update_timeout(TimeoutData *timeout) {
    assert(timeout);
    assert(timeout->ref >= 1);

    if (dbus_timeout_get_enabled(timeout->dbus_timeout)) {
        struct timeval tv;
        avahi_elapse_time(&tv, dbus_timeout_get_interval(timeout->dbus_timeout), 0);
        timeout->poll_api->timeout_update(timeout->
                                      avahi_timeout, &tv);
    } else
        timeout->poll_api->timeout_update(timeout->avahi_timeout, NULL);

}