/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
splx(s);
return (EWOULDBLOCK);
}
- while (head->so_comp.tqh_first == NULL && head->so_error == 0) {
+ while (TAILQ_EMPTY(&head->so_comp) && head->so_error == 0) {
if (head->so_state & SS_CANTRCVMORE) {
head->so_error = ECONNABORTED;
break;
* block allowing another process to accept the connection
* instead.
*/
- so = head->so_comp.tqh_first;
+ so = TAILQ_FIRST(&head->so_comp);
TAILQ_REMOVE(&head->so_comp, so, so_list);
head->so_qlen--;
struct socket *so;
#if KTRACE
struct iovec *ktriov = NULL;
+ struct uio ktruio;
#endif
KERNEL_DEBUG(DBG_FNC_SENDIT | DBG_FUNC_START, 0,0,0,0,0);
} else
control = 0;
+#if KTRACE
+ if (KTRPOINT(p, KTR_GENIO)) {
+ int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
+
+ MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
+ bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
+ ktruio = auio;
+ }
+#endif
len = auio.uio_resid;
so = (struct socket *)fp->f_data;
error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control,
if (auio.uio_resid != len && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
error = 0;
- if (error == EPIPE)
+ /* Generation of SIGPIPE can be controlled per socket */
+ if (error == EPIPE && !(so->so_flags & SOF_NOSIGPIPE))
psignal(p, SIGPIPE);
}
if (error == 0)
*retsize = len - auio.uio_resid;
#if KTRACE
if (ktriov != NULL) {
- if (error == 0)
- ktrgenio(p->p_tracep, s, UIO_WRITE,
- ktriov, *retsize, error);
+ if (error == 0) {
+ ktruio.uio_iov = ktriov;
+ ktruio.uio_resid = retsize[0];
+ ktrgenio(p->p_tracep, s, UIO_WRITE, &ktruio, error, -1);
+ }
FREE(ktriov, M_TEMP);
}
#endif
struct sockaddr *fromsa = 0;
#if KTRACE
struct iovec *ktriov = NULL;
+ struct uio ktruio;
#endif
KERNEL_DEBUG(DBG_FNC_RECVIT | DBG_FUNC_START, 0,0,0,0,0);
MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
+ ktruio = auio;
}
#endif
len = auio.uio_resid;
}
#if KTRACE
if (ktriov != NULL) {
- if (error == 0)
- ktrgenio(p->p_tracep, s, UIO_WRITE,
- ktriov, len - auio.uio_resid, error);
+ if (error == 0) {
+ ktruio.uio_iov = ktriov;
+ ktruio.uio_resid = len - auio.uio_resid;
+ ktrgenio(p->p_tracep, s, UIO_WRITE, &ktruio, error, -1);
+ }
FREE(ktriov, M_TEMP);
}
#endif
#ifdef COMPAT_OLDSOCK
+struct orecv_args {
+ int s;
+ caddr_t buf;
+ int len;
+ int flags;
+};
+
int
orecv(p, uap, retval)
struct proc *p;
- register struct orecv_args {
- int s;
- caddr_t buf;
- int len;
- int flags;
- } *uap;
+ struct orecv_args *uap;
register_t *retval;
{
struct msghdr msg;
* overlays the new one, missing only the flags, and with the (old) access
* rights where the control fields are now.
*/
+struct orecvmsg_args {
+ int s;
+ struct omsghdr *msg;
+ int flags;
+};
+
int
orecvmsg(p, uap, retval)
struct proc *p;
- register struct orecvmsg_args {
- int s;
- struct omsghdr *msg;
- int flags;
- } *uap;
+ struct orecvmsg_args *uap;
register_t *retval;
{
struct msghdr msg;
}
#endif
+struct recvmsg_args {
+ int s;
+ struct msghdr *msg;
+ int flags;
+};
+
int
recvmsg(p, uap, retval)
struct proc *p;
- register struct recvmsg_args {
- int s;
- struct msghdr *msg;
- int flags;
- } *uap;
+ struct recvmsg_args *uap;
register_t *retval;
{
struct msghdr msg;
}
/* ARGSUSED */
+struct shutdown_args {
+ int s;
+ int how;
+};
+
int
shutdown(p, uap, retval)
struct proc *p;
- register struct shutdown_args {
- int s;
- int how;
- } *uap;
+ struct shutdown_args *uap;
register_t *retval;
{
struct file *fp;
/* ARGSUSED */
+struct setsockopt_args {
+ int s;
+ int level;
+ int name;
+ caddr_t val;
+ int valsize;
+};
+
int
setsockopt(p, uap, retval)
struct proc *p;
- register struct setsockopt_args {
- int s;
- int level;
- int name;
- caddr_t val;
- int valsize;
- } *uap;
+ struct setsockopt_args *uap;
register_t *retval;
{
struct file *fp;