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().
This commit is contained in:
pooka 2014-04-25 15:52:45 +00:00
parent 1fa48c8c01
commit 2324105436
4 changed files with 25 additions and 94 deletions

View File

@ -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 @@ seldestroy(struct selinfo *sip)
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.
*/

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: smb_trantcp.c,v 1.44 2011/08/31 18:31:04 plunky Exp
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
@ -112,14 +111,6 @@ nb_setsockopt_int(struct socket *so, int level, int name, int val)
return so_setsockopt(NULL, so, level, name, &val, sizeof(val)); /* XXX */
}
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)
{
@ -184,8 +175,8 @@ nb_connect_in(struct nbpcb *nbp, struct sockaddr_in *to, struct lwp *l)
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 @@ nbssn_rq_request(struct nbpcb *nbp, struct lwp *l)
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 @@ nbssn_recvhdr(struct nbpcb *nbp, int *lenp,
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 @@ nbssn_recv(struct nbpcb *nbp, struct mbuf **mpp, int *lenp,
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 @@ smb_nbst_recv(struct smb_vc *vcp, struct mbuf **mpp, struct lwp *l)
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 @@ smb_nbst_getparam(struct smb_vc *vcp, int param, void *data)
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;

View File

@ -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 @@ struct nbpcb {
#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

View File

@ -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 selnotify(struct selinfo *, int, long);
void selsysinit(struct cpu_info *);
void selinit(struct selinfo *);
void seldestroy(struct selinfo *);
int pollsock(struct socket *, const struct timespec *, int);
#else /* _KERNEL */