Hi,
On Sun, Mar 11, 2012 at 8:19 AM, DR <drdarkraven@xxxxxxxxx> wrote:
Sounds great, but I think it would be cleaner to avoid exporting soIf my understanding of ev_break() is right, my patch works quite the
many symbols. For example, for at least some of those calls to exit(),
can't we just make the function signal to the caller through a return
code that it has failed? The caller would then signal to his parent
and so on, until we get to the event handlers. Those handlers know all
state involved and can cleanly break out of the loop.
In case the last sentence became a bit confusing, consider this (->
indicates a function call):
Event loop -> Event handler -> A -> B -> C
If C called exit, you're now calling ev_break in C. But then you have
to export the symbols of stuff that needs to be cleaned up in the
event handler, in A and in B, so that you can clean up for them. If
you instead propagate the error across the call stack, C would clean
after itself and pass the error code to B, which would do the same and
pass the error code to A, and so on. That way no function has to clean
up after its parent.
That might require some refactoring (e.g. some functions might already
return something) but it's probably worth it.
same way as you described.
Event handler will return, and all the clean up is done in main(), no
extra symbols need to be exported.