Example #1
0
static gboolean
g_fam_file_monitor_is_supported (void)
{
  g_mutex_lock (&fam_lock);

  if (!fam_initialised)
    {
      fam_initialised = FAMOpen2 (&fam_connection, "GLib GIO") == 0;

      if (fam_initialised)
        {
#ifdef HAVE_FAM_NO_EXISTS
          /* This is a gamin extension that avoids sending all the
           * Exists event for dir monitors
           */
          FAMNoExists (&fam_connection);
#endif

          fam_source = g_unix_fd_source_new (FAMCONNECTION_GETFD (&fam_connection), G_IO_IN);
          g_source_set_callback (fam_source, (GSourceFunc) g_fam_file_monitor_callback, NULL, NULL);
          g_source_attach (fam_source, GLIB_PRIVATE_CALL(g_get_worker_context) ());
        }
    }

  g_mutex_unlock (&fam_lock);

  g_print ("II %d\n", fam_initialised);

  return fam_initialised;
}
Example #2
0
static gboolean
sbd_get_two_node(void)
{
    uint8_t two_node_u8 = 0;
    int cmap_fd;

    if (!track_handle) {
        if (cmap_initialize(&cmap_handle) != CS_OK) {
            cl_log(LOG_WARNING, "Cannot initialize CMAP service\n");
            goto out;
        }

        if (cmap_track_add(cmap_handle, "quorum.two_node",
                            CMAP_TRACK_DELETE|CMAP_TRACK_MODIFY|CMAP_TRACK_ADD,
                            sbd_cmap_notify_fn, NULL, &track_handle) != CS_OK) {
            cl_log(LOG_WARNING, "Failed adding CMAP tracker for 2Node-mode\n");
            goto out;
        }

        /* add the tracker to mainloop */
        if (cmap_fd_get(cmap_handle, &cmap_fd) != CS_OK) {
            cl_log(LOG_WARNING, "Failed to get a file handle for cmap\n");
            goto out;
        }

        if (!(cmap_source = g_unix_fd_source_new (cmap_fd, G_IO_IN))) {
            cl_log(LOG_WARNING, "Couldn't create source for cmap\n");
            goto out;
        }
        g_source_set_callback(cmap_source, cmap_dispatch_callback, NULL, NULL);
        g_source_attach(cmap_source, NULL);
    }

    if (cmap_get_uint8(cmap_handle, "quorum.two_node", &two_node_u8) == CS_OK) {
        cl_log(two_node_u8? LOG_NOTICE : LOG_INFO,
               "Corosync is%s in 2Node-mode", two_node_u8?"":" not");
        two_node = two_node_u8;
    } else {
        cl_log(LOG_INFO, "quorum.two_node not present in cmap\n");
    }
    return TRUE;

out:
    cmap_destroy();

    return FALSE;
}
int luaopen_material_editor_capi(lua_State *L)
{
	lua_newtable(L);
	luaL_setfuncs(L, lua_b2l_material_editor_capi, 0);
	g_L = L;
	cb.on_expose = on_expose;
	cb.on_destroy = on_destroy;
	cb.on_resize = on_resize;
	cb.on_mouse_button_up = on_mouse_button_up;
	cb.on_mouse_button_down = on_mouse_button_down;
	cb.on_mouse_move = on_mouse_move;
	cb.on_mouse_wheel = on_mouse_wheel;
	cb.on_resize = on_resize;
	glwin_init();
	GMainContext *ctx = g_main_context_default();
	g_src = g_unix_fd_source_new(glwin_epoll_fd, G_IO_IN);
	g_source_attach(g_src, ctx);
	g_source_set_callback(g_src, dispatch, NULL, NULL);
	return 1;
}
static GSource *
g_unix_input_stream_pollable_create_source (GPollableInputStream *stream,
					    GCancellable         *cancellable)
{
  GUnixInputStream *unix_stream = G_UNIX_INPUT_STREAM (stream);
  GSource *inner_source, *cancellable_source, *pollable_source;

  pollable_source = g_pollable_source_new (G_OBJECT (stream));

  inner_source = g_unix_fd_source_new (unix_stream->priv->fd, G_IO_IN);
  g_source_set_dummy_callback (inner_source);
  g_source_add_child_source (pollable_source, inner_source);
  g_source_unref (inner_source);

  if (cancellable)
    {
      cancellable_source = g_cancellable_source_new (cancellable);
      g_source_set_dummy_callback (cancellable_source);
      g_source_add_child_source (pollable_source, cancellable_source);
      g_source_unref (cancellable_source);
    }

  return pollable_source;
}
Example #5
0
/**
 * g_unix_fd_add_full:
 * @priority: the priority of the source
 * @fd: a file descriptor
 * @condition: IO conditions to watch for on @fd
 * @function: a #GUnixFDSourceFunc
 * @user_data: data to pass to @function
 * @notify: function to call when the idle is removed, or %NULL
 *
 * Sets a function to be called when the IO condition, as specified by
 * @condition becomes true for @fd.
 *
 * This is the same as g_unix_fd_add(), except that it allows you to
 * specify a non-default priority and a provide a #GDestroyNotify for
 * @user_data.
 *
 * Returns: the ID (greater than 0) of the event source
 *
 * Since: 2.36
 **/
guint
g_unix_fd_add_full (gint              priority,
                    gint              fd,
                    GIOCondition      condition,
                    GUnixFDSourceFunc function,
                    gpointer          user_data,
                    GDestroyNotify    notify)
{
  GSource *source;
  guint id;

  g_return_val_if_fail (function != NULL, 0);

  source = g_unix_fd_source_new (fd, condition);

  if (priority != G_PRIORITY_DEFAULT)
    g_source_set_priority (source, priority);

  g_source_set_callback (source, (GSourceFunc) function, user_data, notify);
  id = g_source_attach (source, NULL);
  g_source_unref (source);

  return id;
}