Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runAsync doesn't work when the socket is slow #24

Open
aleixpol opened this issue Sep 26, 2017 · 1 comment
Open

runAsync doesn't work when the socket is slow #24

aleixpol opened this issue Sep 26, 2017 · 1 comment

Comments

@aleixpol
Copy link
Contributor

Here's the code where we could reproduce it (on my system and Robert's).
git://anongit.kde.org/scratch/apol/snapmanager

@robert-ancell
Copy link
Contributor

It does work in Glib so perhaps there's something about the way the socket is made?

#include <snapd-glib/snapd-glib.h>
#include <gio/gio.h>

static void
list_cb (GObject *object, GAsyncResult *result, gpointer user_data)
{
  SnapdClient *client = (SnapdClient*) object;
  GPtrArray *snaps;
  int i;

  snaps = snapd_client_list_finish (client, result, NULL);
  for (i = 0; i < snaps->len; i++) {
    SnapdSnap *snap = snaps->pdata[i];
    g_printerr ("%s\n", snapd_snap_get_name (snap));
  }
}

int main (int argc, char **argv)
{
  GMainLoop *loop;
  GSocket *socket;
  GSocketAddress *address;
  SnapdClient *client;

  loop = g_main_loop_new (NULL, FALSE);
  socket = g_socket_new (G_SOCKET_FAMILY_IPV4, G_SOCKET_TYPE_STREAM, 0, NULL);
  address = g_inet_socket_address_new (g_inet_address_new_loopback (G_SOCKET_FAMILY_IPV4), 7627);
  g_socket_connect (socket, address, NULL, NULL);

  client = snapd_client_new_from_socket (socket);
  snapd_client_list_async (client, NULL, list_cb, NULL);

  g_main_loop_run (loop);

  return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants