lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] lwip_connect locks tcpip_thread when trying to connet to an


From: Luca Coppolaro
Subject: [lwip-users] lwip_connect locks tcpip_thread when trying to connet to an inactive port
Date: Thu, 12 Jun 2008 13:22:59 +0200
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

Hi,
I ported lwIP to a Renesas H8/S CPU running a proprietary cooperative multitasking O.S.
First tests were very positive and httpserver run properly.

Now I'm trying to use sockets but "lwip_connect" never return if it try to connect to an inactive port. I'm porting an FTP client, everything works fine if the FTP server is running, but if the FTP server is stopped "lwip_connect" never returns.

I don't understand what I mistake.

I traced the execution and those are the relevant steps:
- (context: my SYS task) tcpip_apimsg post a message to execute do_connect
- (context: my SYS task) tcpip_apimsg wait for a signal on the semaphore
- (context: TCPIP task) message is fetched and do_connect is called
- (context: TCPIP task) do_connect calls tcp_connect that does NOT send a signal on the semaphore, the signal will be sent from do_connected or err_tcp (see comments in do_connect)
- (context: TCPIP task) destination is unreachable, and many retry are done
- (context: TCPIP task) err_tcp is called when the max retry number is reached - (context: TCPIP task) err_tcp calls execute the macro API_EVENT because conn->recvmbox is not null
- (context: TCPIP task) API_EVENT calls event_callback
- (context: TCPIP task) event_callback calls sys_sem_wait and wait for a signal on the semaphore

Then:
- task SYS is waiting for a signal (it should arrive from err_tcp)
- task TCPIP is waiting for a signal

Who is supposed to send the signal to TCPIP task?????

Many thanks,
Luca

This is what I do in my application:
 // Spawn a task that initialize lwIP and dispatch ethernet packets
 // Wait until lwIP is initialized
 s = lwip_socket(AF_INET, SOCK_STREAM, 0);
 if (s < 0)
   return;
 host.sin_family = AF_INET;
 if (inet_aton("192.168.1.6",&host.sin_addr) == 0)
   // close socket and return
 host.sin_port = 21;
 if (lwip_connect(s, (struct sockaddr *)&host, sizeof(host)) < 0)
   // close socket and return

And those are my application traces (traces with capital TCPIP where added by me)
 TCP/IP initialized.
 Applications started.
 TPCIP: in tcpip_apimsg calling sys_arch_sem_wait (current task is sys)
 tcpip_thread: API message 0x41f4c4
 TCPIP: in tcp_apimsg exited from sys_arch_sem_wait
 lwip_socket(PF_INET, SOCK_STREAM, 0) = 0
 lwip_connect(0, addr=192.168.1.6 port=21)
 TPCIP: in tcpip_apimsg calling sys_arch_sem_wait (current task is sys)
 tcpip_thread: API message 0x41f4c0
 tcpip: etharp_tmr()
 tcpip: etharp_tmr()
 tcpip: etharp_tmr()
 TCPIP: in err_tcp
TCPIP: in err_tcp - calling API_EVENT in the first 'if' statement (never exit)
 TCPIP: in event_callback (conn=0x41b8dc, socket=0)
 TCPIP: in event_callback - active task is tcpip
 TCPIP: in event_callback - calling sys_sem_wait(selectsem) (never exit)
 tcpip: etharp_tmr()
 tcpip: etharp_tmr() .... a lot more follow







reply via email to

[Prev in Thread] Current Thread [Next in Thread]