[Libevent-users] Multithreads event_add problem

2007-10-09 Thread Quan Sun
Hi,

These days I'm working on a web client project. The design is rather
simple, and I use two threads.

One thread creates sockets, with a given time-varing speed, then these
sockets are passed to second thread. The second thread is a
event_dispatch(), it perform all the actual work.

My question is, what is the best method to pass events between thread?
I used event_add in first thread, and these two threads share event.
But it seems that libevent is leaking fds in this case, I've read some
of 1.2a's codes, libevent itself does not have thread lock in
event_add.

-- 

Quan Sun
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users


Re: [Libevent-users] file io

2007-10-09 Thread William Ahern
On Tue, Oct 09, 2007 at 11:06:21AM -0400, arthur zhang wrote:
 Hi All,
 
 As my understanding, with libevent, any io should be non_blocking, and here
 comes my dumb q;-)
 
 I want log stuffs(trace) to a disk file in my comm callback, so I open a
 file like below, but I didn't get any write event to call back. I am using
 Ubuntu Dapper and my target system is Solaris 10.

1) You can't do non-blocking file I/O in Unix using the standard interfaces.
   You need to use a horrible and poorly implemented interfaces like POSIX
   Asynchronous I/O, which is impossible to use with libevent.

2) A file descriptor (to a realfile) will _always_ poll as ready for reading
   or writing.  (The logic being, even though the disk might be slow, it's
   still always available for I/O--the disk is one gigantic buffer.) Thus,
   if your code was written properly your complaint should have been that
   you got an endless succession of write readiness callbacks suspicously
   lacking any gap.

 Using stdout worked.

If stdout was a pipe, then it would work. Thus, you could shamefully (but
with good reason) pipe to cat, and redirect cat's stdout to a file.
___
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users