summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2012-07-10 09:40:26 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2012-07-10 09:40:26 +0000
commitb0bc89b175be423fa0d76a862098676bd3303d26 (patch)
tree09abba35c9debb56987e816537142ba49ba22b57 /sys
parent4002041a3851c90f39e2583f12e2caca85d95677 (diff)
Try to cleanup the macro magic because of socket spliceing. Since struct
socket is no longer affected by option SOCKET_SPLICE we can simplyfy the code. OK bluhm@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_socket.c18
-rw-r--r--sys/sys/socketvar.h27
2 files changed, 17 insertions, 28 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 8f2be3a7261..10b1fa202b0 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.101 2012/07/07 18:48:19 bluhm Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.102 2012/07/10 09:40:25 claudio Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -1268,16 +1268,14 @@ somove(struct socket *so, int wait)
if (o) {
error = (*sosp->so_proto->pr_usrreq)(sosp,
PRU_SEND, m, NULL, NULL, NULL);
- m = NULL;
+ m = o;
if (error) {
- m_freem(o);
if (sosp->so_state & SS_CANTSENDMORE)
error = EPIPE;
goto release;
}
len -= oobmark;
so->so_splicelen += oobmark;
- m = o;
o = m_get(wait, MT_DATA);
}
oobmark = 0;
@@ -1333,25 +1331,33 @@ somove(struct socket *so, int wait)
timeout_add_tv(&so->so_idleto, &so->so_idletv);
return (1);
}
+#endif /* SOCKET_SPLICE */
void
sorwakeup(struct socket *so)
{
+#ifdef SOCKET_SPLICE
if (so->so_rcv.sb_flags & SB_SPLICE) {
(void) somove(so, M_DONTWAIT);
return;
}
- _sorwakeup(so);
+#endif
+ sowakeup(so, &so->so_rcv);
+ if (so->so_upcall)
+ (*(so->so_upcall))(so, so->so_upcallarg, M_DONTWAIT);
}
void
sowwakeup(struct socket *so)
{
+#ifdef SOCKET_SPLICE
if (so->so_snd.sb_flags & SB_SPLICE)
(void) somove(so->so_spliceback, M_DONTWAIT);
- _sowwakeup(so);
+#endif
+ sowakeup(so, &so->so_snd);
}
+#ifdef SOCKET_SPLICE
void
soidle(void *arg)
{
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
index 709a314d439..f4ec198099e 100644
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: socketvar.h,v 1.50 2011/07/04 22:53:53 tedu Exp $ */
+/* $OpenBSD: socketvar.h,v 1.51 2012/07/10 09:40:25 claudio Exp $ */
/* $NetBSD: socketvar.h,v 1.18 1996/02/09 18:25:38 christos Exp $ */
/*-
@@ -77,14 +77,12 @@ struct socket {
uid_t so_sigeuid; /* euid of process who set so_pgid */
u_long so_oobmark; /* chars to oob mark */
-#if 1 /*def SOCKET_SPLICE*/
struct socket *so_splice; /* send data to drain socket */
struct socket *so_spliceback; /* back ref for notify and cleanup */
off_t so_splicelen; /* number of bytes spliced so far */
off_t so_splicemax; /* maximum number of bytes to splice */
struct timeval so_idletv; /* idle timeout */
struct timeout so_idleto;
-#endif /* SOCKET_SPLICE */
/*
* Variables for socket buffering.
*/
@@ -175,10 +173,11 @@ struct socket {
((so)->so_state & SS_ISSENDING)
/* can we read something from so? */
-#define _soreadable(so) \
+#define soreadable(so) \
+ ((so)->so_splice == NULL && \
((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \
- ((so)->so_state & SS_CANTRCVMORE) || \
- (so)->so_qlen || (so)->so_error)
+ ((so)->so_state & SS_CANTRCVMORE) || \
+ (so)->so_qlen || (so)->so_error))
/* can we write something to so? */
#define sowriteable(so) \
@@ -225,24 +224,8 @@ struct socket {
} \
} while (/* CONSTCOND */ 0)
-#define _sorwakeup(so) do { \
- sowakeup((so), &(so)->so_rcv); \
- if ((so)->so_upcall) \
- (*((so)->so_upcall))((so), (so)->so_upcallarg, \
- M_DONTWAIT); \
-} while (/* CONSTCOND */ 0)
-
-#define _sowwakeup(so) sowakeup((so), &(so)->so_snd)
-
-#ifdef SOCKET_SPLICE
-#define soreadable(so) ((so)->so_splice == NULL && _soreadable(so))
void sorwakeup(struct socket *);
void sowwakeup(struct socket *);
-#else /* SOCKET_SPLICE */
-#define soreadable(so) _soreadable(so)
-#define sorwakeup(so) _sorwakeup(so)
-#define sowwakeup(so) _sowwakeup(so)
-#endif /* SOCKET_SPLICE */
#ifdef _KERNEL
extern u_long sb_max;