lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Re: an idea how to implement sending non-blocking sockets(L


From: Martin Velek
Subject: [lwip-users] Re: an idea how to implement sending non-blocking sockets(LWIP1.4.x)
Date: Thu, 30 Sep 2010 17:20:34 +0200

Hi,

> !!!The lwip sometimes hangs with segmentation fault on api_msg.c,
> (original file) line 1204.

It seems that the last issue is caused by calling the event function
sent_tcp() that call again do_writemore() but without properly
initialized a netconn structure, especially the current_msg property.


Thread [2] 12300 (Suspended : Signal : SIGSEGV:Segmentation fault)      
        do_writemore() at /home/velek/Velek/projects/lwip/api/api_msg.c:1,168
0x8076703
        sent_tcp() at /home/velek/Velek/projects/lwip/api/api_msg.c:306 
0x8074e95       
        tcp_input() at /home/velek/Velek/projects/lwip/core/tcp_in.c:342 
0x807ddae      
        ip_input() at /home/velek/Velek/projects/lwip/core/ipv4/ip.c:505 
0x8071bb0      
        ethernet_input() at
/home/velek/Velek/projects/lwip/netif/etharp.c:1,249 0x8069203
        tcpip_thread() at /home/velek/Velek/projects/lwip/api/tcpip.c:103 
0x807c042     
        start_thread() at 0x13396e      
        clone() at 0x23ea4e     

Name : current_msg
        Details:0x0
        Default:0x0
        Decimal:0
        Hex:0x0
        Binary:0
        Octal:0

Name : callback
        Details:0x807a37c <event_callback>
        Default:0x807a37c <event_callback>
        Decimal:134718332
        Hex:0x807a37c
        Binary:1000000001111010001101111100
        Octal:01001721574


On 30 September 2010 12:54, Martin Velek <address@hidden> wrote:
> Hello,
>
> I have posted a feature request (or bug)
> http://savannah.nongnu.org/bugs/?31084 and I would like to discuss a
> suggestions how to how to implement non-blocking sockets in some
> reasonable way. I think the lwip could behave as described in the
> feature request (if a socket is in the non-blocking mode, the LWIP
> tries to send as much as possible (free space in send buffer)).
> However I do not know exactly the internal structure of LWIP so that
> the following modification can break something.
>
> The main idea is to determine free space in buffer and send only
> MIN(size, free space in send buffer).
>
> lwip-1.4.0.rc1
>
> api.h, add below line 160 - size_t sent;
> --need to modify netconn structure to have got a place where will be
> stored number of characters sent.
>
> sockets.c, line 767-773 - Comment out or remove the the checking for
> flags or nonblocking netconn.
>
> sockets.c, line 777 - change to ((flags & MSG_DONTWAIT) ||
> netconn_is_nonblocking(sock->conn) ? NETCONN_DONTBLOCK : 0);
> --set write_flags NETCONN_DONTBLOCK a) MSG_DONTWAIT is set or b) the
> netconn is non-blocking
>
> sockets.c, line 782 - change to return (err == ERR_OK ?
> (int)sock->conn->sent : -1);
> --return only number of characters sent or error
>
> api_lib.c,add below line 596 - conn->sent = msg.msg.msg.w.len;
> --store number of characters sent to the netconn structure
>
> api_msg.c,add below line 1329 -
>  if (NETCONN_DONTBLOCK & msg->msg.w.apiflags) {
>        msg->msg.w.len = MIN(msg->msg.w.len, tcp_sndbuf(msg->conn->pcb.tcp));
> }
> if (msg->msg.w.len > 0) {
> --MIN is some kind of selecting minimum, e.g. #define MIN(a,b) 
> ((a)>(b)?(b):(a))
>
> api_msg.c,add below line 1346 -
> } else {
> msg->err = ERR_WOULDBLOCK;
> }
>
> However there are some issues
> If the lwip_send ends with EAGAIN  or  EWOULDBLOCK, can be lwip_select
> able to detect event in case data was sent before calling
> lwip_select?
> What about other types of sockets?(A more sophisticated check should
> be provided)
>
> !!!The lwip sometimes hangs with segmentation fault on api_msg.c,
> (original file) line 1204.
>
> Regards,
> Martin
>



reply via email to

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