CW 10.6 / MQX 4.2 / K60
I'm using FTPSRV with no problems, everything is OK... except if I have an active connection and then, call FTPSRV_release().
Since this call, EVERY tasks on my projects are blocked for ever in ftpsrc.c line 96 :
while(server->server_tid)
{
_sched_yield() ;
}
I try to add a _time_delay() in this loop and I have other tasks OK. But the FTPSRV NEVER shutdown before I cut the FTP client.
Nobody shutdown the FTPSRV() ?
Yvan
The call to FTPSRV_release() may get stuck also because of a wrong task priority schema. The RTCS user manual gives a hint about it.
I got the case with following task priorities:
TCP_TASK = 10
FTP_SERVER_TASK = 7
TASK that calls FTPSRV_release() = 8
In the manual it's stated that FTP_SERVER_TASK must be lower than TCP_TASK. I would like to add, also the call task of FTPSRV_release() must be lower. So after adjusting the task priorities to:
TCP_TASK = 10
FTP_SERVER_TASK = 11
TASK that calls FTPSRV_release() = 12
FTPSRV exits gracefully.
Best Regards,
Stefan Haase
This thread is more than one year old. But I see same effect in MQX 4.2.0 and no fix could be found.
A work around which works for me is to use following code:
FTPSRV_STRUCT* server = (FTPSRV_STRUCT*)FTPs_hd; result = shutdown ( server->sock_v4, FLAG_ABORT_CONNECTION );
instead of calling FTPSRV_release().
It looks like that closesocket() does not release the select() in ftpsrv_wait_for_conn() but shutdown() does.
The release mechanism depends on the ftpsrv_server_task() setting the server->server_tid member to zero. As it is a different task than the one that calls FTPSRV_release(), I think it must have "volatile" keyword to force the compiler to always read from memory when checking the value.
Maybe your compiler optimized this out - you can check by looking into assembly when inside the while loop. Try to declare "server_tid" as volatile.
Martin,
Thanks for your answer, but my problem is not with a particular use : server_tid is the one which is include in the Freescale FTPSRV_STRUCT struct.
I've just tried your idea, but there is no difference.
I think that everybody who try to use the FTPSRV will have this symptom...
Yvan