Nick Mathewson | 2 Jan 2011 03:15

Re: Handling POLLHUP in evport.c

On Wed, Dec 29, 2010 at 6:07 AM, Yee Keat Phuah <ykphuah <at> gmail.com> wrote:
> Hi,
>
> Recently I came across a scenario where I added a unix pipe in
> bufferevent, but then when the pipe is closed, I experience an
> infinite loop.
>
> This happens in Solaris 10 using evport by default.
>
> Its traced down to evport.c:460.

What version were you looking at?   The ones I'm looking at now don't
have anything interesting on line 460 of evport.c.

> Contrary to devpoll.c, epoll.c and poll.c, there's no handling of
> POLLHUP, which is what I see returned in my usage of libevent, hence
> the events will be 0, it then will trigger an infinite loop in the
> base loop.
>
> Putting out a test program to reproduce this will take some time,
> hence I hope this is an obvious bug that the maintainer of evport.c
> can respond to, from the limited information above?

Sadly, there aren't any evport experts on the Libevent team right now;
I can look at the code well enough to try to guess what it's doing,
but it seems like you probably know the Solaris APIs better than I do.
 (I've got nothing against Solaris, but it's not a system I've used
regularly since the 90s.)

I _think_ what you're suggesting is something like adding
(Continue reading)

Nick Mathewson | 2 Jan 2011 03:17

Re: Re: Libevent 2.0.10-stable is released

On Sat, Dec 25, 2010 at 11:05 AM, Dongsheng Song
<dongsheng.song <at> gmail.com> wrote:
> Hi all,
>
> When I test with vc2010, static link passed all regress test, but dll
> version have may failed:

It would probably help to see what error CreateProcess is actually
giving there.  Can you step through with a debugger to find out?

--

-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

Nick Mathewson | 2 Jan 2011 03:24

Re: newbie questions on rpc and threading in libevent

On Wed, Dec 22, 2010 at 3:24 AM, Wayne Shao <wshao99 <at> gmail.com> wrote:
> Hi
> I find out about libevent when I was searching for some asych i/o framework
> with simple http handling + websocket.
> I have not read through the code yet. I have a few questions,
> 1) Threading:  Is i/o handling in a single threaded?  Is read callback
> invoked inline from the same thread that handles epoll events?

Unless you explicitly call for multiple threads (by launching them
yourself, or by telling Libevent it can use IOCP) , Libevent won't
launch multiple IO threads for you.

> 2) RPC: from the doc "libevents provides a framework for creating RPC
> servers and clients". Is there an example of this? What kind of RPC?  (e.g,
> is there anyway to hack it with Facebook Thrift)

That's handled by the code in evrpc.c and by stub code generated by
event_rpcgen.py.   It's one of the last modules I haven't figured out
and documented yet.  It seems to be an ad hoc RPC format that Niels
designed.  For more information on its use, your best bet is the
doxygen documentation in event2/rpc.h ; you might also want to check
out the unit tests in regress_rpc.c .

If somebody wants to write better documentation, or some nice clean
sample code for the samples/ directory, that would be much
appreciated.

(As a heads-up: no work has been done to make the http or rpc modules
thread-safe, so you shouldn't use the same http or rpc data structures
from two threads at once.)
(Continue reading)

Nick Mathewson | 2 Jan 2011 03:36

Re: _EVUTIL_NIL_CONDITION cause VC2010 error C2070

On Sat, Dec 25, 2010 at 10:21 PM, Dongsheng Song
<dongsheng.song <at> gmail.com> wrote:
> Hi Jones,
>
> Your commit b63ab17 caused VC2010 error C2070:
>
> bufferevent_async.c(409) : error C2070: 'unsigned int': illegal sizeof operand
> bufferevent_async.c(434) : error C2070: 'unsigned int': illegal sizeof operand
> bufferevent_async.c(473) : error C2070: 'unsigned int': illegal sizeof operand
>
> Because you can not use sizeof on bitfield, here is my patch:

How about this patch instead; it ensures that EVUTIL_ASSERT() still
counts as using a variable, while not breaking when using it with
bitfields. Does it work for you?

--

-- 
Nick
Dongsheng Song | 2 Jan 2011 05:03
Picon

Re: _EVUTIL_NIL_CONDITION cause VC2010 error C2070

Of course, it works.

Maybe you should add an comment for why use sizeof(!(condition)), in
order to avoid
improper rollback accidentally.

On Sun, Jan 2, 2011 at 10:36, Nick Mathewson <nickm <at> freehaven.net> wrote:
> On Sat, Dec 25, 2010 at 10:21 PM, Dongsheng Song
> <dongsheng.song <at> gmail.com> wrote:
>> Hi Jones,
>>
>> Your commit b63ab17 caused VC2010 error C2070:
>>
>> bufferevent_async.c(409) : error C2070: 'unsigned int': illegal sizeof operand
>> bufferevent_async.c(434) : error C2070: 'unsigned int': illegal sizeof operand
>> bufferevent_async.c(473) : error C2070: 'unsigned int': illegal sizeof operand
>>
>> Because you can not use sizeof on bitfield, here is my patch:
>
> How about this patch instead; it ensures that EVUTIL_ASSERT() still
> counts as using a variable, while not breaking when using it with
> bitfields. Does it work for you?
>
> --
> Nick
>
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

(Continue reading)

Nick Mathewson | 2 Jan 2011 06:54

Re: _EVUTIL_NIL_CONDITION cause VC2010 error C2070

On Sat, Jan 1, 2011 at 11:03 PM, Dongsheng Song
<dongsheng.song <at> gmail.com> wrote:
> Of course, it works.
>
> Maybe you should add an comment for why use sizeof(!(condition)), in
> order to avoid
> improper rollback accidentally.

