GIOCondition is a bit field
authorMichał Kępień <github@kempniu.pl>
Tue, 25 Sep 2018 21:52:25 +0200
changeset 723 c4953bf0a53d
parent 722 80579726ccb4
child 724 3cd39dfd5ff7
GIOCondition is a bit field Use bitwise AND instead of equality checks when processing a GIOCondition value passed to a GIOChannel callback since it may be a bitwise combination of multiple enum values (e.g. G_IO_OUT | G_IO_ERR).
loudmouth/lm-old-socket.c
loudmouth/lm-proxy.c
--- a/loudmouth/lm-old-socket.c	Sun May 14 12:12:09 2017 +0200
+++ b/loudmouth/lm-old-socket.c	Tue Sep 25 21:52:25 2018 +0200
@@ -517,7 +517,7 @@
     /* addr = connect_data->current_addr; */
     fd = g_io_channel_unix_get_fd (source);
 
-    if (condition == G_IO_ERR) {
+    if (condition & G_IO_ERR) {
         len = sizeof (err);
         _lm_sock_get_error (fd, &err, &len);
         if (!_lm_sock_is_blocking_error (err)) {
--- a/loudmouth/lm-proxy.c	Sun May 14 12:12:09 2017 +0200
+++ b/loudmouth/lm-proxy.c	Tue Sep 25 21:52:25 2018 +0200
@@ -218,12 +218,12 @@
 
     g_return_val_if_fail (proxy != NULL, FALSE);
 
-    if (condition == G_IO_ERR) {
+    if (condition & G_IO_ERR) {
         len = sizeof (error);
         _lm_sock_get_error (connect_data->fd, &error, &len);
         _lm_old_socket_failed_with_error (connect_data, error);
         return FALSE;
-    } else if (condition == G_IO_OUT) {
+    } else if (condition & G_IO_OUT) {
         if (!proxy_negotiate (lm_connection_get_proxy (connection), connect_data->fd, lm_connection_get_server (connection), lm_connection_get_port (connection))) {
             _lm_old_socket_failed (connect_data);
             return FALSE;