Skip to content

Commit

Permalink
Merge branch 'master' of git://git.savannah.nongnu.org/lwip
Browse files Browse the repository at this point in the history
  • Loading branch information
tabascoeye committed Feb 6, 2015
2 parents e736200 + ec68aaf commit 7544017
Show file tree
Hide file tree
Showing 18 changed files with 554 additions and 748 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ HISTORY

++ New features:

2015-01-02: Simon Goldschmidt
* tcp.c: tcp_kill_prio(): prefer nearly-closed connections (waiting for the
last ACK only) over established connections when out of tcp pcbs

2015-01-17: Simon Goldschmidt
* api: allow enabling socket API without (public) netconn API - netconn API is
still used by sockets, but keeping it private (static) should allow better
compiler optimizations

2015-01-16: Simon Goldschmidt
* tcp_in.c: fixed bug #20506 "Initial congestion window is very small" again
by implementing the calculation formula from RFC3390

2014-12-10: Simon Goldschmidt
* api: added option LWIP_NETCONN_SEM_PER_THREAD to use a semaphore per thread
instead of using one per netconn and per select call
Expand Down Expand Up @@ -143,6 +156,19 @@ HISTORY

++ Bugfixes:

2014-01-27: Simon Goldschmidt
* api_msg.c: fixed that SHUT_RD followed by SHUT_WR was different to SHUT_RDWR,
fixed return value of lwip_netconn_do_close on unconnected netconns

2015-01-17: Simon Goldschmidt
* sockets.c: fixed bug #43361 select() crashes with stale FDs

2015-01-17: Simon Goldschmidt
* sockets.c/.h, memp_std.h: fixed bug #40788 "lwip_setsockopt_internal() crashes"
by rewriting set/getsockopt functions to combine checks with the actual code
and add more NULL checks; this also fixes that CORE_LOCKING used message
passing for set/getsockopt.

2014-12-19: Simon Goldschmidt
* opt.h, dhcp.h/.c: prevent dhcp from starting when netif link is down (only
when LWIP_DHCP_CHECK_LINK_UP==1, which is disabled by default for
Expand Down
9 changes: 6 additions & 3 deletions src/api/api_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, netconn_cal
err_t
netconn_delete(struct netconn *conn)
{
err_t err;
API_MSG_VAR_DECLARE(msg);

/* No ASSERT here because possible to get a (conn == NULL) if we got an accept error */
Expand All @@ -123,12 +124,14 @@ netconn_delete(struct netconn *conn)
API_MSG_VAR_ALLOC(msg);
API_MSG_VAR_REF(msg).function = lwip_netconn_do_delconn;
API_MSG_VAR_REF(msg).msg.conn = conn;
tcpip_apimsg(&API_MSG_VAR_REF(msg));
err = tcpip_apimsg(&API_MSG_VAR_REF(msg));
API_MSG_VAR_FREE(msg);

netconn_free(conn);
if (err != ERR_OK) {
return err;
}

/* don't care for return value of lwip_netconn_do_delconn since it only calls void functions */
netconn_free(conn);

return ERR_OK;
}
Expand Down
42 changes: 28 additions & 14 deletions src/api/api_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ lwip_netconn_do_close_internal(struct netconn *conn)
{
err_t err;
u8_t shut, shut_rx, shut_tx, close;
struct tcp_pcb* tpcb = conn->pcb.tcp;

LWIP_ASSERT("invalid conn", (conn != NULL));
LWIP_ASSERT("this is for tcp netconns only", (NETCONNTYPE_GROUP(conn->type) == NETCONN_TCP));
Expand All @@ -769,34 +770,46 @@ lwip_netconn_do_close_internal(struct netconn *conn)
shut = conn->current_msg->msg.sd.shut;
shut_rx = shut & NETCONN_SHUT_RD;
shut_tx = shut & NETCONN_SHUT_WR;
/* shutting down both ends is the same as closing */
close = shut == NETCONN_SHUT_RDWR;
/* shutting down both ends is the same as closing
(also if RD or WR side was shut down before already) */
if (shut == NETCONN_SHUT_RDWR) {
close = 1;
} else if (shut_rx &&
((tpcb->state == FIN_WAIT_1) ||
(tpcb->state == FIN_WAIT_2) ||
(tpcb->state == CLOSING))) {
close = 1;
} else if (shut_tx && ((tpcb->flags & TF_RXCLOSED) != 0)) {
close = 1;
} else {
close = 0;
}

/* Set back some callback pointers */
if (close) {
tcp_arg(conn->pcb.tcp, NULL);
tcp_arg(tpcb, NULL);
}
if (conn->pcb.tcp->state == LISTEN) {
tcp_accept(conn->pcb.tcp, NULL);
if (tpcb->state == LISTEN) {
tcp_accept(tpcb, NULL);
} else {
/* some callbacks have to be reset if tcp_close is not successful */
if (shut_rx) {
tcp_recv(conn->pcb.tcp, NULL);
tcp_accept(conn->pcb.tcp, NULL);
tcp_recv(tpcb, NULL);
tcp_accept(tpcb, NULL);
}
if (shut_tx) {
tcp_sent(conn->pcb.tcp, NULL);
tcp_sent(tpcb, NULL);
}
if (close) {
tcp_poll(conn->pcb.tcp, NULL, 4);
tcp_err(conn->pcb.tcp, NULL);
tcp_poll(tpcb, NULL, 4);
tcp_err(tpcb, NULL);
}
}
/* Try to close the connection */
if (close) {
err = tcp_close(conn->pcb.tcp);
err = tcp_close(tpcb);
} else {
err = tcp_shutdown(conn->pcb.tcp, shut_rx, shut_tx);
err = tcp_shutdown(tpcb, shut_rx, shut_tx);
}
if (err == ERR_OK) {
/* Closing succeeded */
Expand Down Expand Up @@ -844,7 +857,7 @@ void
lwip_netconn_do_delconn(struct api_msg_msg *msg)
{
/* @todo TCP: abort running write/connect? */
if ((msg->conn->state != NETCONN_NONE) &&
if ((msg->conn->state != NETCONN_NONE) &&
(msg->conn->state != NETCONN_LISTEN) &&
(msg->conn->state != NETCONN_CONNECT)) {
/* this only happens for TCP netconns */
Expand All @@ -854,6 +867,7 @@ lwip_netconn_do_delconn(struct api_msg_msg *msg)
} else {
LWIP_ASSERT("blocking connect in progress",
(msg->conn->state != NETCONN_CONNECT) || IN_NONBLOCKING_CONNECT(msg->conn));
msg->err = ERR_OK;
/* Drain and delete mboxes */
netconn_drain(msg->conn);

Expand Down Expand Up @@ -1538,7 +1552,7 @@ lwip_netconn_do_close(struct api_msg_msg *msg)
} else
#endif /* LWIP_TCP */
{
msg->err = ERR_VAL;
msg->err = ERR_CONN;
}
sys_sem_signal(LWIP_API_MSG_SEM(msg));
}
Expand Down

0 comments on commit 7544017

Please sign in to comment.