Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
G
GLib
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 936
    • Issues 936
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 59
    • Merge Requests 59
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GNOME
  • GLib
  • Issues
  • #1523

Closed
Open
Opened Sep 12, 2018 by Marcin Mielniczuk@marmistrz

GIO NetworkMonitor doesn't reflect the current network state

System: Arch Linux + Cinnamon + Network Manager GLib version: 2.58.0-1

Take the following code:

#include <gio/gio.h>
#include <iostream>

int main ()
{
    GNetworkMonitor* monitor = g_network_monitor_get_default();
    std::cout << std::boolalpha << static_cast<bool>(g_network_monitor_get_network_available(monitor)) << std::endl;
    std::cout << g_network_monitor_get_connectivity(monitor) << std::endl;

    return 0;
}

Compiled with

g++ $(pkg-config --libs --cflags gio-2.0) main.cpp -o main

Then the result of this program is always

true
4

no matter if the WLAN connection (the only active connection) is turned on or off via the Cinnamon Network Manager applet. ip a confirms that the connection gets down.

Similarly, this Python code:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gio, Gtk
 
 
def network_status_changed(monitor, connected):
    print(f"xD {connected}")
 
 
network_monitor = Gio.NetworkMonitor.get_default()
network_monitor.connect('network-changed', network_status_changed)
print(network_monitor.get_connectivity())
 
Gtk.main()

always shows G_NETWORK_CONNECTIVITY_FULL and never executes the callback for the network-changed signal.

There are three interfaces in the system: lo, enpXsY (always down) and wlpXsY (down or up, depending on the case)

journalctl-xe shows no relevant errors

Edited Sep 12, 2018 by Marcin Mielniczuk
Assignee
Assign to
2.58.1
Milestone
2.58.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: GNOME/glib#1523