PERFORCE change 89043 for review
Robert Watson
rwatson at FreeBSD.org
Mon Jan 2 02:42:21 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=89043
Change 89043 by rwatson at 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
More information about the p4-projects
mailing list