[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE : RE : [lwip-users] tcp_close and the unsent queue
From: |
Frédéric BERNON |
Subject: |
RE : RE : [lwip-users] tcp_close and the unsent queue |
Date: |
Wed, 11 Oct 2006 20:13:32 +0200 |
Hi Clive,
Here the lwip_close() code. I have disable the protection against "We cannot
allow multiple closes of the same socket" because I don't have this kind of
problem with my application, and waiting inside the "socksem" critical section
block others tasks.
There is no a real "mssleep" in lwip (the sys_msleep() is implemented with
sys_sem_new/sys_sem_wait_timeout/sys_sem_free, and it's not - to my point of
view - a good implementation for this issue), so I use my OS "sleep()". I will
extend sys and sys_arch to do something more in the lwip spirit.
I will put this code in netconn API when I will got few minutes. I have change
some little things in netconn to implement a "recv timeout" with the
SO_RCVTIMEO, IP_MULTICAST_TTL, IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP options.
There is some others informations in :
http://savannah.nongnu.org/bugs/?func=detailitem&item_id=15926
Regards
int
lwip_close(int s)
{
struct lwip_socket *sock;
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s));
if (!socksem)
socksem = sys_sem_new(1);
/* We cannot allow multiple closes of the same socket. */
//FB sys_sem_wait(socksem);
sock = get_socket(s);
if (!sock) {
//FB sys_sem_signal(socksem);
set_errno(EBADF);
return -1;
}
if (sock->conn->type==NETCONN_TCP)//FB have to add a timeout
{ while (((sock->conn->pcb.tcp->unacked!=NULL) ||
(sock->conn->pcb.tcp->unsent!=NULL)) && (sock->conn->err==ERR_OK))
{ //FB sys_msleep(1);
tmosalTaskSleep(1);//FB wait here 1ms, but not use sys_msleep() because
not usefull
}
}
sys_sem_wait(socksem); //FB now, enter in critcal section
netconn_close(sock->conn);//FB was never call before, to check if really
necessary/usefull
netconn_delete(sock->conn);
if (sock->lastdata) {
netbuf_delete(sock->lastdata);
}
sock->lastdata = NULL;
sock->lastoffset = 0;
sock->conn = NULL;
sys_sem_signal(socksem);
sock_set_errno(sock, 0);
return 0;
}
====================================
Frédéric BERNON
HYMATOM SA
Chef de projet informatique
Microsoft Certified Professional
Tél. : +33 (0)4-67-87-61-10
Fax. : +33 (0)4-67-70-85-44
Email : address@hidden
Web Site : http://www.hymatom.fr
====================================
-----Message d'origine-----
De : address@hidden [mailto:address@hidden De la part de Clive Wilson
Envoyé : mercredi 11 octobre 2006 19:31
À : Mailing list for lwIP users
Objet : RE : [lwip-users] tcp_close and the unsent queue
At 13:37 11/10/2006, you wrote:
Content-Type: multipart/related; type="multipart/alternative";
boundary="----_=_NextPart_001_01C6ED32.132CF677"
content-class: urn:content-classes:message
Hi Tom,
Which API do you use ? sockets or raw api ? If you use sockets API, I can
suggest a little patch to fix this problem in lwip_close.
Hello Frédéric,
Can you post the lwip_close patch here? I'm very interested to see what it is.
Kind regards,
Clive Wilson
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- RE : RE : [lwip-users] tcp_close and the unsent queue,
Frédéric BERNON <=