diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-11-27 19:19:30 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-11-27 19:19:30 +0000 |
commit | 2a9b51de584c89c6a2dcb85cafb74424a47545cd (patch) | |
tree | 414e720883d4373d9a95fda398bdd4f799cc79b4 /nuttx/net | |
parent | 20c3067ff452e4e4604e11ec37479c50a4444de8 (diff) | |
download | px4-nuttx-2a9b51de584c89c6a2dcb85cafb74424a47545cd.tar.gz px4-nuttx-2a9b51de584c89c6a2dcb85cafb74424a47545cd.tar.bz2 px4-nuttx-2a9b51de584c89c6a2dcb85cafb74424a47545cd.zip |
Fixed missing logic in readahead buffer logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@409 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net')
-rw-r--r-- | nuttx/net/connect.c | 2 | ||||
-rw-r--r-- | nuttx/net/net-close.c | 3 | ||||
-rw-r--r-- | nuttx/net/recvfrom.c | 9 | ||||
-rw-r--r-- | nuttx/net/send.c | 8 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpcallback.c | 15 |
5 files changed, 28 insertions, 9 deletions
diff --git a/nuttx/net/connect.c b/nuttx/net/connect.c index 2316e1ba3..8d26f8e7e 100644 --- a/nuttx/net/connect.c +++ b/nuttx/net/connect.c @@ -146,6 +146,7 @@ static inline void tcp_setup_callbacks(struct uip_conn *conn, FAR struct socket { /* Set up the callbacks in the connection */ + conn->data_flags = UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT|UIP_CONNECTED; conn->data_private = (void*)pstate; conn->data_event = tcp_connect_interrupt; @@ -165,6 +166,7 @@ static inline void tcp_teardown_callbacks(struct uip_conn *conn, int status) { /* Make sure that no further interrupts are processed */ + conn->data_flags = 0; conn->data_private = NULL; conn->data_event = NULL; diff --git a/nuttx/net/net-close.c b/nuttx/net/net-close.c index 24a526ba6..f64d70de7 100644 --- a/nuttx/net/net-close.c +++ b/nuttx/net/net-close.c @@ -102,6 +102,7 @@ static uint8 netclose_interrupt(struct uip_driver_s *dev, { /* The disconnection is complete */ + conn->data_flags = 0; conn->data_private = NULL; conn->data_event = NULL; sem_post(&pstate->cl_sem); @@ -160,6 +161,7 @@ static inline void netclose_disconnect(FAR struct socket *psock) sem_init(&state.cl_sem, 0, 0); conn = psock->s_conn; + conn->data_flags = UIP_NEWDATA|UIP_CLOSE|UIP_ABORT; conn->data_private = (void*)&state; conn->data_event = netclose_interrupt; @@ -170,6 +172,7 @@ static inline void netclose_disconnect(FAR struct socket *psock) /* We are now disconnected */ sem_destroy(&state.cl_sem); + conn->data_flags = 0; conn->data_private = NULL; conn->data_event = NULL; } diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c index cb6cc88be..af28635f7 100644 --- a/nuttx/net/recvfrom.c +++ b/nuttx/net/recvfrom.c @@ -369,7 +369,7 @@ static uint8 recvfrom_tcpinterrupt(struct uip_driver_s *dev, { /* If new data is available, then complete the read action. */ - if (uip_newdata_event(flags)) + if ((flags & UIP_NEWDATA) != 0) { /* Copy the data from the packet */ @@ -391,6 +391,7 @@ static uint8 recvfrom_tcpinterrupt(struct uip_driver_s *dev, * Don't allow any further TCP call backs. */ + conn->data_flags = 0; conn->data_private = NULL; conn->data_event = NULL; @@ -418,6 +419,7 @@ static uint8 recvfrom_tcpinterrupt(struct uip_driver_s *dev, /* Stop further callbacks */ + conn->data_flags = 0; conn->data_private = NULL; conn->data_event = NULL; @@ -443,6 +445,7 @@ static uint8 recvfrom_tcpinterrupt(struct uip_driver_s *dev, nvdbg("TCP timeout\n"); + conn->data_flags = 0; conn->data_private = NULL; conn->data_event = NULL; @@ -543,7 +546,7 @@ static void recvfrom_udpinterrupt(struct uip_driver_s *dev, { /* If new data is available, then complete the read action. */ - if (uip_newdata_event(flags)) + if ((flags & UIP_NEWDATA) != 0) { /* Copy the data from the packet */ @@ -860,6 +863,7 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, /* Set up the callback in the connection */ conn = (struct uip_conn *)psock->s_conn; + conn->data_flags = UIP_NEWDATA|UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT; conn->data_private = (void*)&state; conn->data_event = recvfrom_tcpinterrupt; @@ -873,6 +877,7 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, /* Make sure that no further interrupts are processed */ + conn->data_flags = 0; conn->data_private = NULL; conn->data_event = NULL; } diff --git a/nuttx/net/send.c b/nuttx/net/send.c index c0bb11fe0..69cf883ac 100644 --- a/nuttx/net/send.c +++ b/nuttx/net/send.c @@ -110,7 +110,7 @@ static uint8 send_interrupt(struct uip_driver_s *dev, struct uip_conn *conn, uin * then send it now. */ - if (pstate->snd_state != STATE_DATA_SENT || uip_rexmit_event(flags)) + if (pstate->snd_state != STATE_DATA_SENT || (flags & UIP_REXMIT) != 0) { if (pstate->snd_buflen > uip_mss(conn)) { @@ -126,7 +126,7 @@ static uint8 send_interrupt(struct uip_driver_s *dev, struct uip_conn *conn, uin /* Check if all data has been sent and acknowledged */ - else if (pstate->snd_state == STATE_DATA_SENT && uip_ack_event(flags)) + else if (pstate->snd_state == STATE_DATA_SENT && (flags & UIP_ACKDATA) != 0) { /* Yes.. the data has been sent AND acknowledged */ @@ -152,6 +152,7 @@ static uint8 send_interrupt(struct uip_driver_s *dev, struct uip_conn *conn, uin /* Don't allow any further call backs. */ + conn->data_flags = 0; conn->data_private = NULL; conn->data_event = NULL; @@ -169,6 +170,7 @@ static uint8 send_interrupt(struct uip_driver_s *dev, struct uip_conn *conn, uin { /* Stop further callbacks */ + conn->data_flags = 0; conn->data_private = NULL; conn->data_event = NULL; @@ -301,6 +303,7 @@ ssize_t send(int sockfd, const void *buf, size_t len, int flags) /* Set up the callback in the connection */ conn = (struct uip_conn *)psock->s_conn; + conn->data_flags = UIP_REXMIT|UIP_ACKDATA|UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT; conn->data_private = (void*)&state; conn->data_event = send_interrupt; @@ -318,6 +321,7 @@ ssize_t send(int sockfd, const void *buf, size_t len, int flags) /* Make sure that no further interrupts are processed */ + conn->data_flags = 0; conn->data_private = NULL; conn->data_event = NULL; } diff --git a/nuttx/net/uip/uip-tcpcallback.c b/nuttx/net/uip/uip-tcpcallback.c index 845c49a81..d96e97981 100644 --- a/nuttx/net/uip/uip-tcpcallback.c +++ b/nuttx/net/uip/uip-tcpcallback.c @@ -84,7 +84,7 @@ uip_dataevent(struct uip_driver_s *dev, struct uip_conn *conn, uint8 flags) * can have zero-length with UIP_NEWDATA set just to cause an ACK). */ - if (uip_newdata_event(flags) && dev->d_len > 0) + if ((flags & UIP_NEWDATA) != 0 && dev->d_len > 0) { #if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0 /* Allocate a read-ahead buffer to hold the newly received data */ @@ -174,7 +174,7 @@ uint8 uip_tcpcallback(struct uip_driver_s *dev, struct uip_conn *conn, uint8 fla if (conn->data_event) { /* Perform the callback. Callback function normally returns the input flags, - * however, the implemenation may set one of the following: + * however, the implementation may set one of the following: * * UIP_CLOSE - Gracefully close the current connection * UIP_ABORT - Abort (reset) the current connection on an error that @@ -188,12 +188,17 @@ uint8 uip_tcpcallback(struct uip_driver_s *dev, struct uip_conn *conn, uint8 fla ret = conn->data_event(dev, conn, flags); } - else + + /* If there is no data callback -OR- if the data callback does not handle the + * newdata event, then there is no handler in place to handle new incoming data. + */ + + if (!conn->data_event || (conn->data_flags & UIP_NEWDATA) == 0) { - /* There is no handler to receive new data in place */ + /* In either case, we will take a default newdata action */ nvdbg("No listener on connection\n"); - ret = uip_dataevent(dev, conn, flags); + ret = uip_dataevent(dev, conn, ret); } /* Check if there is a connection-related event and a connection |