I bought a couple of Digibutlers in 2008 with the purpose of developing a homecontrol application (mainly heating control and regulation). But quickly other activities interfered and it is only recently that I could invest substantial time in my ancient project.
Once I had a Digibutler working (of course, I experienced a number of the problems discussed elsewhere in this forum) I connected it to my local ethernet and I tried to access it from each of the four PC present on it. Simultaneous connections invoking the
variables.htm
page (which reloads itself quite frequently) quickly caused the device to hang, with reboot being the only way out.
I wonder if this problem has already been discussed elsewhere in this forum, because I guess it cannot have got unnoticed for two years now. Anyway, I hope this contribution will prove useful to a few readers.
I have to substantially modify the software, so a deep dive into its guts was unavoidable. During my explorations, I stepped on the following code snippets in module freescale_http_server.c
1. Function :
freescale_http_cmdcb
(interrupt routine)
case M_CLOSED:
while( semaphore ){};
semaphore = 1;
freescale_http_remove( so ); // EMG - 3/31/06
semaphore = 0;
2. Function :
freescale_http_check
(interruptible routine)
while( semaphore )
Obviously, this semaphore was a last minute patch to avoid a concurrent execution of two functions (session allocation/deallocation), with a good chance of leaving the session data structure in an inconsistent state.
But as it is done, the cure may well be worse than the illness :
while( semaphore )
else freescale_http_remove( so ); // EMG - 3/31/06
break; // let stale conn timer catch these
------------------
void freescale_http_check(void)
{
M_SOCK so;
if ( emg_http_server_socket == INVALID_SOCKET )
return ;
while(msring_del(&emg_http_msring, &so) == 0)
{
semaphore = 1;
while(freescale_http_connection(so) == 0)
{
semaphore = 0;
freescale_http_loop();
}
semaphore = 0;
while (stc_rem != stc_ins)
{
freescale_http_remove((M_SOCK) socket_to_close[stc_rem++]);
if (stc_rem >= STC_SIZE) stc_rem = 0;
html_vars[17]++; // occurrence counter
}
}
After these modifications my Digibutler has worked for days without trouble. Let's now get on to real work !