lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] connect block for ever?? (i need a workaround)


From: Piero 74
Subject: Re: [lwip-users] connect block for ever?? (i need a workaround)
Date: Fri, 3 Oct 2008 15:21:56 +0200



2008/10/2 David Empson <address@hidden>
Piero 74 wrote:
>I have to develop in my application a task which sends email on certain events. The provide address will be programmed.
>I will use dns to resolve the provider address.
>
>After, i will try to connect to it: if server will be down for some reason, my task will be block forever!!!!
>
>I need to avoid blocking task... is there a work around?
 
[Additional information from discussion in lwip-devel: this is using BSD sockets.]
 
The obvious solution would be to create another task to separate the sending of e-mail from the normal function of your main task. You can use some kind of queue mechanism to copy the e-mail from the main task to the "send e-mail" task.

yes... i have the same idea... because i saw that connect requested from client can block for 20 seconds if the server  is down.

 
You may need to limit the queue size to deal with the "mail server offline" scenario. The e-mail sending task would discard all pending messages if it fails to connect to the server, and then try the connection again the next time an e-mail send is requested by the main task.

interesting idea... but i have to consider RAM usage.
 
 
Depending on memory constraints, you might be able to hold on to old messages and try again after a reasonable delay, or perhaps keep a single e-mail message which records the fact that you had to delete several due to inability to connect to the mail server.

interesting idea too!
 
 
Having a queue for sending multiple e-mail messages also has the advantage that you might be able to send several at once in a single connection to the mail server, if several notifiable events occur in quick succession.

Yes, you are all right, the only problem it could be RAM usage, but i'm thinking something like a list of predefined messages, and a email-book, so, messages exchanged on queue will have small size (just some indexes)....


But, my real problem, it's a timeout for connect request: in my application all tasks cannot block for a long time, because i have a watchdog system which will reset the board if some task will be blocked for a long time (currently is working with 60s timeout).
So, i have to be sure that connect doesn't block forever, or blocks always for a fixed time.

I did a simple test, and i saw a 18 seconds block (time for sending 6 SYN packets with tcpiip retransmission delay policy)
I have to other tests, but, it seems an acceptable behavior! (if i will put email manager in a specific task, as you said)

Bye,
Piero

reply via email to

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