Re: [Libevent-users] Must delete events before closing the socket handle
On Fri, Sep 18, 2009, Nick Mathewson wrote: Right now most of the clue is in the reference book thing I've started writing. The source for it is here, in Git: git://git.torproject.org/~nickm/git/lebook.git Right. I'm glad to apply patches or pull contributions from other people's repositories. There's no wiki; if somebody knows a good wiki host that we should use, I'd be glad to set one up for non-book things, though I'd like to concentrate as much clue in the book as possible. Sure. I think it'd be a worthwhile exercise though to have a formal API document shipped with the source code which explains what is going on; versus just the manpage which is a good high level overview but it doesn't explain the what or why. I'll see what I can sort out at my end in my obviously copiously free time. :) Adrian ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] Must delete events before closing the socket handle
I just resolved a similar issue today, where I needed to close a file descriptor AFTER deleting an event. My symptoms, though, were different. What underlying mechanism is your libevent using ? In my case it is epoll. With select or poll my scenario had no problems, in spite of the wrong order. From: libevent-users-boun...@monkey.org [mailto:libevent-users-boun...@monkey.org] On Behalf Of Clint Webb Sent: Thursday, September 17, 2009 7:46 PM To: libevent-users@monkey.org Subject: [Libevent-users] Must delete events before closing the socket handle Hello everyone, After spending over a week debugging a project I am working on, I have discovered that you must delete any persistent events BEFORE you close the socket handle. Just letting other people know who might not have noticed it before. The symptom will be that the next time the same socket handle is assigned, events will not fire when data arrives on the socket. In some cases I was getting segfaults. I've attached some code that will echo what it receives. It can be used to demonstrate what happens. -- Be excellent to each other ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] Must delete events before closing the socket handle
Well, the order of which you can do this depends on what the underlying OS will do for you. I'd suggest sticking to delete event, close socket usage. Anything else isn't portable. Nick, is this actually documented anywhere? Adrian On Thu, Sep 17, 2009, Gilad Benjamini wrote: I just resolved a similar issue today, where I needed to close a file descriptor AFTER deleting an event. My symptoms, though, were different. What underlying mechanism is your libevent using ? In my case it is epoll. With select or poll my scenario had no problems, in spite of the wrong order. From: libevent-users-boun...@monkey.org [mailto:libevent-users-boun...@monkey.org] On Behalf Of Clint Webb Sent: Thursday, September 17, 2009 7:46 PM To: libevent-users@monkey.org Subject: [Libevent-users] Must delete events before closing the socket handle Hello everyone, After spending over a week debugging a project I am working on, I have discovered that you must delete any persistent events BEFORE you close the socket handle. Just letting other people know who might not have noticed it before. The symptom will be that the next time the same socket handle is assigned, events will not fire when data arrives on the socket. In some cases I was getting segfaults. I've attached some code that will echo what it receives. It can be used to demonstrate what happens. -- Be excellent to each other ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users -- - Xenion - http://www.xenion.com.au/ - VPS Hosting - Commercial Squid Support - - $25/pm entry-level VPSes w/ capped bandwidth charges available in WA - ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] Must delete events before closing the socket handle
On Fri, Sep 18, 2009 at 10:57:25AM +0800, Adrian Chadd wrote: Well, the order of which you can do this depends on what the underlying OS will do for you. I'd suggest sticking to delete event, close socket usage. Anything else isn't portable. Nick, is this actually documented anywhere? Not that I recall, and it really ought to be. Anybody want to write the documentation patch? -- Nick ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] Must delete events before closing the socket handle
On Thu, Sep 17, 2009, Nick Mathewson wrote: Nick, is this actually documented anywhere? Not that I recall, and it really ought to be. Anybody want to write the documentation patch? I've been threatening to do this for ages. I may as well start now. Is there a project wiki or something somewhere where I can start braindumping clue into? Adrian ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] Must delete events before closing the socket handle
I forgot to mention that I am using libevent-2.02alpha. I think it definately makes sence to free the event before closing the handle, but it just didn't occur to me before. On Fri, Sep 18, 2009 at 10:57 AM, Adrian Chadd adr...@creative.net.auwrote: Well, the order of which you can do this depends on what the underlying OS will do for you. I'd suggest sticking to delete event, close socket usage. Anything else isn't portable. Nick, is this actually documented anywhere? Adrian On Thu, Sep 17, 2009, Gilad Benjamini wrote: I just resolved a similar issue today, where I needed to close a file descriptor AFTER deleting an event. My symptoms, though, were different. What underlying mechanism is your libevent using ? In my case it is epoll. With select or poll my scenario had no problems, in spite of the wrong order. From: libevent-users-boun...@monkey.org [mailto:libevent-users-boun...@monkey.org] On Behalf Of Clint Webb Sent: Thursday, September 17, 2009 7:46 PM To: libevent-users@monkey.org Subject: [Libevent-users] Must delete events before closing the socket handle Hello everyone, After spending over a week debugging a project I am working on, I have discovered that you must delete any persistent events BEFORE you close the socket handle. Just letting other people know who might not have noticed it before. The symptom will be that the next time the same socket handle is assigned, events will not fire when data arrives on the socket. In some cases I was getting segfaults. I've attached some code that will echo what it receives. It can be used to demonstrate what happens. -- Be excellent to each other ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users -- - Xenion - http://www.xenion.com.au/ - VPS Hosting - Commercial Squid Support - - $25/pm entry-level VPSes w/ capped bandwidth charges available in WA - -- Be excellent to each other ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] Must delete events before closing the socket handle
On Thu, Sep 17, 2009 at 07:51:58PM -0700, Gilad Benjamini wrote: I just resolved a similar issue today, where I needed to close a file descriptor AFTER deleting an event. My symptoms, though, were different. What underlying mechanism is your libevent using ? In my case it is epoll. With select or poll my scenario had no problems, in spite of the wrong order. Few people do it, but these--and other--errors would be easier to catch if people checked the return value of event_del(). I often use assert(0 == event_del()), because if event_del() is failing then in all likelihood I have a bug in my code (the alternative being a bug in libevent, or a kernel bug). 'Tis better to have QA screaming at you, or a few hundred upset customers, than to roll out a buggy app to tens-of-thousands of customers and watch tech support disintegrate as you struggle to locate the source of the bug, assuming you can even get a trace. (This is also why setting NDEBUG for the production build is usually counter-productive.) ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] Must delete events before closing the socket handle
On Fri, Sep 18, 2009 at 11:09:52AM +0800, Adrian Chadd wrote: On Thu, Sep 17, 2009, Nick Mathewson wrote: Nick, is this actually documented anywhere? Not that I recall, and it really ought to be. Anybody want to write the documentation patch? I've been threatening to do this for ages. I may as well start now. Is there a project wiki or something somewhere where I can start braindumping clue into? Right now most of the clue is in the reference book thing I've started writing. The source for it is here, in Git: git://git.torproject.org/~nickm/git/lebook.git I'm glad to apply patches or pull contributions from other people's repositories. There's no wiki; if somebody knows a good wiki host that we should use, I'd be glad to set one up for non-book things, though I'd like to concentrate as much clue in the book as possible. Also, as a heads-up: We'll probably be moving the mailing list to some other host soon, due to monkeymail's general unreliability. Currently sourceforge seems likeliest. The likeliest time for this, assuming we don't flake out, is next week once Niels is back home. yrs, -- Nick ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users