Good idea; merged it.  Thanks!

--

-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

Harlan Stenn | 2 Jan 2011 11:54
X-Face
Favicon
Gravatar

libevent-config script?

A number of different packages will install foo-config in the PATH to
make it easy to figure out if the package installed and what options
should be used.

Examples include:

 autoopts-config
 cups-config
 curl-config
 libgcrypt-config
 libpng-config

Anyway, I was wondering if libevent could install something similar.

I'm looking for path information (include and library) and any needed
CPP, library, etc. flags.

--

-- 
Harlan Stenn <stenn <at> ntp.org>
http://ntpforum.isc.org  - be a member!
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

Kevin Bowling | 2 Jan 2011 13:39
Gravatar

Re: libevent-config script?

On Sun, Jan 2, 2011 at 5:54 AM, Harlan Stenn <stenn <at> ntp.org> wrote:

A number of different packages will install foo-config in the PATH to
make it easy to figure out if the package installed and what options
should be used.

Examples include:

 autoopts-config
 cups-config
 curl-config
 libgcrypt-config
 libpng-config

Anyway, I was wondering if libevent could install something similar.

I'm looking for path information (include and library) and any needed
CPP, library, etc. flags.

libevent provides pkg-config files that should do the same as these helper programs.  You can run shell program 'PKG_CONFIG_PATH=/foo/libevent/lib/pkgconfig/ pkg-config' to get the information you desire on stdout.  pkg-config also has nice Autoconf macros.
Harlan Stenn | 3 Jan 2011 00:48
Favicon
Gravatar

Re: libevent-config script?

Kevin wrote:
> On Sun, Jan 2, 2011 at 5:54 AM, Harlan Stenn <stenn <at> ntp.org> wrote:
> 
> > A number of different packages will install foo-config in the PATH to
> > make it easy to figure out if the package installed and what options
> > should be used.
> >
> > Anyway, I was wondering if libevent could install something similar.
> >
> > I'm looking for path information (include and library) and any needed
> > CPP, library, etc. flags.
> 
> libevent provides pkg-config files that should do the same as these helper
> programs.  You can run shell program
> 'PKG_CONFIG_PATH=/foo/libevent/lib/pkgconfig/ pkg-config' to get the
> information you desire on stdout.

But that (mechanism) assumes you know where libevent was installed
(which is a local policy choice).

So if the answer is "Let's produce a libevent-config program that is a
1-liner that does this" then that may be an OK answer.  It would require
pkg-config to be installed though, and I'm interested in this capabilty
for *portability*, and making folks install even more software is not
the way I'd like to see this evolve.

> pkg-config also has nice Autoconf macros.

I don't know exactly what you mean by that, but it's where I was gonna
go next, as I also need autoconf macros to do some things with libevent
(like see if a local version exists, and is at a suitable version level.
If so, we can use the existing, installed libevent.  Otherwise, we
should configure, build, *possibly* install, but link against, libevents
that is included in the "parent" package).

H
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

Kevin Bowling | 3 Jan 2011 04:49
Gravatar

Re: libevent-config script?

On Sun, Jan 2, 2011 at 6:48 PM, Harlan Stenn <stenn <at> ntp.org> wrote:

Kevin wrote:
> On Sun, Jan 2, 2011 at 5:54 AM, Harlan Stenn <stenn <at> ntp.org> wrote:
>
> > A number of different packages will install foo-config in the PATH to
> > make it easy to figure out if the package installed and what options
> > should be used.
> >
> > Anyway, I was wondering if libevent could install something similar.
> >
> > I'm looking for path information (include and library) and any needed
> > CPP, library, etc. flags.
>
> libevent provides pkg-config files that should do the same as these helper
> programs.  You can run shell program
> 'PKG_CONFIG_PATH=/foo/libevent/lib/pkgconfig/ pkg-config' to get the
> information you desire on stdout.

But that (mechanism) assumes you know where libevent was installed
(which is a local policy choice).

I think the tradeoff is reasonable.  If the pkg-config files exist in a standard location (/usr/lib/pkgconfig, /usr/local/lib/pkgconfig), no environment variable is needed.  If it doesn't, a shell PATH env var would be needed for a standalone program. 

So if the answer is "Let's produce a libevent-config program that is a
1-liner that does this" then that may be an OK answer.  It would require
pkg-config to be installed though, and I'm interested in this capabilty
for *portability*, and making folks install even more software is not
the way I'd like to see this evolve.

pkg-config will handle everything in your third paragraph out of the box.  Test for libevent of a specific version.  If that fails, abort the build and tell the user to pass ./configure a bundled libevent flag if they desire or point to the correct system path.  That flag would do a recursive autoconf build with SUBDIRS and link directly to the internal copy of libevent.  Linking internal would be based on the build root, not pkg-config so you could even test against whether pkg-config is installed or not and offer a workaround.  pkg-config is pretty much universal on Linux (used by glib) and available for most commercial Unix in repos sys admins are savvy to so I don't think it's a problem in practice.


> pkg-config also has nice Autoconf macros.

I don't know exactly what you mean by that, but it's where I was gonna
go next, as I also need autoconf macros to do some things with libevent
(like see if a local version exists, and is at a suitable version level.
If so, we can use the existing, installed libevent.  Otherwise, we
should configure, build, *possibly* install, but link against, libevents
that is included in the "parent" package).

Also, some food for thought.  Since you are talking about users building from source, I'm guessing this is FOSS.  If that's the case, you should avoid bundling libraries like libevent if you have any desire for inclusion in distros like Debian, Fedora, and Gentoo.  Now that libevent 2.0.10 is "stable", we should start seeing it in the next round of releases.  Users of older releases like RHEL are used to jumping through hoops to build software.

Gmane