After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 468910 - giofunc condition=0
giofunc condition=0
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: win32
2.14.x
Other All
: Normal major
: ---
Assigned To: gtk-win32 maintainers
gtk-win32 maintainers
Depends on:
Blocks:
 
 
Reported: 2007-08-21 15:55 UTC by Andrey Bogomolov
Modified: 2018-05-24 11:05 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andrey Bogomolov 2007-08-21 15:55:26 UTC
Please describe the problem:
Sometimes (when you move or resize window) condition in GIOFunc == 0. After that my connection freezes, and I never get any additional callback.

Steps to reproduce:
1. This is a simple program you can reproduce with:

#include <windows.h>
#include <winsock2.h>
#include <gtk/gtk.h>

int sock;
GIOChannel *chan;
gchar server[100] = "64.161.255.20";
int port = 6667;
GtkTextBuffer *buffer;

gboolean giofunc_func(GIOChannel *source, GIOCondition condition, gpointer data)
{
  GtkTextIter iter;
  char buf[1025];

  switch(condition) {
  case G_IO_IN:
    recv(sock, buf, 1024, 0);
    buf[1024] = 0;
    gtk_text_buffer_get_end_iter(buffer, &iter);
    gtk_text_buffer_insert(buffer, &iter, buf, -1);
    break;
  case G_IO_OUT:
    Sleep(5000);
    gtk_text_buffer_get_end_iter(buffer, &iter);
    gtk_text_buffer_insert(buffer, &iter, "Connecting!\n", -1);
    send(sock, "NICK gtk_bug_testing\r\n", 22, 0);
    send(sock, "USER u 0 * :u\r\n", 15, 0);
    send(sock, "JOIN #gtk+\r\n", 12, 0);
    send(sock, "LIST\r\n", 6, 0);
    return FALSE;
  default:
    gtk_text_buffer_get_end_iter(buffer, &iter);
    gtk_text_buffer_insert(buffer, &iter, "\nBug!\n", -1);
    break;
  }
  return TRUE;
}

void network_init()
{
  struct sockaddr_in addr;
  int on = 1;

  sock = socket(AF_INET, SOCK_STREAM, 0);
  ioctlsocket(sock, FIONBIO, &on);
  chan = g_io_channel_win32_new_socket(sock);
  addr.sin_family = AF_INET;
  addr.sin_port = htons(port);
  addr.sin_addr.s_addr = inet_addr(server);

  g_io_add_watch(chan, G_IO_IN, giofunc_func, NULL);
  g_io_add_watch(chan, G_IO_OUT, giofunc_func, NULL);
  connect(sock, (struct sockaddr*)&addr, sizeof(struct sockaddr_in));
}

int main(int argc, char *argv[])
{
  GtkWidget *window, *textview, *scroll;

  WSADATA wsaData;
  WSAStartup(MAKEWORD( 2, 2 ), &wsaData);

  gtk_init(&argc, &argv);
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(window, 500, 500);
  textview = gtk_text_view_new();
  buffer = gtk_text_view_get_buffer(textview);

  scroll = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
  gtk_container_add(GTK_CONTAINER(scroll), textview);

  gtk_container_add(GTK_CONTAINER(window), scroll);

  gtk_widget_show_all(window);
  network_init();
  gtk_main();
}

2. You should run the program
3. It will connect to freenode's irc server and begin listing all possible channels
4. Move or resize window during it

Actual results:
It will insert in textview "Bug!" (condition == 0) and connection will "freeze" - you can check it by printing something to #gtk+ channel from another irc client.

Expected results:


Does this happen every time?
Sometimes, with intensive traffic receiving/sending

Other information:
Comment 1 Tor Lillqvist 2008-08-19 00:42:41 UTC
This is probably a duplicate of bug #338943, as the code sets several watches on the same socket... That said, changing the code to add just one watch (for G_IO_IN|G_IO_OUT) doesn't work either...
Comment 2 GNOME Infrastructure Team 2018-05-24 11:05:09 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/101.