From owner-p4-projects@FreeBSD.ORG Mon Jan 2 10:42:21 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DD4EC16A422; Mon, 2 Jan 2006 10:42:20 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AEEDA16A41F for ; Mon, 2 Jan 2006 10:42:20 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4C28143D46 for ; Mon, 2 Jan 2006 10:42:20 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k02AgKdo055600 for ; Mon, 2 Jan 2006 10:42:20 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k02AgJJu055597 for perforce@freebsd.org; Mon, 2 Jan 2006 10:42:19 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Mon, 2 Jan 2006 10:42:19 GMT Message-Id: <200601021042.k02AgJJu055597@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 89043 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jan 2006 10:42:21 -0000 http://perforce.freebsd.org/chv.cgi?CH=89043 Change 89043 by rwatson@rwatson_sesame on 2006/01/02 10:42:13 Clean up sosend_dgram() return handling. Affected files ... .. //depot/projects/netsmp/src/sys/kern/uipc_socket.c#23 edit Differences ... ==== //depot/projects/netsmp/src/sys/kern/uipc_socket.c#23 (text+ko) ==== @@ -716,7 +716,6 @@ } #define SBLOCKWAIT(f) (((f) & MSG_DONTWAIT) ? M_NOWAIT : M_WAITOK) -#define snderr(errno) { error = (errno); goto release; } int sosend_dgram(so, addr, uio, top, control, flags, td) @@ -763,11 +762,15 @@ clen = control->m_len; SOCKBUF_LOCK(&so->so_snd); - if (so->so_snd.sb_state & SBS_CANTSENDMORE) - snderr(EPIPE); + if (so->so_snd.sb_state & SBS_CANTSENDMORE) { + SOCKBUF_UNLOCK(&so->so_snd); + error = EPIPE; + goto out; + } if (so->so_error) { error = so->so_error; so->so_error = 0; + SOCKBUF_UNLOCK(&so->so_snd); goto out; } if ((so->so_state & SS_ISCONNECTED) == 0) { @@ -780,11 +783,19 @@ if ((so->so_proto->pr_flags & PR_CONNREQUIRED) && (so->so_proto->pr_flags & PR_IMPLOPCL) == 0) { if ((so->so_state & SS_ISCONFIRMING) == 0 && - !(resid == 0 && clen != 0)) - snderr(ENOTCONN); - } else if (addr == NULL) - snderr(so->so_proto->pr_flags & PR_CONNREQUIRED ? - ENOTCONN : EDESTADDRREQ); + !(resid == 0 && clen != 0)) { + SOCKBUF_UNLOCK(&so->so_snd); + error = ENOTCONN; + goto out; + } + } else if (addr == NULL) { + if (so->so_proto->pr_flags & PR_CONNREQUIRED) + error = ENOTCONN; + else + error = EDESTADDRREQ; + SOCKBUF_UNLOCK(&so->so_snd); + goto out; + } } /* @@ -795,8 +806,10 @@ if (flags & MSG_OOB) space += 1024; space -= clen; - if (resid > space) - snderr(EMSGSIZE); + if (resid > space) { + error = EMSGSIZE; + goto out; + } SOCKBUF_UNLOCK(&so->so_snd); if (uio == NULL) { resid = 0; @@ -874,7 +887,7 @@ * must check for short counts if EINTR/ERESTART are returned. * Data and control buffers are freed on return. */ - +#define snderr(errno) { error = (errno); goto release; } int sosend(so, addr, uio, top, control, flags, td) struct socket *so; @@ -1036,6 +1049,7 @@ m_freem(control); return (error); } +#undef snderr /* * The part of soreceive() that implements reading non-inline out-of-band