[Top][All Lists]

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

Re: [lwip-users] lwip_close() doesn't work when lwip_write() hangs

From: Joel Cunningham
Subject: Re: [lwip-users] lwip_close() doesn't work when lwip_write() hangs
Date: Mon, 12 Oct 2015 14:44:51 +0000 (GMT)

LwIP doesn't support this kind of threading model.  Multiple threads can not perform simultaneous operations (read+write, write+close, etc.) on the same socket.  The main limitation is that the netconn only has a single semaphore for blocking the calling thread when entering the core context.

On the master branch there is support for this model but the feature is in alpha state (see LWIP_NETCONN_FULLDUPLEX). In LwIP 1.4.1, this is not supported.


On Oct 10, 2015, at 12:29 AM, alhadpalkar <address@hidden> wrote:

I am using branch 1.4.1 of lwip. I have a thread that connects to a remote
server and writes data to it using lwip_write(). Sometimes this hangs
indefinitely. Looks like its waiting on the op->completed semaphore which
never gets signaled.

I tried using the SO_SNDTIMEO socket option, but that just causes panics in
my system. So I tried another approach where I use a watchdog that detects
this hang and calls lwip_close(). But it looks like LWIP doesn't like it. I
hit this assert

netconn_free(struct netconn *conn)
LWIP_ASSERT("PCB must be deallocated outside this function", conn->pcb.tcp
== NULL);

On debugging further it looks like we end up getting the ERR_INPROGRESS in

do_delconn(struct api_msg_msg *msg)
/* @todo TCP: abort running write/connect? */
if ((msg->conn->state != NETCONN_NONE) &&
(msg->conn->state != NETCONN_LISTEN) &&
(msg->conn->state != NETCONN_CONNECT)) {
/* this only happens for TCP netconns */
LWIP_ASSERT("msg->conn->type == NETCONN_TCP", msg->conn->type ==
km_printf("err in progress\n");
msg->err = ERR_INPROGRESS;

so we never end up cleanup up the pcbs which leads to this assert.

Is there a way around this?

View this message in context: http://lwip.100.n7.nabble.com/lwip-close-doesn-t-work-when-lwip-write-hangs-tp25191.html
Sent from the lwip-users mailing list archive at Nabble.com.

lwip-users mailing list

reply via email to

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