예제 #1
0
파일: dbus.c 프로젝트: tradej/pacemaker
static int
pcmk_dbus_watch_dispatch(gpointer userdata)
{
    bool oom = FALSE;
    DBusWatch *watch = userdata;
    int flags = dbus_watch_get_flags(watch);
    bool enabled = dbus_watch_get_enabled (watch);
    mainloop_io_t *client = dbus_watch_get_data(watch);

    crm_trace("Dispatching client %p: %s", client, dbus_watch_flags_to_string(flags));
    if (enabled && is_set(flags, DBUS_WATCH_READABLE)) {
        oom = !dbus_watch_handle(watch, flags);

    } else if (enabled && is_set(flags, DBUS_WATCH_READABLE)) {
        oom = !dbus_watch_handle(watch, flags);

    } else if(enabled) {
        oom = !dbus_watch_handle(watch, DBUS_WATCH_ERROR);
    }

    if(flags != dbus_watch_get_flags(watch)) {
        flags = dbus_watch_get_flags(watch);
        crm_trace("Dispatched client %p: %s (%d)", client, dbus_watch_flags_to_string(flags), flags);
    }

    if(oom) {
        crm_err("DBus encountered OOM while attempting to dispatch %p (%s)", client, dbus_watch_flags_to_string(flags));
    }
    return 0;
}
예제 #2
0
파일: idbus.c 프로젝트: kaffeemonster/g2cd
static void handle_watch(struct sock_com *s, short revents)
{
	struct DBusWatch *w = s->data;
	unsigned int flags = 0;

	if(!w)
		return;
	if(!dbus_watch_get_enabled(w)) {
		s->enabled = false;
		return;
	}

	flags |= revents & POLLIN  ? DBUS_WATCH_READABLE : 0;
	flags |= revents & POLLOUT ? DBUS_WATCH_WRITABLE : 0;
	flags |= revents & POLLERR ? DBUS_WATCH_ERROR    : 0;
	flags |= revents & POLLHUP ? DBUS_WATCH_HANGUP   : 0;
	if(flags)
		dbus_watch_handle(w, flags);
	if(idbus_connection)
	{
		dbus_connection_ref(idbus_connection);
		while(DBUS_DISPATCH_DATA_REMAINS == dbus_connection_dispatch(idbus_connection)) {
			/* nop */;
		}
		dbus_connection_unref(idbus_connection);
	}
}
예제 #3
0
/* pa_io_event_cb_t IO event handler */
static void handle_io_event(pa_mainloop_api *ea, pa_io_event *e, int fd, pa_io_event_flags_t events, void *userdata) {
    unsigned int flags = 0;
    DBusWatch *watch = userdata;

#if HAVE_DBUS_WATCH_GET_UNIX_FD
    pa_assert(fd == dbus_watch_get_unix_fd(watch));
#else
    pa_assert(fd == dbus_watch_get_fd(watch));
#endif

    if (!dbus_watch_get_enabled(watch)) {
        pa_log_warn("Asked to handle disabled watch: %p %i", (void*) watch, fd);
        return;
    }

    if (events & PA_IO_EVENT_INPUT)
        flags |= DBUS_WATCH_READABLE;
    if (events & PA_IO_EVENT_OUTPUT)
        flags |= DBUS_WATCH_WRITABLE;
    if (events & PA_IO_EVENT_HANGUP)
        flags |= DBUS_WATCH_HANGUP;
    if (events & PA_IO_EVENT_ERROR)
        flags |= DBUS_WATCH_ERROR;

    dbus_watch_handle(watch, flags);
}
예제 #4
0
파일: main.c 프로젝트: PeterXu/gst-mobile
static dbus_bool_t
reload_watch_callback (DBusWatch    *watch,
		       unsigned int  condition,
		       void         *data)
{
  return dbus_watch_handle (watch, condition);
}
예제 #5
0
파일: efl.c 프로젝트: connectivity/connline
static Eina_Bool watch_handler_dispatch(void *data,
					Ecore_Fd_Handler *e_handler)
{
	struct watch_handler *io_handler = data;
	DBusDispatchStatus status;
	unsigned int flags = 0;

	if (ecore_main_fd_handler_active_get(e_handler, ECORE_FD_ERROR)
								== EINA_TRUE)
		flags |= DBUS_WATCH_ERROR;
	if (ecore_main_fd_handler_active_get(e_handler, ECORE_FD_READ)
								== EINA_TRUE)
		flags |= DBUS_WATCH_READABLE;
	if (ecore_main_fd_handler_active_get(e_handler, ECORE_FD_WRITE)
								== EINA_TRUE)
		flags |= DBUS_WATCH_WRITABLE;

	dbus_watch_handle(io_handler->watch, flags);

	status = dbus_connection_get_dispatch_status(io_handler->dbus_cnx);
	if (status == DBUS_DISPATCH_DATA_REMAINS)
		ecore_timer_add(0, efl_dispatch_dbus, io_handler->dbus_cnx);

	dbus_connection_unref(io_handler->dbus_cnx);

	return TRUE;
}
예제 #6
0
/* Callback: "glib says dbus fd is active" */
static gboolean handle_dbus_fd(GIOChannel *gio, GIOCondition condition, gpointer data)
{
    DBusWatch *watch = (DBusWatch*)data;

    log_debug("%s(gio, condition:%x [bits:IN/PRI/OUT/ERR/HUP...], data)", __func__, (int)condition);

    /* Notify the D-Bus library when a previously-added watch
     * is ready for reading or writing, or has an exception such as a hangup.
     */
    int glib_flags = (int)condition;
    int dbus_flags = 0;
    if (glib_flags & G_IO_IN)  dbus_flags |= DBUS_WATCH_READABLE;
    if (glib_flags & G_IO_OUT) dbus_flags |= DBUS_WATCH_WRITABLE;
    if (glib_flags & G_IO_ERR) dbus_flags |= DBUS_WATCH_ERROR;
    if (glib_flags & G_IO_HUP) dbus_flags |= DBUS_WATCH_HANGUP;
    /*
     * TODO:
     * If dbus_watch_handle returns FALSE, then the file descriptor
     * may still be ready for reading or writing, but more memory
     * is needed in order to do the reading or writing. If you ignore
     * the FALSE return, your application may spin in a busy loop
     * on the file descriptor until memory becomes available,
     * but nothing more catastrophic should happen.
     */
    dbus_watch_handle(watch, dbus_flags);

    while (dbus_connection_dispatch(g_dbus_conn) == DBUS_DISPATCH_DATA_REMAINS)
        log_debug("%s: more data to process, looping", __func__);
    return TRUE; /* "glib, do not remove this event source!" */
}
예제 #7
0
static void read_watch_cb(int fd, void* d) { 
	/* E_DEBUG(E_STRLOC ": read_watch_cb()\n"); */

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

	WatchListIter it = dc->watch_list->begin(), it_end = dc->watch_list->end();
	while(it != it_end) {
		if(dbus_watch_get_fd(*it) == fd && dbus_watch_get_enabled(*it)) {
			if(!dbus_watch_handle(*it, DBUS_WATCH_READABLE))
				E_WARNING(E_STRLOC ": Out of memory\n");
			break;
		}
		++it;
	}

	/*
	 * Check if there are more incomming data and process them. Note that 
	 * dbus_connection_dispatch() call will also remove data from queue. 
	 * This means that (here) timer will not be installed if only one unprocessed
	 * message is in queue; opposite, after installment it will process the rest
	 * of the messages without interrupting read_watch_cb() flow.
	 *
	 * If this is not set (e.g. all data are processed here), we can miss initial
	 * (or later) messages that are sent to us. Also, timer will be triggered faster
	 * as it can (seems that 0.5 as timer value misses some data...).
	 */
	if(dbus_connection_dispatch(dc->conn) == DBUS_DISPATCH_DATA_REMAINS)
		Fl::add_timeout(0.2, dispatch_cb, dc);
}
예제 #8
0
void
io_watch_handler_cb (hidval pcb_watch,
		     int fd, unsigned int condition, hidval data)
{
  IOWatchHandler *handler;
  unsigned int dbus_condition = 0;

  handler = (IOWatchHandler *) data.ptr;

  // TODO: IS THIS NEEDED?
  //if (connection)
  //  dbus_connection_ref (connection);

  if (condition & PCB_WATCH_READABLE)
    dbus_condition |= DBUS_WATCH_READABLE;
  if (condition & PCB_WATCH_WRITABLE)
    dbus_condition |= DBUS_WATCH_WRITABLE;
  if (condition & PCB_WATCH_ERROR)
    dbus_condition |= DBUS_WATCH_ERROR;
  if (condition & PCB_WATCH_HANGUP)
    dbus_condition |= DBUS_WATCH_HANGUP;

  /* We don't touch the handler after this, because DBus
   * may have disabled the watch and thus killed the handler
   */
  dbus_watch_handle (handler->dbus_watch, dbus_condition);
  handler = NULL;

  //if (connection)
  //  dbus_connection_unref (connection);

  return;
}
예제 #9
0
void check_dbus_listeners(fd_set *rset, fd_set *wset, fd_set *eset)
{
  DBusConnection *connection = (DBusConnection *)daemon->dbus;
  struct watch *w;

  for (w = daemon->watches; w; w = w->next)
    if (dbus_watch_get_enabled(w->watch))
      {
	unsigned int flags = 0;
	int fd = dbus_watch_get_unix_fd(w->watch);
	
	if (FD_ISSET(fd, rset))
	  flags |= DBUS_WATCH_READABLE;
	
	if (FD_ISSET(fd, wset))
	  flags |= DBUS_WATCH_WRITABLE;
	
	if (FD_ISSET(fd, eset))
	  flags |= DBUS_WATCH_ERROR;

	if (flags != 0)
	  dbus_watch_handle(w->watch, flags);
      }

  if (connection)
    {
      dbus_connection_ref (connection);
      while (dbus_connection_dispatch (connection) == DBUS_DISPATCH_DATA_REMAINS);
      dbus_connection_unref (connection);
    }
}
static gboolean
io_handler_dispatch (GIOChannel *source, GIOCondition condition, gpointer data)
{
	IOHandler *handler = data;
	guint dbus_condition = 0;
	DBusConnection *connection = handler->cs->connection;

	if (connection)
		dbus_connection_ref (connection);

	if (condition & G_IO_IN)
		dbus_condition |= DBUS_WATCH_READABLE;
	if (condition & G_IO_OUT)
		dbus_condition |= DBUS_WATCH_WRITABLE;
	if (condition & G_IO_ERR)
		dbus_condition |= DBUS_WATCH_ERROR;
	if (condition & G_IO_HUP)
		dbus_condition |= DBUS_WATCH_HANGUP;

	/* Note that we don't touch the handler after this, because
	 * dbus may have disabled the watch and thus killed the
	 * handler.
	 */
	dbus_watch_handle (handler->watch, dbus_condition);
	handler = NULL;

	if (connection)
		dbus_connection_unref (connection);

	return TRUE;
}
예제 #11
0
void
DBusWatcher::OnFileCanWriteWithoutBlocking(int aFd)
{
  MOZ_ASSERT(!NS_IsMainThread());

  dbus_watch_handle(mWatch, DBUS_WATCH_WRITABLE);
}
예제 #12
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;
}
void Integrator::slotRead( int fd )
{
  QIntDictIterator<Watch>	it( m_watches );
  for ( ; it.current(); ++it )
    dbus_watch_handle ( it.current()->watch, DBUS_WATCH_READABLE );

  emit readReady();
}
예제 #14
0
static void watch_callback(AvahiWatch *avahi_watch, AVAHI_GCC_UNUSED int fd, AvahiWatchEvent events, void *userdata) {
    DBusWatch *dbus_watch = userdata;

    assert(avahi_watch);
    assert(dbus_watch);

    dbus_watch_handle(dbus_watch, translate_avahi_to_dbus(events));
    /* Ignore the return value */
}
예제 #15
0
static int ldbus_watch_handle(lua_State *L) {
	DBusWatch *watch = check_DBusWatch(L, 1);
	int flags;
	dbus_bool_t ok;
	luaL_argcheck(L, watch != NULL, 1, "watch invalid");
	flags = luaL_checkinteger(L, 2);
	ok = dbus_watch_handle(watch, flags);
	lua_pushboolean(L, ok);
	return 1;
}
예제 #16
0
void
DBusThread::EventLoop()
{
  dbus_connection_set_watch_functions(mConnection, AddWatch,
                                      RemoveWatch, ToggleWatch, this, NULL);
  dbus_connection_set_wakeup_main_function(mConnection, DBusWakeup, this, NULL);
#ifdef DEBUG
  LOG("DBus Event Loop Starting\n");
#endif
  while (1) {
    poll(mPollData.Elements(), mPollData.Length(), -1);

    for (uint32_t i = 0; i < mPollData.Length(); i++) {
      if (!mPollData[i].revents) {
        continue;
      }

      if (mPollData[i].fd == mControlFdR.get()) {
        char data;
        while (recv(mControlFdR.get(), &data, sizeof(char), MSG_DONTWAIT)
               != -1) {
          switch (data) {
          case DBUS_EVENT_LOOP_EXIT:
#ifdef DEBUG
            LOG("DBus Event Loop Exiting\n");
#endif
            dbus_connection_set_watch_functions(mConnection,
                                                NULL, NULL, NULL, NULL, NULL);
            return;
          case DBUS_EVENT_LOOP_ADD:
            HandleWatchAdd(this);
            break;
          case DBUS_EVENT_LOOP_REMOVE:
            HandleWatchRemove(this);
            break;
          case DBUS_EVENT_LOOP_WAKEUP:
            // noop
            break;
          }
        }
      } else {
        short events = mPollData[i].revents;
        unsigned int flags = UnixEventsToDBusFlags(events);
        dbus_watch_handle(mWatchData[i], flags);
        mPollData[i].revents = 0;
        // Break at this point since we don't know if the operation
        // was destructive
        break;
      }
    }
    while (dbus_connection_dispatch(mConnection) ==
           DBUS_DISPATCH_DATA_REMAINS)
    {}
  }
}
예제 #17
0
파일: dbus.c 프로젝트: iamnpc/myfaplayer
/**
 * ProcessWatches() handles a list of dbus watches after poll() has returned
 *
 * This function must be called with p_sys->lock unlocked
 *
 * @param intf_thread_t *p_intf This interface thread state
 * @param DBusWatch **p_watches The list of dbus watches to process
 * @param int i_watches The size of the p_watches array
 * @param struct pollfd *p_fds The result of a poll() call
 * @param int i_fds The number of file descriptors processed by poll()
 */
