From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 19 11:39:38 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F11A7106564A for ; Fri, 19 Aug 2011 11:39:38 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id B10098FC13 for ; Fri, 19 Aug 2011 11:39:38 +0000 (UTC) Received: by gwb15 with SMTP id 15so1822668gwb.13 for ; Fri, 19 Aug 2011 04:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=UKvonWTlHXKEur35X5so4XmRmZQEq/lXluS5tsAk7Sw=; b=aRo1+iMKH9Ogdeo6IMKZonlgY/ysZYhdxyrRR5r99BWgNZo4c/+vEBVhNfKcDYG069 5PaoERl383juEe/NxjWyqFytNsdOnVPUncnpfVTL/hQmZ0/rH3TQtnU72U9UqSsw08VV h2/1K95LOx0Gs6Hqc1CJHSTej4MuJLRfJRe5Q= MIME-Version: 1.0 Received: by 10.151.12.1 with SMTP id p1mr2187421ybi.272.1313752251894; Fri, 19 Aug 2011 04:10:51 -0700 (PDT) Sender: adrian.chadd@gmail.com Received: by 10.150.145.21 with HTTP; Fri, 19 Aug 2011 04:10:51 -0700 (PDT) In-Reply-To: References: Date: Fri, 19 Aug 2011 19:10:51 +0800 X-Google-Sender-Auth: Bu4-lmxmkl9x7uz4v4CkBbf8Pp8 Message-ID: From: Adrian Chadd To: about bus Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: Kqueue + Libevent X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2011 11:39:39 -0000 I've not seen this happen before, are you sure that libevent's kqueue code is properly removing all the pending events for a given FD when it's closed? Adrian On 19 August 2011 18:33, about bus wrote: > Hello! > > I've got some interesting problem with my own server which use Libevent a= nd > Kqueue. > Kqueue holds some sockets for a long time (while reading data) and gives = it > back to application when another side closes connection. > > I have server with FreeBSD 7.2 which serves several thousands requests pe= r > second. > Nginx -> statical requests, images > =A0 =A0 =A0 =A0 -> backend for dynamical requests: Libevent based http se= rver > written on C > > Sometimes, about 0.1% of request, Nginx displays error: "Operation timed = out > while reading response from upstream." > Switching Libevent from Kqueue to Poll in my http server fixes the proble= m. > Poll works fine without errors in Nginx log file. > > Debug output for timeouted requests from Libevent: > 1) Libevent accepts incoming connection from Nginx. > 2) Libevent adds socket to Kqueue for waiting incoming data with HTTP > request. > 3) No events on socket for 60 seconds, no received data. (60 - timeout va= lue > in Nginx config) > 4) On the another side Nginx closes connection and displays timeout error= . > 5) At the same time Kqueue reports about incoming data and returns socket= to > Libevent. > 6) Libevent reads correct HTTP request from socket and passes it to my > handler. > > Why Kqueue does not reports about read event for so long time? > Why Kqueue do it only when another side closes connection? > It is strange, because Poll does not have such problems. > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org= " >