I can totally understand you not wanting to use the reboot option.
Rather than repeatedly kill xbmc.bin until the RPC port is no longer bound to an address, try the following method, which actually works quite well
most of the time....
1. Create a new script, /storage/rbphdmi.sh:
Code:
#!/bin/sh
LOCK=/var/lock/xbmc.disabled
WAIT4PORT='
import sys, time, socket
def p(m):
print(m)
sys.stdout.flush()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
p("[WAIT4PORT]: Checking if the RPC port is already bound to an address...")
c=0
while True:
try:
s.bind(("localhost", 9090))
except Exception as e:
if c==0: p("[WAIT4PORT]: RPC port is already bound - waiting... [%s]" % str(e))
c += 1
time.sleep(1.0)
else:
p("[WAIT4PORT]: RPC port is not bound")
break
s.close()
'
while [ true ]; do
# Give xbmc.bin time to bring up the services before trying to connect with JSON-RPC
sleep 20
# Create the lock file so that xbmc.bin doesn't automatically restart after exiting
touch $LOCK
# Monitor notifications and disable/enable HDMI when required
/storage/texturecache.py @logfile= @debug=yes @rpc.retry=0 rbphdmi | logger -t "$(basename $0)"
# Wait until RPC port is no longer bound to an address
python -c "${WAIT4PORT}" | logger -t "$(basename $0)"
# Start XBMC by removing the lock file
rm $LOCK
done
2. Grant execute permission to /storage/rbphdmi.sh:
Code:
chmod +x /storage/rbphdmi.sh
3. Update the autostart.sh hack in
post #35, replacing "RET=66" with "RET=255" - this will ensure that xbmc.bin is restarted each time, rather than the Pi rebooted.
4. Add a call to /storage/rbphdmi.sh at the end of autostart.sh in place of the current call to texturecache.py, ie.:
Code:
/storage/rbphdmi.sh &
4. sync, reboot.
5. "tail -f /var/log/messages" to see rbphdmi-related events.
What the new script rbphdmi.sh will do is prevent xbmc.bin from restarting by creating a lock file (/var/lock/xbmc.disabled) until the RPC port is no longer bound to an address, at which point the lock file is removed and xbmc.bin can then load successfully.
Quite often, the RPC port will not be bound to an address after xbmc.bin has exited with Application.Quit(), in which case there will be no delay before xbmc.bin is restarted. Basically, how it is all of the time with Gotham!
However, whenever the port remains bound to an address, usually after a "killall xbmc.bin", the delay before the port is unbound will be
60 seconds. I've tried changing the default value for net.ipv4.tcp_fin_timeout to something less than 60 seconds, but xbmc.bin is ignoring whatever value I set (or maybe I'm changing the wrong tcp setting?) so the delay is always 60 seconds whenever the address/port remains bound after xbmc.bin has exited, and I've found no way to reduce it.
This is my last shot at working around the problems with Frodo - unless you can find a better way to make it work then upgrading to Gotham is the only other option!