From f08a32ba977f8e5d918b36b60dfa44c4689e5c70 Mon Sep 17 00:00:00 2001 From: rrs Date: Tue, 4 Dec 2007 14:41:48 +0000 Subject: - Found a problem in non-blocking sends. When sending, once the locks are all unlocked to do the copy's in, its possible that other events could then raise the number of bytes outstanding pushing it so not all the message would fit. This would then cause us to send only part of the message. This fix makes it so we keep a "reserved" amount that can be kept in mind when making calculations to send. - rcv msg args with a NULL/NULL for to/tolen will return an error incorrectly for the 1-2-1 model. - We were not doing 0 len return correctly and not setting cantrcv more correctly. Previouly we "fixed" this area by taking out the socantrcv since we then could not get the data out. The correct rix is to still flag the socket but alow a by-pass route to continue to read until all data is consumed. MFC after: 1 week --- sys/netinet/sctputil.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'sys/netinet/sctputil.c') diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 801107f..fb660c8 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -904,6 +904,7 @@ sctp_init_asoc(struct sctp_inpcb *m, struct sctp_tcb *stcb, #else asoc->default_flowlabel = 0; #endif + asoc->sb_send_resv = 0; if (override_tag) { struct timeval now; @@ -3363,6 +3364,7 @@ sctp_notify_shutdown_event(struct sctp_tcb *stcb) } #endif socantsendmore(stcb->sctp_socket); + socantrcvmore(stcb->sctp_socket); #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING) SCTP_SOCKET_UNLOCK(so, 1); #endif @@ -4948,10 +4950,6 @@ sctp_sorecvmsg(struct socket *so, SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); return (EINVAL); } - if (from && fromlen <= 0) { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, EINVAL); - return (EINVAL); - } if (msg_flags) { in_flags = *msg_flags; if (in_flags & MSG_PEEK) @@ -5017,12 +5015,15 @@ restart_nosblocks: error = so->so_error; if ((in_flags & MSG_PEEK) == 0) so->so_error = 0; + goto out; } else { - SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, ENOTCONN); - /* indicate EOF */ - error = 0; + if (so->so_rcv.sb_cc == 0) { + SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, ENOTCONN); + /* indicate EOF */ + error = 0; + goto out; + } } - goto out; } if ((so->so_rcv.sb_cc <= held_length) && block_allowed) { /* we need to wait for data */ -- cgit v1.1