static void ProcessWatches( intf_thread_t *p_intf,
                            DBusWatch **p_watches, int i_watches,
                            struct pollfd *p_fds,  int i_fds )
{
    /* Process watches */
    for( int i = 0; i < i_watches; i++ )
    {
        DBusWatch *p_watch = p_watches[i];
        if( !dbus_watch_get_enabled( p_watch ) )
            continue;

        for( int j = 0; j < i_fds; j++ )
        {
            if( p_fds[j].fd != dbus_watch_get_unix_fd( p_watch ) )
                continue;

            int i_flags   = 0;
            int i_revents = p_fds[j].revents;
            int i_fd      = p_fds[j].fd;

            if( i_revents & POLLIN )
            {
                msg_Dbg( p_intf, "fd %d is ready for reading", i_fd );
                i_flags |= DBUS_WATCH_READABLE;
            }

            if( i_revents & POLLOUT )
            {
                msg_Dbg( p_intf, "fd %d is ready for writing", i_fd );
                i_flags |= DBUS_WATCH_WRITABLE;
            }

            if( i_revents & POLLERR )
            {
                msg_Dbg( p_intf, "error when polling fd %d", i_fd );
                i_flags |= DBUS_WATCH_ERROR;
            }

            if( i_revents & POLLHUP )
            {
                msg_Dbg( p_intf, "Hangup signal on fd %d", i_fd );
                i_flags |= DBUS_WATCH_HANGUP;
            }

            if( i_flags )
            {
                msg_Dbg( p_intf, "Handling dbus watch on fd %d", i_fd );
                dbus_watch_handle( p_watch, i_flags );
            }
            else
                msg_Dbg( p_intf, "Nothing happened on fd %d", i_fd );
        }
    }
}
예제 #18
0
/*
 * watch_handler
 * Callback for D-BUS to handle messages on a file-descriptor
 */
