Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Remove pollsock(). Since it took only a single socket, ...
details: https://anonhg.NetBSD.org/src/rev/c58e252c6cf8
branches: trunk
changeset: 328946:c58e252c6cf8
user: pooka <pooka%NetBSD.org@localhost>
date: Fri Apr 25 15:52:45 2014 +0000
description:
Remove pollsock(). Since it took only a single socket, it was essentially
a complicated way to call soreceive() with a sb_timeo. The only user
(netsmb) already did that anyway, so just had to delete the call to
pollsock().
diffstat:
sys/kern/sys_select.c | 62 +----------------------------------------------
sys/netsmb/smb_trantcp.c | 46 +++++++++++++---------------------
sys/netsmb/smb_trantcp.h | 8 +++---
sys/sys/select.h | 3 +-
4 files changed, 25 insertions(+), 94 deletions(-)
diffs (249 lines):
diff -r b6bc1541b4e9 -r c58e252c6cf8 sys/kern/sys_select.c
--- a/sys/kern/sys_select.c Fri Apr 25 15:51:12 2014 +0000
+++ b/sys/kern/sys_select.c Fri Apr 25 15:52:45 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_select.c,v 1.38 2014/02/25 18:30:11 pooka Exp $ */
+/* $NetBSD: sys_select.c,v 1.39 2014/04/25 15:52:45 pooka Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
@@ -84,7 +84,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.38 2014/02/25 18:30:11 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_select.c,v 1.39 2014/04/25 15:52:45 pooka Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -875,64 +875,6 @@
mutex_spin_exit(lock);
}
-int
-pollsock(struct socket *so, const struct timespec *tsp, int events)
-{
- int ncoll, error, timo;
- struct timespec sleepts, ts;
- selcluster_t *sc;
- lwp_t *l;
- kmutex_t *lock;
-
- timo = 0;
- if (tsp != NULL) {
- ts = *tsp;
- if (inittimeleft(&ts, &sleepts) == -1)
- return EINVAL;
- }
-
- l = curlwp;
- sc = curcpu()->ci_data.cpu_selcluster;
- lock = sc->sc_lock;
- l->l_selcluster = sc;
- SLIST_INIT(&l->l_selwait);
- error = 0;
- for (;;) {
- /*
- * No need to lock. If this is overwritten by another
- * value while scanning, we will retry below. We only
- * need to see exact state from the descriptors that
- * we are about to poll, and lock activity resulting
- * from fo_poll is enough to provide an up to date value
- * for new polling activity.
- */
- ncoll = sc->sc_ncoll;
- l->l_selflag = SEL_SCANNING;
- if (sopoll(so, events) != 0)
- break;
- if (tsp && (timo = gettimeleft(&ts, &sleepts)) <= 0)
- break;
- mutex_spin_enter(lock);
- if (l->l_selflag != SEL_SCANNING || sc->sc_ncoll != ncoll) {
- mutex_spin_exit(lock);
- continue;
- }
- l->l_selflag = SEL_BLOCKING;
- sleepq_enter(&sc->sc_sleepq, l, lock);
- sleepq_enqueue(&sc->sc_sleepq, sc, "pollsock", &select_sobj);
- error = sleepq_block(timo, true);
- if (error != 0)
- break;
- }
- selclear();
- /* poll is not restarted after signals... */
- if (error == ERESTART)
- error = EINTR;
- if (error == EWOULDBLOCK)
- error = 0;
- return (error);
-}
-
/*
* System control nodes.
*/
diff -r b6bc1541b4e9 -r c58e252c6cf8 sys/netsmb/smb_trantcp.c
--- a/sys/netsmb/smb_trantcp.c Fri Apr 25 15:51:12 2014 +0000
+++ b/sys/netsmb/smb_trantcp.c Fri Apr 25 15:52:45 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: smb_trantcp.c,v 1.44 2011/08/31 18:31:04 plunky Exp $ */
+/* $NetBSD: smb_trantcp.c,v 1.45 2014/04/25 15:52:45 pooka Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smb_trantcp.c,v 1.44 2011/08/31 18:31:04 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smb_trantcp.c,v 1.45 2014/04/25 15:52:45 pooka Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -96,13 +96,12 @@
static int nb_tcpsndbuf = NB_SNDQ;
static int nb_tcprcvbuf = NB_RCVQ;
-static const struct timespec nb_timo = { 15, 0 }; /* XXX sysctl? */
#define nb_sosend(so,m,flags,l) (*(so)->so_send)(so, NULL, (struct uio *)0, \
m, (struct mbuf *)0, flags, l)
static int nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp,
- u_int8_t *rpcodep, struct lwp *l);
+ u_int8_t *rpcodep, bool firstwait, struct lwp *l);
static int smb_nbst_disconnect(struct smb_vc *vcp, struct lwp *l);
static int
@@ -113,14 +112,6 @@
}
static int
-nbssn_rselect(struct nbpcb *nbp, const struct timespec *ts, int events,
- struct lwp *l)
-{
-
- return pollsock(nbp->nbp_tso, ts, events);
-}
-
-static int
nb_intr(struct nbpcb *nbp, struct lwp *l)
{
return 0;
@@ -184,8 +175,8 @@
so->so_rcv.sb_flags |= SB_UPCALL;
so->so_rcv.sb_flags &= ~SB_NOINTR;
so->so_snd.sb_flags &= ~SB_NOINTR;
- so->so_rcv.sb_timeo = NB_SNDTIMEO;
- so->so_snd.sb_timeo = NB_RCVTIMEO;
+ so->so_rcv.sb_timeo = NB_RCVTIMEO * hz;
+ so->so_snd.sb_timeo = NB_RCVTIMEO * hz;
error = soreserve(so, nb_tcpsndbuf, nb_tcprcvbuf);
sounlock(so);
if (error)
@@ -250,15 +241,13 @@
mb_done(mbp);
if (error)
return error;
- error = nbssn_rselect(nbp, &nb_timo, POLLIN, l);
- if (error == EWOULDBLOCK) { /* Timeout */
- NBDEBUG(("initial request timeout\n"));
- return ETIMEDOUT;
- }
- if (error) /* restart or interrupt */
- return error;
- error = nbssn_recv(nbp, &m0, &rplen, &rpcode, l);
+ error = nbssn_recv(nbp, &m0, &rplen, &rpcode, true, l);
if (error) {
+ if (error == EWOULDBLOCK) { /* Timeout */
+ printf("would blockn\n");
+ NBDEBUG(("initial request timeout\n"));
+ return ETIMEDOUT;
+ }
NBDEBUG(("recv() error %d\n", error));
return error;
}
@@ -338,7 +327,7 @@
static int
nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp,
- u_int8_t *rpcodep, struct lwp *l)
+ u_int8_t *rpcodep, bool dowait, struct lwp *l)
{
struct socket *so = nbp->nbp_tso;
struct uio auio;
@@ -356,12 +345,13 @@
if (mpp)
*mpp = NULL;
m = NULL;
- for(;;) {
+ for(;; dowait = false) {
/*
* Poll for a response header.
* If we don't have one waiting, return.
*/
- error = nbssn_recvhdr(nbp, &len, &rpcode, MSG_DONTWAIT, l);
+ error = nbssn_recvhdr(nbp, &len, &rpcode,
+ dowait ? 0 : MSG_DONTWAIT, l);
if (so->so_state &
(SS_ISDISCONNECTING | SS_ISDISCONNECTED | SS_CANTRCVMORE)) {
nbp->nbp_state = NBST_CLOSED;
@@ -606,7 +596,7 @@
int error, rplen;
nbp->nbp_flags |= NBF_RECVLOCK;
- error = nbssn_recv(nbp, mpp, &rplen, &rpcode, l);
+ error = nbssn_recv(nbp, mpp, &rplen, &rpcode, false, l);
nbp->nbp_flags &= ~NBF_RECVLOCK;
return error;
}
@@ -646,8 +636,8 @@
break;
case SMBTP_TIMEOUT:
tvp = (struct timeval *)data;
- tvp->tv_sec = nb_timo.tv_sec;
- tvp->tv_usec = nb_timo.tv_nsec / 1000;
+ tvp->tv_sec = NB_RCVTIMEO;
+ tvp->tv_usec = 0;
break;
default:
return EINVAL;
diff -r b6bc1541b4e9 -r c58e252c6cf8 sys/netsmb/smb_trantcp.h
--- a/sys/netsmb/smb_trantcp.h Fri Apr 25 15:51:12 2014 +0000
+++ b/sys/netsmb/smb_trantcp.h Fri Apr 25 15:52:45 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: smb_trantcp.h,v 1.6 2008/06/24 10:37:19 gmcgarry Exp $ */
+/* $NetBSD: smb_trantcp.h,v 1.7 2014/04/25 15:52:45 pooka Exp $ */
/*
* Copyright (c) 2000-2001, Boris Popov
@@ -82,10 +82,10 @@
#define NB_RCVQ (64 * 1024)
/*
- * Timeouts used for send/receive. XXX Sysctl this?
+ * Timeouts (s) used for send/receive. XXX Sysctl this?
*/
-#define NB_SNDTIMEO (5 * hz)
-#define NB_RCVTIMEO (5 * hz)
+#define NB_SNDTIMEO (5)
+#define NB_RCVTIMEO (5)
/*
* TCP slowstart presents a problem in conjunction with large
diff -r b6bc1541b4e9 -r c58e252c6cf8 sys/sys/select.h
--- a/sys/sys/select.h Fri Apr 25 15:51:12 2014 +0000
+++ b/sys/sys/select.h Fri Apr 25 15:52:45 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: select.h,v 1.36 2009/11/11 09:48:51 rmind Exp $ */
+/* $NetBSD: select.h,v 1.37 2014/04/25 15:52:45 pooka Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -55,7 +55,6 @@
void selsysinit(struct cpu_info *);
void selinit(struct selinfo *);
void seldestroy(struct selinfo *);
-int pollsock(struct socket *, const struct timespec *, int);
#else /* _KERNEL */
Home |
Main Index |
Thread Index |
Old Index