Thank you for your quick answer, Niels.

Okay, i can explain a bit more about why those issues matter.

1. Consider for example of a server which uses libevent as a portable
library for dealing which a high number of connections. The commercial
server is distributed in binary form, so libevent is build statically
inside it. On different platforms (FreeBSD, Linux 2.4 and 2.6) we have
different binaries which are optimized for using the most effective
system call (kqueue, epoll and poll/rtsig) of the system.
We should avoid the possibility for the enviroment variables to affect
the server functionality. So the libevent code should not depend on
getenv() but just pick the best method available. I think the only way
to achieve this is to put getenv() code inside ifdefs. And the needed
symbols could be define using configure script. 

If you know another good way to to this please tell me.

2. Output to standard streams. This is not good either for a network
server. It usually demonizes itself. The output descriptors could even
be closed after daemonizing. Or the data written to them has to be in
special format.
Is there a way to install an application callback for handling errors
and/or outputting messages inside libevent ?


3. exit() call is dangerous in C++ programs. This is defined by
standard. This is very dangerous that the library decides to kill the
current process. The application usually does not expect such behaviour
from a library. There should be a callback for such critical situations.
For C++ the handling of such error should be done using exceptions.

P.S. I'll try to learn the source code a bit more and if I come up with
useful modifications I will of course send them to you :) 

> Hi Dmitri,
> 
> I don't think that any of the 3 items precludes use in C++.  At least,
> I have not had any problems using libevent in C++ applications.  That
> said, if you have any patches, that would make it easier to integrate
> libevent with C++ code, fell free to send them.
> 
> For patches, I would prefer to keep the numer of ifdefs minimal.
> 
> Niels.
> 
> On 8/7/06, Dmitri Kalinin <[EMAIL PROTECTED]> wrote:
> > I tried to examine the internals of libevent source code.
> > I figured out that:
> > 1. getenv() is often used to determine the event demultiplexing method
> > at runtime.
> > 2. Sometimes the library outputs messages on stdout/stderr
> > 3. there is at least one occurence of exit() system call
> >
> > All those things make it hard to include the library in a C++ project.
> >
> > Is there a way do disable all or some of those features (i think i can
> > setup a custom error handling policy, but how?)
> >
> > Maybe the source code has to be modified using ifdef's to include or
> > exclude all those features from the build. Is there a plan to do this ?
> > Maybe I could try to do this myself. Would you accept such a patch?


_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to