static void sbus_watch_handler(struct tevent_context *ev,
                               struct tevent_fd *fde,
                               uint16_t flags, void *data)
{
    struct sbus_watch_ctx *watch = talloc_get_type(data,
                                                   struct sbus_watch_ctx);
    enum dbus_conn_type type;
    union dbus_conn_pointer dbus_p;

    /* conn may get freed inside a handle, save the data we need for later */
    type = watch->conn->type;
    dbus_p = watch->conn->dbus;

    /* Take a reference while handling watch */
    if (type == SBUS_SERVER) {
        dbus_server_ref(dbus_p.server);
    } else {
        dbus_connection_ref(dbus_p.conn);
    }

    /* Fire if readable */
    if (flags & TEVENT_FD_READ) {
        if (watch->dbus_read_watch) {
            dbus_watch_handle(watch->dbus_read_watch, DBUS_WATCH_READABLE);
        }
    }

    /* Fire if writeable */
    if (flags & TEVENT_FD_WRITE) {
        if (watch->dbus_write_watch) {
            dbus_watch_handle(watch->dbus_write_watch, DBUS_WATCH_WRITABLE);
        }
    }

    /* Release reference once done */
    if (type == SBUS_SERVER) {
        dbus_server_unref(dbus_p.server);
    } else {
        dbus_connection_unref(dbus_p.conn);
    }
}
예제 #19
0
파일: dbus-amiga.c 프로젝트: michalsc/AROS
static void MainLoop() {
  struct ConnectionData* c = (struct ConnectionData*) FindTask(NULL)->tc_UserData;
  kprintf("MainLoop started %08lx (cd %08lx)\n", FindTask(NULL), c);

  c->signal = AllocSignal(-1);

  if (c->signal == -1) {
    goto exit;
  }
  
  Signal(c->creator, SIGF_SINGLE);
  
  while(TRUE) {
    ULONG signals = Wait(SIGBREAKF_CTRL_C | (1UL << c->signal));

    kprintf("MainLoop got a signal %lx\n", signals);

    if (signals & SIGBREAKF_CTRL_C) {
      break;
    }

    if (signals & (1UL << c->signal)) {
      struct WatchData* w;
      
//      dbus_connection_ref(c->connection);

      kprintf("Checking watches\n");
      for(w = (struct WatchData*) c->watches.mlh_Head;
	  w->node.mln_Succ != NULL;
	  w = (struct WatchData*) w->node.mln_Succ) {
	kprintf("%s watch on fd %ld, flags %lx\n",
		w->enabled ? "Enabled" : "Disabled",
		dbus_watch_get_fd(w->watch), dbus_watch_get_flags(w->watch));
	if (w->enabled) {
	  dbus_watch_handle(w->watch, dbus_watch_get_flags(w->watch));
	}
      }
      
      kprintf("Dispatching messages\n");
      /* Dispatch messages */
      while (dbus_connection_dispatch(c->connection) == DBUS_DISPATCH_DATA_REMAINS) {
	kprintf("More messages available\n");
      }

//      dbus_connection_unref(c->connection);
    }
  }

exit:
  c->main = NULL;
  Signal(c->creator, SIGF_SINGLE);
  kprintf("MainLoop terminating\n");
}
예제 #20
0
파일: dbus.c 프로젝트: chaind/chaind
int dbus_update(struct dbus* dbus)
{
    DBusDispatchStatus status;

    // handle watches
    Word_t watch_count = 0;
    JLC(watch_count, dbus->watches, 0, -1);
    struct pollfd* pollfds = (struct pollfd*)alloca(sizeof(struct pollfd) * watch_count);
    int fdcount = get_pollfds(dbus, pollfds);

    if(poll(pollfds, fdcount, 0) < 0) {
        return -1;
    }

    // process the watches
    DBusWatch** pwatch;
    Word_t index = 0;
    int c = 0;
    JLF(pwatch, dbus->watches, index);
    while(pwatch != NULL) {
        struct pollfd* poll_result = &pollfds[c];
        struct DBusWatch* watch = *pwatch;

        if(dbus_watch_get_enabled(watch)) {
            assert(poll_result->fd == dbus_watch_get_unix_fd(watch));

            int flags = 0;
            int revents = poll_result->revents;

            if((revents & POLLIN) != 0) flags |= DBUS_WATCH_READABLE;
            if((revents & POLLOUT) != 0) flags |= DBUS_WATCH_WRITABLE;
            if((revents & POLLERR) != 0) flags |= DBUS_WATCH_ERROR;
            if((revents & POLLHUP) != 0) flags |= DBUS_WATCH_HANGUP;

            if(flags != 0) dbus_watch_handle(watch, flags);

            c++;
        }
        JLN(pwatch, dbus->watches, index);
    }

    // dispatch incoming messages
    while((status = dbus_connection_get_dispatch_status(dbus->conn)) != DBUS_DISPATCH_COMPLETE) {
        dbus_connection_dispatch(dbus->conn);
    }

    // Send outgoing messages
    if(dbus_connection_has_messages_to_send(dbus->conn)) {
        dbus_connection_flush(dbus->conn);
    }

    return 0;
}
예제 #21
0
static void process_watch(struct wpas_dbus_priv *priv,
			  DBusWatch *watch, eloop_event_type type)
{
	dbus_connection_ref(priv->con);

	priv->should_dispatch = 0;

	if (type == EVENT_TYPE_READ)
		dbus_watch_handle(watch, DBUS_WATCH_READABLE);
	else if (type == EVENT_TYPE_WRITE)
		dbus_watch_handle(watch, DBUS_WATCH_WRITABLE);
	else if (type == EVENT_TYPE_EXCEPTION)
		dbus_watch_handle(watch, DBUS_WATCH_ERROR);

	if (priv->should_dispatch) {
		dispatch_data(priv->con);
		priv->should_dispatch = 0;
	}

	dbus_connection_unref(priv->con);
}
예제 #22
0
파일: bus.c 프로젝트: scottt/dbus-vmci
static dbus_bool_t
server_watch_callback (DBusWatch     *watch,
                       unsigned int   condition,
                       void          *data)
{
    /* FIXME this can be done in dbus-mainloop.c
     * if the code in activation.c for the babysitter
     * watch handler is fixed.
     */

    return dbus_watch_handle (watch, condition);
}
예제 #23
0
void
DBusWatcher::OnFileCanReadWithoutBlocking(int aFd)
{
  MOZ_ASSERT(!NS_IsMainThread());

  dbus_watch_handle(mWatch, DBUS_WATCH_READABLE);

  DBusDispatchStatus dbusDispatchStatus;
  do {
    dbusDispatchStatus =
      dbus_connection_dispatch(mConnection->GetConnection());
  } while (dbusDispatchStatus == DBUS_DISPATCH_DATA_REMAINS);
}
예제 #24
0
static void process_watch(struct ctrl_iface_dbus_priv *iface,
			  DBusWatch *watch, eloop_event_type type)
{
	dbus_connection_ref(iface->con);

	iface->should_dispatch = 0;

	if (type == EVENT_TYPE_READ)
		dbus_watch_handle(watch, DBUS_WATCH_READABLE);
	else if (type == EVENT_TYPE_WRITE)
		dbus_watch_handle(watch, DBUS_WATCH_WRITABLE);
	else if (type == EVENT_TYPE_EXCEPTION)
		dbus_watch_handle(watch, DBUS_WATCH_ERROR);

	if (iface->should_dispatch) {
		while (dbus_connection_get_dispatch_status(iface->con) ==
		       DBUS_DISPATCH_DATA_REMAINS)
			dbus_connection_dispatch(iface->con);
		iface->should_dispatch = 0;
	}

	dbus_connection_unref(iface->con);
}
예제 #25
0
static void write_watch_cb(int fd, void* d) { 
	/* E_DEBUG(E_STRLOC ": write_watch_cb()\n"); */

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

	WatchListIter it = dc->watch_list->begin(), it_end = dc->watch_list->end();
	while(it != it_end) { 
		if(dbus_watch_get_fd(*it) == fd && dbus_watch_get_enabled(*it)) {
			if(!dbus_watch_handle(*it, DBUS_WATCH_WRITABLE))
				E_WARNING(E_STRLOC ": Out of memory\n");
			break;
		}
		++it;
	}
}
예제 #26
0
static gboolean watch_func(GIOChannel *chan, GIOCondition cond, gpointer data)
{
	DBusWatch *watch = data;
	struct watch_info *info = dbus_watch_get_data(watch);
	int flags = 0;

	if (cond & G_IO_IN)  flags |= DBUS_WATCH_READABLE;
	if (cond & G_IO_OUT) flags |= DBUS_WATCH_WRITABLE;
	if (cond & G_IO_HUP) flags |= DBUS_WATCH_HANGUP;
	if (cond & G_IO_ERR) flags |= DBUS_WATCH_ERROR;

	dbus_watch_handle(watch, flags);

	if (dbus_connection_get_dispatch_status(info->conn) == DBUS_DISPATCH_DATA_REMAINS)
		g_timeout_add(DISPATCH_TIMEOUT, message_dispatch_cb, info->conn);

	return TRUE;
}
예제 #27
0
static gboolean watch_func(GIOChannel *chan, GIOCondition cond, gpointer data)
{
	struct watch_info *info = data;
	unsigned int flags = 0;
	DBusDispatchStatus status;

	if (cond & G_IO_IN)  flags |= DBUS_WATCH_READABLE;
	if (cond & G_IO_OUT) flags |= DBUS_WATCH_WRITABLE;
	if (cond & G_IO_HUP) flags |= DBUS_WATCH_HANGUP;
	if (cond & G_IO_ERR) flags |= DBUS_WATCH_ERROR;

	dbus_watch_handle(info->watch, flags);

	status = dbus_connection_get_dispatch_status(info->conn);
	queue_dispatch(info->conn, status);

	return TRUE;
}
예제 #28
0
파일: dbus.c 프로젝트: ChristophHaag/weston
static int weston_dbus_dispatch_watch(int fd, uint32_t mask, void *data)
{
	DBusWatch *watch = data;
	uint32_t flags = 0;

	if (dbus_watch_get_enabled(watch)) {
		if (mask & WL_EVENT_READABLE)
			flags |= DBUS_WATCH_READABLE;
		if (mask & WL_EVENT_WRITABLE)
			flags |= DBUS_WATCH_WRITABLE;
		if (mask & WL_EVENT_HANGUP)
			flags |= DBUS_WATCH_HANGUP;
		if (mask & WL_EVENT_ERROR)
			flags |= DBUS_WATCH_ERROR;

		dbus_watch_handle(watch, flags);
	}

	return 0;
}
예제 #29
0
파일: dbus.c 프로젝트: TELE-TWIN/livebox2
gboolean watch_func(GIOChannel *chan, GIOCondition cond, gpointer data)
{
	DBusWatch *watch = (DBusWatch *) data;
	int flags = 0;

	if (cond & G_IO_IN)  flags |= DBUS_WATCH_READABLE;
	if (cond & G_IO_OUT) flags |= DBUS_WATCH_WRITABLE;
	if (cond & G_IO_HUP) flags |= DBUS_WATCH_HANGUP;
	if (cond & G_IO_ERR) flags |= DBUS_WATCH_ERROR;

	dbus_watch_handle(watch, flags);

	dbus_connection_ref(connection);

	/* Dispatch messages */
	while (dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS);

	dbus_connection_unref(connection);

	return TRUE;
}
예제 #30
0
파일: loop.c 프로젝트: Pardus-Linux/COMAR
static void fd_handler(short events, DBusWatch *watch)
{
    unsigned int flags = 0;

    if (events & POLLIN)
        flags |= DBUS_WATCH_READABLE;
    if (events & POLLOUT)
        flags |= DBUS_WATCH_WRITABLE;
    if (events & POLLHUP)
        flags |= DBUS_WATCH_HANGUP;
    if (events & POLLERR)
        flags |= DBUS_WATCH_ERROR;

    while (!dbus_watch_handle(watch, flags)) {
        log_error("DBus watch handler needs more memory, sleeping...\n");
        sleep(1);
    }

    dbus_connection_ref(bus_conn);
    while (dbus_connection_dispatch(bus_conn) == DBUS_DISPATCH_DATA_REMAINS);
    dbus_connection_unref(bus_conn);
}