Module Name: src Committed By: pooka Date: Fri Apr 25 15:52:45 UTC 2014
Modified Files: src/sys/kern: sys_select.c src/sys/netsmb: smb_trantcp.c smb_trantcp.h src/sys/sys: select.h Log Message: 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(). To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/kern/sys_select.c cvs rdiff -u -r1.44 -r1.45 src/sys/netsmb/smb_trantcp.c cvs rdiff -u -r1.6 -r1.7 src/sys/netsmb/smb_trantcp.h cvs rdiff -u -r1.36 -r1.37 src/sys/sys/select.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/sys_select.c diff -u src/sys/kern/sys_select.c:1.38 src/sys/kern/sys_select.c:1.39 --- src/sys/kern/sys_select.c:1.38 Tue Feb 25 18:30:11 2014 +++ src/sys/kern/sys_select.c Fri Apr 25 15:52:45 2014 @@ -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. */ Index: src/sys/netsmb/smb_trantcp.c diff -u src/sys/netsmb/smb_trantcp.c:1.44 src/sys/netsmb/smb_trantcp.c:1.45 --- src/sys/netsmb/smb_trantcp.c:1.44 Wed Aug 31 18:31:04 2011 +++ src/sys/netsmb/smb_trantcp.c Fri Apr 25 15:52:45 2014 @@ -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. 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 @@ nb_setsockopt_int(struct socket *so, int } 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 @@ nb_connect_in(struct nbpcb *nbp, struct 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, stru 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 *le 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 mbu 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 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, in 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; Index: src/sys/netsmb/smb_trantcp.h diff -u src/sys/netsmb/smb_trantcp.h:1.6 src/sys/netsmb/smb_trantcp.h:1.7 --- src/sys/netsmb/smb_trantcp.h:1.6 Tue Jun 24 10:37:19 2008 +++ src/sys/netsmb/smb_trantcp.h Fri Apr 25 15:52:45 2014 @@ -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 Index: src/sys/sys/select.h diff -u src/sys/sys/select.h:1.36 src/sys/sys/select.h:1.37 --- src/sys/sys/select.h:1.36 Wed Nov 11 09:48:51 2009 +++ src/sys/sys/select.h Fri Apr 25 15:52:45 2014 @@ -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, lo void selsysinit(struct cpu_info *); void selinit(struct selinfo *); void seldestroy(struct selinfo *); -int pollsock(struct socket *, const struct timespec *, int); #else /* _KERNEL */