Bug 233469

Summary: knetworkmanager confused by /etc/init.d/network restart
Product: [Unmaintained] knetworkmanager Reporter: Tristan Miller <psychonaut>
Component: generalAssignee: Will Stephenson <wstephenson>
Status: RESOLVED INTENTIONAL    
Severity: normal CC: benderamp, lamarque, ruchir.brahmbhatt
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Unspecified   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: hack to restart knetworkmanager
hack to restart knetworkmanager if it was running.
hack to restart knetworkmanager if it was running.

Description Tristan Miller 2010-04-06 11:36:22 UTC
Version:            (using KDE 4.4.2)
Installed from:    openSUSE RPMs

Reproducibility: Always

Steps to reproduce:
1. Make sure knetworkmanager is running and that a network connection is active
2. As root, run (as appropriate for one's system)
# rcnetwork restart
or
# /etc/init.d/network restart

Observed behaviour:
3. The knetworkmanager system tray icon changes to a blue W.  Right-clicking on it does not list any available networks; there are only grayed-out options.
It's now completely useless and must be manually killed and restarted.
Comment 1 Lamarque V. Souza 2010-05-03 05:06:37 UTC
I tried to figure out why this is happening but failed. I have found some weird berhaviour in solid networkmanager support (knetworkmanager also has the same behaviour). For some reason solid networkmanager backend (solid/networkmanager-0.7/manager.cpp) and knetworkmanager do not receive signals from networkmanager if it restarts. For instance in solid/networkmanager-0.7/manager.cpp: 

 1. NMNetworkManager::NMNetworkManager(QObject * parent, const QStringList &) 
 2. {
 3.    qDBusRegisterMetaType<QList<QDBusObjectPath> >();
 4.    d_ptr = new NMNetworkManagerPrivate;
 5.    Q_D(NMNetworkManager);
 6.    d->nmState = d->iface.state();
 7.    d->isWirelessHardwareEnabled = d->iface.wirelessHardwareEnabled();
 8.    d->isWirelessEnabled = d->iface.wirelessEnabled();
 9.    connect( &d->iface, SIGNAL(DeviceAdded(const QDBusObjectPath &)),
10.                 this, SLOT(deviceAdded(const QDBusObjectPath &)));
11.     connect( &d->iface, SIGNAL(DeviceRemoved(const QDBusObjectPath &)),
12.                 this, SLOT(deviceRemoved(const QDBusObjectPath &)));
13.     connect( &d->iface, SIGNAL(PropertiesChanged(const QVariantMap &)),
14.                 this, SLOT(propertiesChanged(const QVariantMap &)));
15.     connect( &d->iface, SIGNAL(StateChanged(uint)),
16.                 this, SLOT(stateChanged(uint)));
17. 
18.     d->iface.connection().connect(QLatin1String("org.freedesktop.DBus"),
19.             QLatin1String("/org/freedesktop/DBus"), 
20. QLatin1String("org.freedesktop.DBus"),
21.             QLatin1String("NameOwnerChanged"), QLatin1String("sss"),
22.             this, SLOT(nameOwnerChanged(QString,QString,QString)));

The connects in lines 9, 11, 13, and 15 have no effect when networkmanager restart, but the connect in line 18 still works.

In knetworkmanager/monolithic/knetworkmanagertrayicon.cpp:

KNetworkManagerTrayIcon::KNetworkManagerTrayIcon(...
.
.
.
    // hide the icon when network management is unavailable
    QObject::connect(Solid::Control::NetworkManager::notifier(),
                        SIGNAL(statusChanged(Solid::Networking::Status)),
                        this,
                      SLOT(networkingStatusChanged(Solid::Networking::Status)));

The slot networkingStatusChanged sometimes is called when networkmanger stops, but it is never called when it starts again.

In knetworkmanager/backends/NetworkManager/nmdbussettingsconnectionprovider.cpp, 
NMDBusSettingsConnectionProvider::onRemoteConnectionRemoved:

if I delete d->iface and create a new one then I got a notification saying that networking system has been disabled, without this change I never get one.

I suspect for some reason all classes connected to org.freedesktop.networkmanager when networkmanager closes does not reconnect when networkmanager restarts again. I just have not figure out why.
Comment 2 Lamarque V. Souza 2010-05-03 05:10:40 UTC
I forgot to say that the networkmanagement kded module still works correctly. Even if the tray icon do not react the interfaces marked as "autoconnect" continues to connect in background and I can use the Internet normally.
Comment 3 Lamarque V. Souza 2010-05-03 05:15:08 UTC
Created attachment 43179 [details]
hack to restart knetworkmanager

This hack closes knm's tray icon when networkmanager is gone from dbus and starts it again when networkmanager registers to dbus. It is not a solution but at least makes knm restart automatically.
Comment 4 Lamarque V. Souza 2010-05-18 07:11:52 UTC
Created attachment 43680 [details]
hack to restart knetworkmanager if it was running.

This version only restarts knm if it was running when NetworkManager was closed. That way it does not disturb who uses plasma applet or nm-applet.
Comment 5 Lamarque V. Souza 2010-05-18 09:12:06 UTC
Created attachment 43682 [details]
hack to restart knetworkmanager if it was running.

It seems knm has to run after NM or it will not receive signals from Notifier, this is the problem I described in my first post. So let's do it differently. Now it works as expected, just make sure NM is running when the first instance of knm starts, knm will not work properly otherside.
Comment 6 Lamarque V. Souza 2010-10-03 03:23:07 UTC
I do not have problems with NM restart anymore. I am using KDE SC 4.5.1, NetworkManager 0.8 and svn Plasma NM from September 8th. Could someone test if this problem is really fixed?
Comment 7 Tristan Miller 2010-10-25 14:54:26 UTC
Bug 236521 appears to be a duplicate of this one.
Comment 8 Lamarque V. Souza 2011-01-30 22:52:04 UTC
*** Bug 236521 has been marked as a duplicate of this bug. ***
Comment 9 Lamarque V. Souza 2011-01-30 22:58:43 UTC
Please use Plasma NetworkManager instead of knetworkmanager, it does not suffer from this problem. Knetworkmanager monolithic is not being developed anymore.
Comment 10 Lamarque V. Souza 2011-02-01 01:11:51 UTC
*** Bug 223080 has been marked as a duplicate of this bug. ***