From owner-svn-src-head@freebsd.org Wed Feb 1 13:12:09 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2B8B0CC226B; Wed, 1 Feb 2017 13:12:09 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D6FCAF59; Wed, 1 Feb 2017 13:12:08 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v11DC7HA085026; Wed, 1 Feb 2017 13:12:07 GMT (envelope-from harti@FreeBSD.org) Received: (from harti@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v11DC7WJ085025; Wed, 1 Feb 2017 13:12:07 GMT (envelope-from harti@FreeBSD.org) Message-Id: <201702011312.v11DC7WJ085025@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: harti set sender to harti@FreeBSD.org using -f From: Hartmut Brandt Date: Wed, 1 Feb 2017 13:12:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313043 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Feb 2017 13:12:09 -0000 Author: harti Date: Wed Feb 1 13:12:07 2017 New Revision: 313043 URL: https://svnweb.freebsd.org/changeset/base/313043 Log: Merge filt_soread and filt_solisten and decide what to do when checking for EVFILT_READ at the point of the check not when the event is registers. This fixes a problem with asio when accepting a connection. Reviewed by: kib@, Scott Mitchell Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c ============================================================================== --- head/sys/kern/uipc_socket.c Wed Feb 1 08:46:59 2017 (r313042) +++ head/sys/kern/uipc_socket.c Wed Feb 1 13:12:07 2017 (r313043) @@ -159,16 +159,10 @@ static void filt_sordetach(struct knote static int filt_soread(struct knote *kn, long hint); static void filt_sowdetach(struct knote *kn); static int filt_sowrite(struct knote *kn, long hint); -static int filt_solisten(struct knote *kn, long hint); static int inline hhook_run_socket(struct socket *so, void *hctx, int32_t h_id); static int filt_soempty(struct knote *kn, long hint); fo_kqfilter_t soo_kqfilter; -static struct filterops solisten_filtops = { - .f_isfd = 1, - .f_detach = filt_sordetach, - .f_event = filt_solisten, -}; static struct filterops soread_filtops = { .f_isfd = 1, .f_detach = filt_sordetach, @@ -3107,10 +3101,7 @@ soo_kqfilter(struct file *fp, struct kno switch (kn->kn_filter) { case EVFILT_READ: - if (so->so_options & SO_ACCEPTCONN) - kn->kn_fop = &solisten_filtops; - else - kn->kn_fop = &soread_filtops; + kn->kn_fop = &soread_filtops; sb = &so->so_rcv; break; case EVFILT_WRITE: @@ -3321,6 +3312,11 @@ filt_soread(struct knote *kn, long hint) struct socket *so; so = kn->kn_fp->f_data; + if (so->so_options & SO_ACCEPTCONN) { + kn->kn_data = so->so_qlen; + return (!TAILQ_EMPTY(&so->so_comp)); + + } SOCKBUF_LOCK_ASSERT(&so->so_rcv); kn->kn_data = sbavail(&so->so_rcv) - so->so_rcv.sb_ctl; @@ -3333,11 +3329,9 @@ filt_soread(struct knote *kn, long hint) if (kn->kn_sfflags & NOTE_LOWAT) { if (kn->kn_data >= kn->kn_sdata) - return 1; - } else { - if (sbavail(&so->so_rcv) >= so->so_rcv.sb_lowat) - return 1; - } + return (1); + } else if (sbavail(&so->so_rcv) >= so->so_rcv.sb_lowat) + return (1); /* This hook returning non-zero indicates an event, not error */ return (hhook_run_socket(so, NULL, HHOOK_FILT_SOREAD)); @@ -3397,16 +3391,6 @@ filt_soempty(struct knote *kn, long hint return (0); } -/*ARGSUSED*/ -static int -filt_solisten(struct knote *kn, long hint) -{ - struct socket *so = kn->kn_fp->f_data; - - kn->kn_data = so->so_qlen; - return (!TAILQ_EMPTY(&so->so_comp)); -} - int socheckuid(struct socket *so, uid_t uid) {