Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add a direction argument to socket upcalls, so they can ...
details: https://anonhg.NetBSD.org/src/rev/308e49f9bf78
branches: trunk
changeset: 747100:308e49f9bf78
user: tls <tls%NetBSD.org@localhost>
date: Wed Sep 02 14:56:57 2009 +0000
description:
Add a direction argument to socket upcalls, so they can tell why they've
been called when, for example, they're waiting for space to write. From
Ritesh Agrawal at Coyote Point.
diffstat:
sys/kern/uipc_socket2.c | 9 +++++----
sys/net/if_gre.c | 6 +++---
sys/netinet/accf_data.c | 8 ++++----
sys/netinet/accf_http.c | 22 +++++++++++-----------
sys/sys/socketvar.h | 10 +++++-----
5 files changed, 28 insertions(+), 27 deletions(-)
diffs (214 lines):
diff -r 40b6f6c2b14d -r 308e49f9bf78 sys/kern/uipc_socket2.c
--- a/sys/kern/uipc_socket2.c Wed Sep 02 11:44:11 2009 +0000
+++ b/sys/kern/uipc_socket2.c Wed Sep 02 14:56:57 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket2.c,v 1.103 2009/07/24 01:09:49 christos Exp $ */
+/* $NetBSD: uipc_socket2.c,v 1.104 2009/09/02 14:56:57 tls Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.103 2009/07/24 01:09:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.104 2009/09/02 14:56:57 tls Exp $");
#include "opt_mbuftrace.h"
#include "opt_sb_max.h"
@@ -190,7 +190,8 @@
so->so_upcallarg = head->so_accf->so_accept_filter_arg;
so->so_rcv.sb_flags |= SB_UPCALL;
so->so_options &= ~SO_ACCEPTFILTER;
- (*so->so_upcall)(so, so->so_upcallarg, M_DONTWAIT);
+ (*so->so_upcall)(so, so->so_upcallarg,
+ POLLIN|POLLRDNORM, M_DONTWAIT);
}
} else {
cv_broadcast(&so->so_cv);
@@ -472,7 +473,7 @@
if (sb->sb_flags & SB_ASYNC)
fownsignal(so->so_pgid, SIGIO, code, band, so);
if (sb->sb_flags & SB_UPCALL)
- (*so->so_upcall)(so, so->so_upcallarg, M_DONTWAIT);
+ (*so->so_upcall)(so, so->so_upcallarg, band, M_DONTWAIT);
}
/*
diff -r 40b6f6c2b14d -r 308e49f9bf78 sys/net/if_gre.c
--- a/sys/net/if_gre.c Wed Sep 02 11:44:11 2009 +0000
+++ b/sys/net/if_gre.c Wed Sep 02 14:56:57 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gre.c,v 1.140 2009/04/28 23:05:25 dyoung Exp $ */
+/* $NetBSD: if_gre.c,v 1.141 2009/09/02 14:56:57 tls Exp $ */
/*
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.140 2009/04/28 23:05:25 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.141 2009/09/02 14:56:57 tls Exp $");
#include "opt_atalk.h"
#include "opt_gre.h"
@@ -419,7 +419,7 @@
}
static void
-gre_receive(struct socket *so, void *arg, int waitflag)
+gre_receive(struct socket *so, void *arg, int events, int waitflag)
{
struct gre_softc *sc = (struct gre_softc *)arg;
int rc;
diff -r 40b6f6c2b14d -r 308e49f9bf78 sys/netinet/accf_data.c
--- a/sys/netinet/accf_data.c Wed Sep 02 11:44:11 2009 +0000
+++ b/sys/netinet/accf_data.c Wed Sep 02 14:56:57 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: accf_data.c,v 1.5 2008/11/20 10:22:11 ad Exp $ */
+/* $NetBSD: accf_data.c,v 1.6 2009/09/02 14:56:57 tls Exp $ */
/*-
* Copyright (c) 2000 Alfred Perlstein <alfred%FreeBSD.org@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: accf_data.c,v 1.5 2008/11/20 10:22:11 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: accf_data.c,v 1.6 2009/09/02 14:56:57 tls Exp $");
#define ACCEPT_FILTER_MOD
@@ -44,7 +44,7 @@
/* accept filter that holds a socket until data arrives */
-static void sohasdata(struct socket *so, void *arg, int waitflag);
+static void sohasdata(struct socket *so, void *arg, int events, int waitflag);
static struct accept_filter accf_data_filter = {
.accf_name = "dataready",
@@ -77,7 +77,7 @@
}
static void
-sohasdata(struct socket *so, void *arg, int waitflag)
+sohasdata(struct socket *so, void *arg, int events, int waitflag)
{
if (!soreadable(so))
diff -r 40b6f6c2b14d -r 308e49f9bf78 sys/netinet/accf_http.c
--- a/sys/netinet/accf_http.c Wed Sep 02 11:44:11 2009 +0000
+++ b/sys/netinet/accf_http.c Wed Sep 02 14:56:57 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: accf_http.c,v 1.6 2008/11/21 16:08:57 joerg Exp $ */
+/* $NetBSD: accf_http.c,v 1.7 2009/09/02 14:56:57 tls Exp $ */
/*-
* Copyright (c) 2000 Paycounter, Inc.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: accf_http.c,v 1.6 2008/11/21 16:08:57 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: accf_http.c,v 1.7 2009/09/02 14:56:57 tls Exp $");
#define ACCEPT_FILTER_MOD
@@ -46,11 +46,11 @@
MODULE(MODULE_CLASS_MISC, accf_httpready, NULL);
/* check for GET/HEAD */
-static void sohashttpget(struct socket *so, void *arg, int waitflag);
+static void sohashttpget(struct socket *so, void *arg, int events, int waitflag);
/* check for HTTP/1.0 or HTTP/1.1 */
-static void soparsehttpvers(struct socket *so, void *arg, int waitflag);
+static void soparsehttpvers(struct socket *so, void *arg, int events, int waitflag);
/* check for end of HTTP/1.x request */
-static void soishttpconnected(struct socket *so, void *arg, int waitflag);
+static void soishttpconnected(struct socket *so, void *arg, int events, int waitflag);
/* strcmp on an mbuf chain */
static int mbufstrcmp(struct mbuf *m, struct mbuf *npkt, int offset, const char *cmp);
/* strncmp on an mbuf chain */
@@ -221,7 +221,7 @@
} while(0)
static void
-sohashttpget(struct socket *so, void *arg, int waitflag)
+sohashttpget(struct socket *so, void *arg, int events, int waitflag)
{
if ((so->so_state & SS_CANTRCVMORE) == 0 && !sbfull(&so->so_rcv)) {
@@ -255,9 +255,9 @@
if (mbufstrcmp(m, m->m_nextpkt, 1, cmp) == 1) {
DPRINT("mbufstrcmp ok");
if (parse_http_version == 0)
- soishttpconnected(so, arg, waitflag);
+ soishttpconnected(so, arg, events, waitflag);
else
- soparsehttpvers(so, arg, waitflag);
+ soparsehttpvers(so, arg, events, waitflag);
return;
}
DPRINT("mbufstrcmp bad");
@@ -272,7 +272,7 @@
}
static void
-soparsehttpvers(struct socket *so, void *arg, int waitflag)
+soparsehttpvers(struct socket *so, void *arg, int events, int waitflag)
{
struct mbuf *m, *n;
int i, cc, spaces, inspaces;
@@ -325,7 +325,7 @@
mbufstrcmp(m, n, i, "HTTP/1.1")) {
DPRINT("ok");
soishttpconnected(so,
- arg, waitflag);
+ arg, events, waitflag);
return;
} else {
DPRINT("bad");
@@ -357,7 +357,7 @@
#define NCHRS 3
static void
-soishttpconnected(struct socket *so, void *arg, int waitflag)
+soishttpconnected(struct socket *so, void *arg, int events, int waitflag)
{
char a, b, c;
struct mbuf *m, *n;
diff -r 40b6f6c2b14d -r 308e49f9bf78 sys/sys/socketvar.h
--- a/sys/sys/socketvar.h Wed Sep 02 11:44:11 2009 +0000
+++ b/sys/sys/socketvar.h Wed Sep 02 14:56:57 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socketvar.h,v 1.119 2009/04/04 10:12:52 ad Exp $ */
+/* $NetBSD: socketvar.h,v 1.120 2009/09/02 14:56:57 tls Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -159,7 +159,7 @@
struct sockbuf so_rcv; /* receive buffer */
void *so_internal; /* Space for svr4 stream data */
- void (*so_upcall) (struct socket *, void *, int);
+ void (*so_upcall) (struct socket *, void *, int, int);
void * so_upcallarg; /* Arg for above */
int (*so_send) (struct socket *, struct mbuf *,
struct uio *, struct mbuf *,
@@ -214,11 +214,11 @@
struct accept_filter {
char accf_name[16];
void (*accf_callback)
- (struct socket *so, void *arg, int waitflag);
+ (struct socket *, void *, int, int);
void * (*accf_create)
- (struct socket *so, char *arg);
+ (struct socket *, char *);
void (*accf_destroy)
- (struct socket *so);
+ (struct socket *);
LIST_ENTRY(accept_filter) accf_next;
u_int accf_refcnt;
};
Home |
Main Index |
Thread Index |
Old Index