mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-28 20:53:35 +08:00
Enable TCP keepalive on the core device
Automatically runs the idle experiment a few seconds after the master stops responding. Thanks Florent for figuring out TCP_KEEPIDLE_DEFAULT needed to be set in addition to the other options. Closes #31
This commit is contained in:
parent
a1c7efd0ae
commit
f2911d67b7
@ -105,6 +105,10 @@ a lot of data that needs to be copied, this should be set high. */
|
||||
|
||||
/* ---------- TCP options ---------- */
|
||||
#define LWIP_TCP 1
|
||||
#define LWIP_TCP_KEEPALIVE 1
|
||||
#define TCP_KEEPIDLE_DEFAULT 1250
|
||||
#define TCP_KEEPINTVL_DEFAULT 1000
|
||||
#define TCP_KEEPCNT_DEFAULT 3
|
||||
#define TCP_TTL 255
|
||||
|
||||
/* Controls if TCP should queue segments that arrive out of
|
||||
|
@ -60,14 +60,16 @@ static void net_server_close(struct net_server_connstate *cs, struct tcp_pcb *pc
|
||||
active_pcb = NULL;
|
||||
}
|
||||
|
||||
/* lwip loves to call back with broken pointers. Prevent that. */
|
||||
tcp_arg(pcb, NULL);
|
||||
tcp_recv(pcb, NULL);
|
||||
tcp_sent(pcb, NULL);
|
||||
tcp_err(pcb, NULL);
|
||||
if(pcb) {
|
||||
/* lwip loves to call back with broken pointers. Prevent that. */
|
||||
tcp_arg(pcb, NULL);
|
||||
tcp_recv(pcb, NULL);
|
||||
tcp_sent(pcb, NULL);
|
||||
tcp_err(pcb, NULL);
|
||||
|
||||
tcp_close(pcb);
|
||||
}
|
||||
cs_free(cs);
|
||||
tcp_close(pcb);
|
||||
}
|
||||
|
||||
static err_t net_server_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||
@ -155,7 +157,7 @@ static void net_server_err(void *arg, err_t err)
|
||||
struct net_server_connstate *cs;
|
||||
|
||||
cs = (struct net_server_connstate *)arg;
|
||||
cs_free(cs);
|
||||
net_server_close(cs, NULL);
|
||||
}
|
||||
|
||||
static struct tcp_pcb *listen_pcb;
|
||||
@ -177,6 +179,7 @@ static err_t net_server_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
|
||||
void net_server_init(void)
|
||||
{
|
||||
listen_pcb = tcp_new();
|
||||
listen_pcb->so_options |= SOF_KEEPALIVE;
|
||||
tcp_bind(listen_pcb, IP_ADDR_ANY, 1381);
|
||||
listen_pcb = tcp_listen(listen_pcb);
|
||||
tcp_accept(listen_pcb, net_server_accept);
|
||||
|
Loading…
Reference in New Issue
Block a user