diff --git a/configs/launchxl-tms57004/README.txt b/configs/launchxl-tms57004/README.txt index 5bd541f7155..cbcb01eb8b1 100644 --- a/configs/launchxl-tms57004/README.txt +++ b/configs/launchxl-tms57004/README.txt @@ -28,7 +28,7 @@ Status But I was initially able to load FLASH and debug using a Segger J-Link connected to the board as described below. But I think that some of my initial code loads put the TMS570 in bad state (or worse). Now - the NERROR LED is on. When I attempt to problem the FLASH, the J-Link + the NERROR LED is on. When I attempt to program the FLASH, the J-Link software complains that the CPU is running too slowly and then times out trying to erase the FLASH. diff --git a/libc/wqueue/work_queue.c b/libc/wqueue/work_queue.c index 3a09c6d389a..282e6cc024c 100644 --- a/libc/wqueue/work_queue.c +++ b/libc/wqueue/work_queue.c @@ -152,7 +152,9 @@ int work_queue(int qid, FAR struct work_s *work, worker_t worker, { /* Cancel any pending work in the work stucture */ - work_cancel(qid, work); + (void)work_cancel(qid, work); + + /* Then queue the new work */ return work_qqueue(&g_usrwork, work, worker, arg, delay); } diff --git a/net/inet/Make.defs b/net/inet/Make.defs index 2ce0674ef30..de9c25627da 100644 --- a/net/inet/Make.defs +++ b/net/inet/Make.defs @@ -59,10 +59,6 @@ endif endif endif -ifneq ($(CONFIG_NET_TCP_NO_STACK),y) -SOCK_CSRCS += inet_monitor.c -endif - # Include inet build support DEPPATH += --dep-path inet diff --git a/net/inet/inet.h b/net/inet/inet.h index 947e99d733f..a79fb2aa3c8 100644 --- a/net/inet/inet.h +++ b/net/inet/inet.h @@ -128,75 +128,6 @@ struct socket; /* Forward reference */ void inet_setipid(uint16_t id); -/**************************************************************************** - * Name: net_startmonitor - * - * Description: - * Set up to receive TCP connection state changes for a given socket - * - * Input Parameters: - * psock - The socket of interest - * - * Returned Value: - * On success, net_startmonitor returns OK; On any failure, - * net_startmonitor will return a negated errno value. The only failure - * that can occur is if the socket has already been closed and, in this - * case, -ENOTCONN is returned. - * - * Assumptions: - * The caller holds the network lock (if not, it will be locked momentarily - * by this function). - * - ****************************************************************************/ - -#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK) -int net_startmonitor(FAR struct socket *psock); -#endif - -/**************************************************************************** - * Name: net_stopmonitor - * - * Description: - * Stop monitoring TCP connection changes for a given socket - * - * Input Parameters: - * conn - The TCP connection of interest - * - * Returned Value: - * None - * - * Assumptions: - * The caller holds the network lock (if not, it will be locked momentarily - * by this function). - * - ****************************************************************************/ - -#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK) -void net_stopmonitor(FAR struct tcp_conn_s *conn); -#endif - -/**************************************************************************** - * Name: net_lostconnection - * - * Description: - * Called when a loss-of-connection event has occurred. - * - * Parameters: - * psock The TCP socket structure associated. - * flags Set of connection events events - * - * Returned Value: - * None - * - * Assumptions: - * The caller holds the network lock. - * - ****************************************************************************/ - -#if defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK) -void net_lostconnection(FAR struct socket *psock, uint16_t flags); -#endif - /**************************************************************************** * Name: ipv4_getsockname and ipv6_sockname * diff --git a/net/inet/inet_close.c b/net/inet/inet_close.c index 4e2e357dfb9..f372f879505 100644 --- a/net/inet/inet_close.c +++ b/net/inet/inet_close.c @@ -508,7 +508,7 @@ int inet_close(FAR struct socket *psock) /* Stop the network monitor */ - net_stopmonitor(conn); + tcp_stop_monitor(conn); } else { diff --git a/net/inet/inet_connect.c b/net/inet/inet_connect.c index 5a7826b1597..0d63a88a47e 100644 --- a/net/inet/inet_connect.c +++ b/net/inet/inet_connect.c @@ -163,7 +163,7 @@ static void psock_teardown_callbacks(FAR struct tcp_connect_s *pstate, { /* Failed to connect. Stop the connection event monitor */ - net_stopmonitor(conn); + tcp_stop_monitor(conn); } } #endif /* NET_TCP_HAVE_STACK */ @@ -413,16 +413,16 @@ static inline int psock_tcp_connect(FAR struct socket *psock, * the state of the connection up the connection event monitor. */ - ret = net_startmonitor(psock); + ret = tcp_start_monitor(psock); if (ret < 0) { - /* net_startmonitor() can only fail on certain race + /* tcp_start_monitor() can only fail on certain race * conditions where the connection was lost just before * this function was called. That is not expected to * happen in this context, but just in case... */ - net_lostconnection(psock, TCP_ABORT); + tcp_lost_connection(psock, TCP_ABORT); } } } diff --git a/net/inet/inet_recvfrom.c b/net/inet/inet_recvfrom.c index 55a0c1e3207..bc8768e1362 100644 --- a/net/inet/inet_recvfrom.c +++ b/net/inet/inet_recvfrom.c @@ -745,7 +745,7 @@ static uint16_t inet_tcp_interrupt(FAR struct net_driver_s *dev, /* Handle loss-of-connection event */ - net_lostconnection(pstate->ir_sock, flags); + tcp_lost_connection(pstate->ir_sock, flags); /* Check if the peer gracefully closed the connection. */ diff --git a/net/inet/inet_sendfile.c b/net/inet/inet_sendfile.c index e953c4077e1..1aebb69c5f1 100644 --- a/net/inet/inet_sendfile.c +++ b/net/inet/inet_sendfile.c @@ -227,7 +227,7 @@ static uint16_t ack_interrupt(FAR struct net_driver_s *dev, FAR void *pvconn, nwarn("WARNING: Lost connection\n"); - net_lostconnection(pstate->snd_sock, flags); + tcp_lost_connection(pstate->snd_sock, flags); pstate->snd_sent = -ENOTCONN; } @@ -349,7 +349,7 @@ static uint16_t sendfile_interrupt(FAR struct net_driver_s *dev, FAR void *pvcon nwarn("WARNING: Lost connection\n"); - net_lostconnection(pstate->snd_sock, flags); + tcp_lost_connection(pstate->snd_sock, flags); pstate->snd_sent = -ENOTCONN; goto end_wait; } diff --git a/net/inet/inet_sockif.c b/net/inet/inet_sockif.c index 7abea2204ff..923bb27b041 100644 --- a/net/inet/inet_sockif.c +++ b/net/inet/inet_sockif.c @@ -712,10 +712,10 @@ static int inet_accept(FAR struct socket *psock, FAR struct sockaddr *addr, * socket */ - ret = net_startmonitor(newsock); + ret = tcp_start_monitor(newsock); if (ret < 0) { - /* net_startmonitor() can only fail on certain race conditions where + /* tcp_start_monitor() can only fail on certain race conditions where * the connection was lost just before this function was called. Undo * everything we have done and return a failure. */ diff --git a/net/sixlowpan/sixlowpan_tcpsend.c b/net/sixlowpan/sixlowpan_tcpsend.c index d5b11d23d93..f5c9f9ab2c8 100644 --- a/net/sixlowpan/sixlowpan_tcpsend.c +++ b/net/sixlowpan/sixlowpan_tcpsend.c @@ -443,7 +443,7 @@ static uint16_t tcp_send_interrupt(FAR struct net_driver_s *dev, ninfo("Lost connection\n"); - net_lostconnection(sinfo->s_sock, flags); + tcp_lost_connection(sinfo->s_sock, flags); sinfo->s_result = -ENOTCONN; goto end_wait; } diff --git a/net/tcp/Make.defs b/net/tcp/Make.defs index c7b00b60406..dc9f048498c 100644 --- a/net/tcp/Make.defs +++ b/net/tcp/Make.defs @@ -58,7 +58,7 @@ endif NET_CSRCS += tcp_conn.c tcp_seqno.c tcp_devpoll.c tcp_finddev.c tcp_timer.c NET_CSRCS += tcp_send.c tcp_input.c tcp_appsend.c tcp_listen.c -NET_CSRCS += tcp_callback.c tcp_backlog.c tcp_ipselect.c +NET_CSRCS += tcp_monitor.c tcp_callback.c tcp_backlog.c tcp_ipselect.c # TCP write buffering diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index 1553a5199f6..665f046b83c 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -528,6 +528,69 @@ int tcp_bind(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr); int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr); +/**************************************************************************** + * Name: tcp_start_monitor + * + * Description: + * Set up to receive TCP connection state changes for a given socket + * + * Input Parameters: + * psock - The socket of interest + * + * Returned Value: + * On success, tcp_start_monitor returns OK; On any failure, + * tcp_start_monitor will return a negated errno value. The only failure + * that can occur is if the socket has already been closed and, in this + * case, -ENOTCONN is returned. + * + * Assumptions: + * The caller holds the network lock (if not, it will be locked momentarily + * by this function). + * + ****************************************************************************/ + +int tcp_start_monitor(FAR struct socket *psock); + +/**************************************************************************** + * Name: tcp_stop_monitor + * + * Description: + * Stop monitoring TCP connection changes for a given socket + * + * Input Parameters: + * conn - The TCP connection of interest + * + * Returned Value: + * None + * + * Assumptions: + * The caller holds the network lock (if not, it will be locked momentarily + * by this function). + * + ****************************************************************************/ + +void tcp_stop_monitor(FAR struct tcp_conn_s *conn); + +/**************************************************************************** + * Name: tcp_lost_connection + * + * Description: + * Called when a loss-of-connection event has occurred. + * + * Parameters: + * psock The TCP socket structure associated. + * flags Set of connection events events + * + * Returned Value: + * None + * + * Assumptions: + * The caller holds the network lock. + * + ****************************************************************************/ + +void tcp_lost_connection(FAR struct socket *psock, uint16_t flags); + /**************************************************************************** * Name: tcp_ipv4_select * diff --git a/net/inet/inet_monitor.c b/net/tcp/tcp_monitor.c similarity index 94% rename from net/inet/inet_monitor.c rename to net/tcp/tcp_monitor.c index 883df719007..f621d878836 100644 --- a/net/inet/inet_monitor.c +++ b/net/tcp/tcp_monitor.c @@ -1,7 +1,7 @@ /**************************************************************************** - * net/inet/net_monitor.c + * net/tcp/tcp_monitor.c * - * Copyright (C) 2007-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2013, 2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,9 +47,8 @@ #include #include "devif/devif.h" -#include "tcp/tcp.h" #include "socket/socket.h" -#include "inet/inet.h" +#include "tcp/tcp.h" #ifdef NET_TCP_HAVE_STACK @@ -193,7 +192,7 @@ static uint16_t connection_event(FAR struct net_driver_s *dev, * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: net_startmonitor + * Name: tcp_start_monitor * * Description: * Set up to receive TCP connection state changes for a given socket @@ -202,8 +201,8 @@ static uint16_t connection_event(FAR struct net_driver_s *dev, * psock - The socket of interest * * Returned Value: - * On success, net_startmonitor returns OK; On any failure, - * net_startmonitor will return a negated errno value. The only failure + * On success, tcp_start_monitor returns OK; On any failure, + * tcp_start_monitor will return a negated errno value. The only failure * that can occur is if the socket has already been closed and, in this * case, -ENOTCONN is returned. * @@ -213,7 +212,7 @@ static uint16_t connection_event(FAR struct net_driver_s *dev, * ****************************************************************************/ -int net_startmonitor(FAR struct socket *psock) +int tcp_start_monitor(FAR struct socket *psock) { FAR struct tcp_conn_s *conn; FAR struct devif_callback_s *cb; @@ -275,7 +274,7 @@ int net_startmonitor(FAR struct socket *psock) } /**************************************************************************** - * Name: net_stopmonitor + * Name: tcp_stop_monitor * * Description: * Stop monitoring TCP connection changes for a given socket @@ -292,7 +291,7 @@ int net_startmonitor(FAR struct socket *psock) * ****************************************************************************/ -void net_stopmonitor(FAR struct tcp_conn_s *conn) +void tcp_stop_monitor(FAR struct tcp_conn_s *conn) { DEBUGASSERT(conn); @@ -313,7 +312,7 @@ void net_stopmonitor(FAR struct tcp_conn_s *conn) } /**************************************************************************** - * Name: net_lostconnection + * Name: tcp_lost_connection * * Description: * Called when a loss-of-connection event has occurred. @@ -331,7 +330,7 @@ void net_stopmonitor(FAR struct tcp_conn_s *conn) * ****************************************************************************/ -void net_lostconnection(FAR struct socket *psock, uint16_t flags) +void tcp_lost_connection(FAR struct socket *psock, uint16_t flags) { DEBUGASSERT(psock != NULL && psock->s_conn != NULL); @@ -342,7 +341,7 @@ void net_lostconnection(FAR struct socket *psock, uint16_t flags) /* Stop the network monitor */ - net_stopmonitor((FAR struct tcp_conn_s *)psock->s_conn); + tcp_stop_monitor((FAR struct tcp_conn_s *)psock->s_conn); net_unlock(); } diff --git a/net/tcp/tcp_netpoll.c b/net/tcp/tcp_netpoll.c index a31230f4d87..27e5c71e8e6 100644 --- a/net/tcp/tcp_netpoll.c +++ b/net/tcp/tcp_netpoll.c @@ -124,7 +124,7 @@ static uint16_t tcp_poll_interrupt(FAR struct net_driver_s *dev, FAR void *conn, { /* Mark that the connection has been lost */ - net_lostconnection(info->psock, flags); + tcp_lost_connection(info->psock, flags); eventset |= (POLLERR | POLLHUP); } diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index f724a3c4269..ede040e22b9 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -515,7 +515,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev, { /* Report not connected */ - net_lostconnection(psock, flags); + tcp_lost_connection(psock, flags); } /* Free write buffers and terminate polling */ diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index ca0ac24400e..a5c61224c3f 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -400,7 +400,7 @@ static uint16_t tcpsend_interrupt(FAR struct net_driver_s *dev, ninfo("Lost connection\n"); - net_lostconnection(pstate->snd_sock, flags); + tcp_lost_connection(pstate->snd_sock, flags); pstate->snd_sent = -ENOTCONN; goto end_wait; } diff --git a/sched/wqueue/kwork_queue.c b/sched/wqueue/kwork_queue.c index be3fd90978d..4b8137d42b9 100644 --- a/sched/wqueue/kwork_queue.c +++ b/sched/wqueue/kwork_queue.c @@ -151,7 +151,7 @@ int work_queue(int qid, FAR struct work_s *work, worker_t worker, { /* Cancel any pending work in the work stucture */ - work_cancel(qid, work); + (void)work_cancel(qid, work); /* Then queue the new work */