[Patch] Possible fix for SMB/MySQL not accessible after suspend
#1
Hi,

for quite a long time I suffered from two issues within XBMC on OpenELEC after waking up from suspend:
  • SMB shares not accessible
  • MySQL server not accessible

There are several references on the forums and on the bug tracker regarding the first problem:
XBMC bug tracker:
http://trac.xbmc.org/ticket/13286

XBMC forum:
http://forum.xbmc.org/showthread.php?tid=157848
http://forum.xbmc.org/showthread.php?tid=155303
http://forum.xbmc.org/showthread.php?tid=74173
http://orum.xbmc.org/showthread.php?tid=152532

Not sure about references regarding the MySQL problem.


Anyway, I tried to fix both problems in a branch. It is based on 12.2 at the moment. I am not familiar with the XBMC code so not sure if I did it the "right" way. I am testing this since a week and it is working fine for me. SMB and MySQL are available are accessible right after wake up every time. If its done the wrong maybe just look at it as a "proof of concept" since I think at least it shows what the problems are.

The problem with SMB shares is like this:
It only happens on Linux (not on Windows) since Linux is using a different SMB code than on Windows. libsmbclient does not get deinitialized before going to sleep currently. So the lib goes mad after waking up having all its connections closed. The same is probably true for NFS but I did not touch it.
One pitfall is that python addons (for example Library Watchdog) are able to immediately re-init SMB (before XBMC actually goes to sleep) if I just deinit SMB in OnSleep. So I am stopping all python addons before deiniting SMB and restarting them after waking up. This addon-start-stop mechanism is configurable in advancedsettings.xml.

The problem with MySQL:
Right after wake up XBMC issues a library update but at that time the network interface is not up yet (at least for me). So I just added an option that makes XBMC wait for the NIC to come up after suspend before issueing the library update. For me XBMC delays for about 400 ms after wake up for this reason. Currently XBMC waits a maximum time of 10 seconds for the NIC.

The advancedconfig to enable these two options look like this:
Code:
    <suspend>
        <waitfornetafterwakup>1</waitfornetafterwakup>
        <stopservicesonsuspend>1</stopservicesonsuspend>
    </suspend>

The branch is here:
https://github.com/verybadsoldier/xbmc/c...ter-wakeup

I have no idea if you guys are interested in it or if I did it in a way guy can make use of at all. Also no idea if you need the patches applied to your master instead of the 12.2 tag. Please just let me know if you need anything changed/modified/whatever and I am happy to do it.
Reply
#2
Well, not that I was expecting overwhelming replies or something but no reply at all really is a bit Sad. So a wild guess: You are not interested in it at all. Thats no problem but maybe someone could bother to give me a hint whats wrong with it?
SMB not working after suspend (on Linux) is quite an annoying bug in my opinion.
Reply
#3
hi,

we are interested. but also very busy. it would help if you sent pull requests, and rebase on xbmc master.

in general, these issues do not sound like they warrant a setting to workaround them. i'm sure you are not the only one who have a network device that takes a while to reinit. and stopping smb seems like a good idea in general.
Reply
#4
Ok, thanks for your reply! I will do that.
Reply
#5
I have the same issue since upgrading to Frodo on two HTPCs.
Reply
#6
Ok, I did that now (hoping I did it correctly):
https://github.com/xbmc/xbmc/pull/2895

If you see any problems with it please tell me and I am happy to rework it.
Reply
#7
I think is a very Nice solution related to the distributed setup. I also always like the pingapp function.
Reply
#8
NFS is suffering from a similar issue. A huge amount of people suffer from this actually. If this gets merged eventually I really hope someone takes a look at the NFS part as well...
Platforms: macOS - iOS - OSMC
co-author: Red Bull TV add-on
Reply
#9
And i hope the PR introducer will just add NFS support too. And i am very sorry for that huge amount of people which we seem to steal their lives with our buggy shit ...
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#10
Beside the mentioned WOL, this earlier work on pingapp. should be considered. I think a uniform solution would really benefit xbmc with its planned distributed model.
Reply
#11
I just installed OE 3.1 (that's based on xbmc-6aa6247 I think) and they Devkid's patch (check here: https://github.com/OpenELEC/OpenELEC.tv/pull/2383).

I was using a script that restarted XBMC as a workaround, so I removed it, upgraded from 3.0.6 to 3.1 and rebooted.

Then I put my Intel NUC to sleep and I turned it on again, resuming, and after some seconds the system was up again and network connections to my NFS mounts and MySQL were working perfectly.

So I'm just using the OE option to "wait for network on boot" in the settings utility and everything's working out-of-the-box again, with no workarounds implemented.

Wife and kids are happy too...Wink

Thanks a lot devkid, great job.
Reply
#12
Nice to hear, thanks for reporting back! The patch is included in regular OE 3.1.3 now so feel free to update.
Reply
#13
(2013-07-17, 23:58)devkid Wrote: Nice to hear, thanks for reporting back! The patch is included in regular OE 3.1.3 now so feel free to update.
I know this is a while back, but is this patch still included in the latest releases? (OE4.0.7)? Because i have a Intel NUC and have problems with this. Resolved the network issue while booting by enabling the option 'wait for network at startup', but this morning I noticed the same problem when resuming from sleep.

I'll try this anyways tonight.
Reply
#14
(2014-07-28, 09:46)mhoogenbosch Wrote:
(2013-07-17, 23:58)devkid Wrote: Nice to hear, thanks for reporting back! The patch is included in regular OE 3.1.3 now so feel free to update.
I know this is a while back, but is this patch still included in the latest releases? (OE4.0.7)? Because i have a Intel NUC and have problems with this. Resolved the network issue while booting by enabling the option 'wait for network at startup', but this morning I noticed the same problem when resuming from sleep.

I'll try this anyways tonight.
okay i think it is Smile

i've tried this and it works. So for anyone else wondering, yes it still is active.
Reply

Logout Mark Read Team Forum Stats Members Help
[Patch] Possible fix for SMB/MySQL not accessible after suspend0