Ok Think I got it now, or at least a couple of the issues :
1. the compiler settings in the Makefile are incorrect I added optimisation my setting are :
2. When I added a printstr("In http main loop") inside the main xhttp while loop it started working (the quantum observation fix!)...
I also found adding a delay in the loop fixed it like this :
Code: Select all
tmr when timerafter(t + 1000000) :> t;
On deeper examination I discovered there were obviously errant xtcp events occurring which the delay obscurred so I tried adding port filtering on the events, restricting connections to port 80 and this seems to do the trick.
here is the old broken version of xhttpd :
Code: Select all
void xhttpd(chanend tcp_svr)
{
xtcp_connection_t conn;
xtcp_listen(tcp_svr, 80, XTCP_PROTOCOL_TCP);
httpd_init();
xtcp_ask_for_event(tcp_svr);
while(1) {
select
{
case xtcp_event(tcp_svr, conn):
httpd_handle_event(tcp_svr, conn);printintln(conn.local_port);
xtcp_ask_for_event(tcp_svr);
break;
}
}
}
here is the new fixed vs:
Code: Select all
void xhttpd(chanend tcp_svr)
{
xtcp_connection_t conn;
xtcp_listen(tcp_svr, 80, XTCP_PROTOCOL_TCP);
httpd_init();
xtcp_ask_for_event(tcp_svr);
while(1) {
select
{
case xtcp_event(tcp_svr, conn):
switch(conn.local_port)
{
case 80:
httpd_handle_event(tcp_svr, conn);
break;
default:
printintln(conn.local_port);
break;
}
xtcp_ask_for_event(tcp_svr);
break;
}
}
}
Not sure what the errant events are they could be netbios or MSN/MDNS events on the network etc.. adding the port filtering is of course a good idea anyhow.
*Update actually the printint is just adding a delay which is solving or obscuring the issue and making it work. I will investigate further..