Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Mar 2008 18:05:26 +0200
From:      "Vlad GALU" <dudu@dudu.ro>
To:        "Dan Nelson" <dnelson@allantgroup.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: A (perhaps silly) kqueue question
Message-ID:  <ad79ad6b0803140905s1ec8a730u15bc728077c430aa@mail.gmail.com>
In-Reply-To: <20080314153801.GB30116@dan.emsphone.com>
References:  <ad79ad6b0803070847v7464381en958ef73455ed9c89@mail.gmail.com> <20080307223723.X42870@fledge.watson.org> <ad79ad6b0803080009w45fc866euf43ea7e9dbf6b5f5@mail.gmail.com> <ad79ad6b0803140530td3376b8v9307628ed147a89d@mail.gmail.com> <ad79ad6b0803140553j2b509e8alf17696f268eeb350@mail.gmail.com> <20080314153801.GB30116@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 3/14/08, Dan Nelson <dnelson@allantgroup.com> wrote:
> In the last episode (Mar 14), Vlad GALU said:
>  > On 3/14/08, Vlad GALU <dudu@dudu.ro> wrote:
>  > > On 3/8/08, Vlad GALU <dudu@dudu.ro> wrote:
>  > > > On 3/8/08, Robert Watson <rwatson@freebsd.org> wrote:
>  > > > > On Fri, 7 Mar 2008, Vlad GALU wrote:
>  > > > > > I see an unusual symptom with one of our in-house
>  > > > > > applications. The main I/O loop calls kevent(), which in turn
>  > > > > > returns two events with EV_EOF error set, always for the same
>  > > > > > descriptors (they're both socket descriptors). As the man
>  > > > > > page is not pretty clear about it and I don't have my UNP
>  > > > > > copy at hand, I would like to ask the list whether the error
>  > > > > > events are supposed to be one-shot or not.
>  > > > >
>  > > > >  I wonder if it's returning one event for the read socket
>  > > > >  buffer, and one event for the write socket buffer, since there
>  > > > >  are really two event sources for each socket?  Not that this
>  > > > >  is desirable behavior, but it might explain it.  If you
>  > > > >  shutdown() only read, do you get back one EOF kevent and one
>  > > > >  writable kevent?
>  > > >
>  > > >  I'll try that and see. The only issue being the low frequency
>  > > >  this symptom appears at. I'll get back to the list once I have
>  > > >  more info.
>  > >
>  > >  Haven't gotten to the point of testing shutdown() behavior, but
>  > >  here's a truss excerpt of the symptom:
>  > >
>  > >  -- cut here --
>  > >  kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2)
>  > >  kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2)
>  > >  kevent(3,0x0,0,{0x7,EVFILT_WRITE,EV_EOF,54,0x832c,0x800d08080 0x7,EVFILT_READ,EV_EOF,54,0x2a,0x800d08080},1024,0x0) = 2 (0x2)
>
> > >  -- and here --
>  > >
>  > >  So two EOF are returrned for descriptor 7, and errno would be
>  > >  ECONNRESET. The question is now, why isn't it oneshot?
>  >
>  > Ah one more thing. When EOF is caught, a handler which forcibly
>  > removes the event is called, but it keeps poping up again and again.
>
>
> Are you sure the event is being removed?  I used to have a hack that
>  made the kernel return its current eventlist for a kqueue when you
>  called kevent() with nchanges set to -1 (handy for placing in a program
>  and using truss to print the result), but it has rotted.  I'm attaching
>  it in case anyone wants to make it work again.
>

   Yep, I'm sure, I've just read the app logs again, we close the
descriptor in the connection destructor..

>  Since you got EOF status for both the read and write halves of the
>  socket, why not just close the fd?  From my reading of the manpages,
>  unless you specified EV_ONESHOT when you added the event, events will
>  fire until you remove them or the condition that triggers them stops.
>
>
>  --
>         Dan Nelson
>         dnelson@allantgroup.com
>
>


-- 
Mahnahmahnah!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ad79ad6b0803140905s1ec8a730u15bc728077c430aa>