Hi,
I've just realized that, in my application (and also in the httpsrv sample that comes with MQX FRDM-K64F RTOS) that there is a problem in the CGI scripts support.
Once a script is defined to run in a separated task (script stack size > 0), and two requests for the same CGI script are made within the keep alive timeout interval, the http system freezes. The same problem happens if two different scripts requests are done in this interval (if both have stack size != 0).
It is simple to reproduce the problem: FRDM-K64F + MQX RTOS 4.1 package for FRDM-K64F + httpsrv sample. Open the index web page in the browser and perform some fast clicks in the "System RunTime (RTC) button (which is the only one that calls a CGI script configured to run in a separated task).
A similar problem (which can have different causes) is described here: Re: MQX 4 - HTTPSRV : sockets stay opened
I would appreciate any help!
Luiz Fernando
Solved! Go to Solution.
Hi,
please add following line:
_lwsem_post(&session->lock);
To file httpsrv_task.c in folder rtcs\source\apps\httpsrv_task.c to line 455 and let me know if it helped you.
Best regards,
Karel.
Hi,
please add following line:
_lwsem_post(&session->lock);
To file httpsrv_task.c in folder rtcs\source\apps\httpsrv_task.c to line 455 and let me know if it helped you.
Best regards,
Karel.
Thank you Karel! It solved my problem!
So, was that a bug? Do I need to report it somewhere else in order to get it corrected for the next MQX RTOS release?
Other weird thing I noted is that the HTTPSRVCFG_KEEPALIVE_ENABLED option does not appear in the Codewarrior view of the user_config.h file. I needed to add it manually to the user_config.h file, after the MCT generated code comment (otherwise it gets removed every time I change some config and recompile RTCS, as it should be). It would be nice to have the option in the CW user_config.h view. Below the print of the view without the option mentioned.
Thank you very much! It is so nice to receive such fast and accurate answer!
Regards
Luiz Fernando
Hi,
Yes it was a bug. You doesn't have to report it elsewhere. I have already fixed it on our development branch, so it will be fixed in nearest MQX release (4.2 probably).
Best regards,
Karel.
Hi there,
I'm suffering the very same problem I think. I installed MQX 4.1, plus patch 4.1.0.1 applied...
Running the default demo web-server, I'm doing a HTTP-GET testloop on my linux machine like this:
$ while [ true ]; do wget "http://192.168.3.43/icmpstats.cgi" -O /tmp/bla ; done
which is working fine and robust, as it uses doesn't use a seperate task (stack size = 0)
rtcdata.cgi does not work the same... when calling
$ while [ true ]; do wget "http://192.168.3.43/rtcdata.cgi" -O /tmp/bla ; done
a few subsequent wget calls are doing fine, but then suddenly the loop stops, the ressource is not available anymore.
This is the session->lock Patch I applied, but it does not help. it does not change the situation at all.
Index: httpsrv_task.c
===================================================================
--- httpsrv_task.c (revision 8288)
+++ httpsrv_task.c (working copy)
@@ -452,6 +452,7 @@
session->time = RTCS_time_get();
session->timeout = HTTPSRVCFG_KEEPALIVE_TO;
session->keep_alive = 1;
+ _lwsem_post(&session->lock);
}
break;
case HTTPSRV_SES_CLOSE:
Once the rtcdata.cgi ressource got stuck, every other ressource such as icmpstat.cgi is not available anymore, too.
I'll play around with the sources for myself, still hoping to get some help here...
cheers, Martin
Hi Martin,
I was unable to reproduce this problem in MQX 4.1.0.1. I used exactly same shell script as you did. Both icmpstat.cgi and rtcdata.cgi were read successfully. What board you use and what is your configuration?
edit:
please make sure you recompiled RTCS after you applied 4.1.0.1 and lwsem patch.
Best regards,
Karel
Hi Karel,
thanks a lot for your reply, that's good news somehow. I guess... Indeed I'm using a custom BSP, derived from the 52259 eval Tower. I will double-check it all with the Tower board, and come back to you later...
Thanks in advance, Martin
Hi Martin,
there might be a problem with rtcdata.cgi stack. Try to increase it to 3kB in structure cgi_lnk_tbl, file rtcs\examples\httpsrv\cgi.c. In a meantime I will try to reproduce it on 52259 tower board.
Best regards,
Karel
EDIT:
I just tried on MCF52259. HTTP server example (in default configuration) seems to work fine even when I try to read rtcdata.cgi with wget in cycle. However I would recommend to use sleep function in your shell script to limit how fast requests are generated.
Hi Karel,
I switched to the 52259 eval tower, using vanilla 4.1.0.1 MQX. No Problem here with the wget loop getting rtcdata.cgi
That is even without the _lwsem_post(&session->lock); patch.
So I will continue with my custom BSP to figure out what is going on there in difference to the eval-tower.
thanks for your help, Martin