Re: [Libevent-users] patch to use different return value for event_base_loop()
On Thu, 2009-08-13 at 09:16 -0700, Nick Mathewson wrote: > On Wed, Aug 12, 2009 at 11:42:47AM -0700, Ka-Hing Cheung wrote: > [...] > > I do realize that this breaks existing assumptions about return values. > > What if instead of using a different return value, we don't reset > > base->event_gotterm and base->event_break when triggered? We can reset > > them at the beginning of event_base_loop() instead. > > How would you inspect them? The event_base structure isn't exposed in > any public headers. I suppose we could add a new accessor function. Right. > I like the idea of the original patch, but I'm also concerned about > return values. If anyone has written code like > "if (event_base_loop(base,0)<0)" or "if (event_base_loop(base,0)==-1)", > they'll get unexpected results. Yes I like that too. I don't know how strict the api compatibility requirement is, but I am willing to submit another patch (the one with accessor to base->event_gotterm/event_break) if you think that's the better way to do it. -khc ___ Libevent-users mailing list [email protected] http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] patch to use different return value for event_base_loop()
On Wed, Aug 12, 2009 at 11:42:47AM -0700, Ka-Hing Cheung wrote: [...] > I do realize that this breaks existing assumptions about return values. > What if instead of using a different return value, we don't reset > base->event_gotterm and base->event_break when triggered? We can reset > them at the beginning of event_base_loop() instead. How would you inspect them? The event_base structure isn't exposed in any public headers. I suppose we could add a new accessor function. I like the idea of the original patch, but I'm also concerned about return values. If anyone has written code like "if (event_base_loop(base,0)<0)" or "if (event_base_loop(base,0)==-1)", they'll get unexpected results. -- Nick ___ Libevent-users mailing list [email protected] http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] patch to use different return value for event_base_loop()
On Tue, 2009-08-11 at 16:25 -0700, Ka-Hing Cheung wrote: > Attached is a patch that makes event_base_loop() return 2 if it returns > because of a prior call to event_base_loopexit() or > event_base_loopbreak(). This is useful when the caller calls > event_base_loop(base, EVLOOP_ONCE) repeatedly (to do stuff in between > events) and need to know if it should exit. > > Patch is against 2.0.2-alpha. > I do realize that this breaks existing assumptions about return values. What if instead of using a different return value, we don't reset base->event_gotterm and base->event_break when triggered? We can reset them at the beginning of event_base_loop() instead. -khc ___ Libevent-users mailing list [email protected] http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] patch to use different return value for event_base_loop()
On Wed, Aug 12, 2009 at 10:27:15AM -0700, Ka-Hing Cheung wrote: > On Wed, 2009-08-12 at 02:50 -0700, q6Yr7e0o nIJDVMjC wrote: > > Hi, > > > > > > one general question, why do you use #defines instead of enums? > > Because the constants right above are also #defines, so I just follow > the existing practice. > Also, one bonus to defines is that you can do feature checks without being forced to use an autoconf-like system. ___ Libevent-users mailing list [email protected] http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] patch to use different return value for event_base_loop()
On Wed, 2009-08-12 at 02:50 -0700, q6Yr7e0o nIJDVMjC wrote: > Hi, > > > one general question, why do you use #defines instead of enums? Because the constants right above are also #defines, so I just follow the existing practice. -khc ___ Libevent-users mailing list [email protected] http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] patch to use different return value for event_base_loop()
Hi, one general question, why do you use #defines instead of enums? ___ Libevent-users mailing list [email protected] http://monkeymail.org/mailman/listinfo/libevent-users
