From toby.douglass at summerblue.net Sun Dec 3 07:14:21 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Sun Dec 3 07:17:51 2006 Subject: [Libevent-users] Win32 I/O completion ports code release Message-ID: <4572BF9D.8010900@summerblue.net> Hi. I've written a tiny library which provides a simple front end for IO completion ports. The ultimate purpose of this is to provide excellent socket handling under Win32 in libevent so that the socket problem Tor faces is solved. My code base is written around a resource and error handling framework and so the original code that I've written and tested was permeated with that framework. Having completed testing, I've removed my framework code from the library and what remains is what I'm releasing here. I originally intended to create a decent Win32 build of libevent library and to integrate this code. However, last night when I finally had a proper stab at this, I found the libevent code badly disorganised (poor header file/code structure) and after an hour or so, I gave up. As such, I'm releasing my code here and hoping either a libevent expert will integrate it or Tor will use it directly. I will be supporting this code. If people have problems with it or need changed, I will make those changes. One technical note; I believe that I/O completion ports cannot handle accept() type behaviour, only recv() and send(). I have however written a WaitForMultipleObjects() based listen/accept handling library, which might be particularly useful in conjunction with this IOCP code. Technical Information ===================== The API has three functions and is best explained by stating these functions. 1. void socket_iocp_new( void **socket_iocp_state ); 2. void socket_iocp_delete( void *socket_iocp_state ); 3. void socket_iocp_add_socket( void *socket_iocp_state, SOCKET socket, void *user_state, size_t read_buffer_size, void (*callback_function)(SOCKET socket, int event_type, void *read_buffer, DWORD byte_count, void *user_state) ); The purpose of the first two functions is obvious. From the users view, the API works like this; you give a socket, a callback function and a pointer to state of your own (if you have any) to the API and it will call that callback when a read has occurred. The callback function is; void callback_function( SOCKET socket, int event_type, void *read_buffer, DWORD byte_count, void *user_state ); So, you are given the socket which has completed a read (or errored), the event type (read or error), the read buffer, and number of bytes in the buffer, and a pointer to your own state. When the socket closes, the OS automatically removes it from the IOCP socket list, which is why there is no delete_socket() function. Build and Link ============== I use VC6 and I've arranged the code as a statically linked library. The file and directory structure is; libiocp/libiocp.h // public header file to be used with the .lib libiocp/libiocp/ libiocp/libiocp/libiocp.dsp libiocp/libiocp/libiocp.dsw libiocp/libiocp/libiocp.opt libiocp/libiocp/iocp.c libiocp/libiocp/iocp_internal.h The debug and release libraries are created to these pathnames; libiocp/libiocp (debug).lib libiocp/libiocp (release).lib So the basic arrangement is that the public files (libraries and the public header) are in the root, while the code and build files are in the subdirectory libiocp. The code compiles without error with level 4 warnings and warnings as errors. I've had to pragma warnings 4005, 4201 and 4305 so that the MS headers will compile with warnings at level 4. (I've just been discovering some bad behaviour in WinZip, while making up the archive. If you have empty directories in the archive, *they will not be shown in the archive listing in WinZip*, but they WILL be created - so you have invisible directories! also, if you delete all the files in archive, *the archive file is deleted*, so you then need to remake it to add files to the archive - which is annoying, because I added the wrong files, so I deleted them all, went to add the files I did want...and found I couldn't add them. I had to go remake the archive first, despite having *just* made the archive in the first place). Homepage and Direct Download ============================ http://www.summerblue.net/computing/libiocp/index.html http://www.summerblue.net/computing/libiocp/zips/libiocp%201.00%203-Dec-2006.zip From gscott2112 at gmail.com Sun Dec 3 17:03:46 2006 From: gscott2112 at gmail.com (Gordon Scott) Date: Mon Dec 4 19:26:22 2006 Subject: [Libevent-users] Win32 I/O completion ports code release In-Reply-To: <4572BF9D.8010900@summerblue.net> References: <4572BF9D.8010900@summerblue.net> Message-ID: <8c856b690612031403j272073a6nad892d6f06435bc6@mail.gmail.com> very cool. >>One technical note; I believe that I/O completion ports cannot handle >>accept() type behaviour, What do you mean by this? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20061203/9871002f/attachment.htm From toby.douglass at summerblue.net Tue Dec 5 03:45:00 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Tue Dec 5 03:46:16 2006 Subject: [Libevent-users] Win32 I/O completion ports code release In-Reply-To: <8c856b690612031403j272073a6nad892d6f06435bc6@mail.gmail.com> References: <4572BF9D.8010900@summerblue.net> <8c856b690612031403j272073a6nad892d6f06435bc6@mail.gmail.com> Message-ID: <4575318C.4@summerblue.net> Gordon Scott wrote: >>> One technical note; I believe that I/O completion ports cannot handle >>> accept() type behaviour, > > What do you mean by this? With an IOCP, you can give the IOCP a *connected* socket and the IOCP will call you back when a read occurs. But you cannot pass in an *unconnected* socket in the listen state, for the IOCP is not capable of calling you back when an incoming connection occurs and you need to call accept(). The docs say the following functions can be used with an IOCP; ConnectNamedPipe DeviceIoControl LockFileEx ReadDirectoryChangesW ReadFile TransactNamedPipe WaitCommEvent WriteFile So, as you can see, it doesn't seem possible to use an IOCP to handle incoming connections. FYI, libiocp 1.03 was put on the site last night. I'm going to add some example code next, and then maybe integrate the listen/accept solution I've written. From newroswell at gmail.com Tue Dec 5 09:56:34 2006 From: newroswell at gmail.com (Kevin Sanders) Date: Tue Dec 5 09:56:41 2006 Subject: [Libevent-users] Win32 I/O completion ports code release In-Reply-To: <4575318C.4@summerblue.net> References: <4572BF9D.8010900@summerblue.net> <8c856b690612031403j272073a6nad892d6f06435bc6@mail.gmail.com> <4575318C.4@summerblue.net> Message-ID: <375baf50612050656x4118c137x86eaab7b7ade5ab3@mail.gmail.com> On 12/5/06, Toby Douglass wrote: > Gordon Scott wrote: > >>> One technical note; I believe that I/O completion ports cannot handle > >>> accept() type behaviour, > > > > What do you mean by this? > > With an IOCP, you can give the IOCP a *connected* socket and the IOCP > will call you back when a read occurs. > > But you cannot pass in an *unconnected* socket in the listen state, for > the IOCP is not capable of calling you back when an incoming connection > occurs and you need to call accept(). > > The docs say the following functions can be used with an IOCP; > > ConnectNamedPipe > DeviceIoControl > LockFileEx > ReadDirectoryChangesW > ReadFile > TransactNamedPipe > WaitCommEvent > WriteFile > > So, as you can see, it doesn't seem possible to use an IOCP to handle > incoming connections. > > FYI, libiocp 1.03 was put on the site last night. I'm going to add some > example code next, and then maybe integrate the listen/accept solution > I've written. Use AcceptEx. From toby.douglass at summerblue.net Tue Dec 5 10:35:37 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Tue Dec 5 10:35:47 2006 Subject: [Libevent-users] Win32 I/O completion ports code release In-Reply-To: <375baf50612050656x4118c137x86eaab7b7ade5ab3@mail.gmail.com> References: <4572BF9D.8010900@summerblue.net> <8c856b690612031403j272073a6nad892d6f06435bc6@mail.gmail.com> <4575318C.4@summerblue.net> <375baf50612050656x4118c137x86eaab7b7ade5ab3@mail.gmail.com> Message-ID: <55861.82.195.181.130.1165332937.squirrel@webmail.serve.com> >> The docs say the following functions can be used with an IOCP; >> >> ConnectNamedPipe >> DeviceIoControl >> LockFileEx >> ReadDirectoryChangesW >> ReadFile >> TransactNamedPipe >> WaitCommEvent >> WriteFile > Use AcceptEx. The docs sayeth; "The following functions can be used to start I/O operations that complete using completion ports." (And then the above list is given). This to me means that it is these and only these functions which can be used with IOCP, which in turn means having an overlapped structure doesn't automatically mean you can use that function with an IOCP. Have you used AcceptEx() with an IOCP and found it works? From toby.douglass at summerblue.net Tue Dec 5 10:50:42 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Tue Dec 5 10:51:15 2006 Subject: [Libevent-users] Win32 I/O completion ports code release In-Reply-To: <375baf50612050656x4118c137x86eaab7b7ade5ab3@mail.gmail.com> References: <4572BF9D.8010900@summerblue.net> <8c856b690612031403j272073a6nad892d6f06435bc6@mail.gmail.com> <4575318C.4@summerblue.net> <375baf50612050656x4118c137x86eaab7b7ade5ab3@mail.gmail.com> Message-ID: <56507.82.195.181.130.1165333842.squirrel@webmail.serve.com> Kevin Sanders wrote: > Use AcceptEx. Interesting. In the AcceptEx() docs, we find this; "As with all overlapped Windows functions, either Windows events or completion ports can be used as a completion notification mechanism." From newroswell at gmail.com Tue Dec 5 10:59:42 2006 From: newroswell at gmail.com (Kevin Sanders) Date: Tue Dec 5 10:59:47 2006 Subject: [Libevent-users] Win32 I/O completion ports code release In-Reply-To: <55861.82.195.181.130.1165332937.squirrel@webmail.serve.com> References: <4572BF9D.8010900@summerblue.net> <8c856b690612031403j272073a6nad892d6f06435bc6@mail.gmail.com> <4575318C.4@summerblue.net> <375baf50612050656x4118c137x86eaab7b7ade5ab3@mail.gmail.com> <55861.82.195.181.130.1165332937.squirrel@webmail.serve.com> Message-ID: <375baf50612050759q76ba3cc1v234fe1e1e930cc61@mail.gmail.com> On 12/5/06, Toby Douglass wrote: > >> The docs say the following functions can be used with an IOCP; > >> > >> ConnectNamedPipe > >> DeviceIoControl > >> LockFileEx > >> ReadDirectoryChangesW > >> ReadFile > >> TransactNamedPipe > >> WaitCommEvent > >> WriteFile > > > Use AcceptEx. > > The docs sayeth; > > "The following functions can be used to start I/O operations that complete > using completion ports." > > (And then the above list is given). > > This to me means that it is these and only these functions which can be > used with IOCP, which in turn means having an overlapped structure doesn't > automatically mean you can use that function with an IOCP. > > Have you used AcceptEx() with an IOCP and found it works? Of course I have. ConnectEx works great also. From gscott2112 at gmail.com Tue Dec 5 11:13:18 2006 From: gscott2112 at gmail.com (Gordon Scott) Date: Tue Dec 5 11:13:33 2006 Subject: [Libevent-users] Win32 I/O completion ports code release In-Reply-To: <375baf50612050759q76ba3cc1v234fe1e1e930cc61@mail.gmail.com> References: <4572BF9D.8010900@summerblue.net> <8c856b690612031403j272073a6nad892d6f06435bc6@mail.gmail.com> <4575318C.4@summerblue.net> <375baf50612050656x4118c137x86eaab7b7ade5ab3@mail.gmail.com> <55861.82.195.181.130.1165332937.squirrel@webmail.serve.com> <375baf50612050759q76ba3cc1v234fe1e1e930cc61@mail.gmail.com> Message-ID: <8c856b690612050813y51ac58fei745ca662ee46895d@mail.gmail.com> AcceptEx works great. THe cool thing is that you can pre-create a pool of sockets waiting for connection. When a socket is connected you'll get an event from GQCS call. Typically I create about 20 at a time..when I get down to about 5 or so remaining I use AcceptEx to queue up another batch of sockets waiting to be connected. On 12/5/06, Kevin Sanders wrote: > > On 12/5/06, Toby Douglass wrote: > > >> The docs say the following functions can be used with an IOCP; > > >> > > >> ConnectNamedPipe > > >> DeviceIoControl > > >> LockFileEx > > >> ReadDirectoryChangesW > > >> ReadFile > > >> TransactNamedPipe > > >> WaitCommEvent > > >> WriteFile > > > > > Use AcceptEx. > > > > The docs sayeth; > > > > "The following functions can be used to start I/O operations that > complete > > using completion ports." > > > > (And then the above list is given). > > > > This to me means that it is these and only these functions which can be > > used with IOCP, which in turn means having an overlapped structure > doesn't > > automatically mean you can use that function with an IOCP. > > > > Have you used AcceptEx() with an IOCP and found it works? > > Of course I have. ConnectEx works great also. > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkey.org/mailman/listinfo/libevent-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20061205/e3fcc955/attachment.htm From gscott2112 at gmail.com Tue Dec 5 11:21:54 2006 From: gscott2112 at gmail.com (Gordon Scott) Date: Tue Dec 5 11:22:00 2006 Subject: [Libevent-users] Win32 I/O completion ports code release In-Reply-To: <55861.82.195.181.130.1165332937.squirrel@webmail.serve.com> References: <4572BF9D.8010900@summerblue.net> <8c856b690612031403j272073a6nad892d6f06435bc6@mail.gmail.com> <4575318C.4@summerblue.net> <375baf50612050656x4118c137x86eaab7b7ade5ab3@mail.gmail.com> <55861.82.195.181.130.1165332937.squirrel@webmail.serve.com> Message-ID: <8c856b690612050821m20432573w7eae4ccd2fdb8c51@mail.gmail.com> You might want to do some research on IOCP outside of MSDN. Codeproject has a number of IOCP server samples you can look at While the docs may say that those files you mention CAN be used with IOCP, they are by no means the ONLY functions that can be used. For example my server users AcceptEx for accepting connections and WSASend and WSARecv for sending and recieving data on the sockets. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20061205/134fbc46/attachment.htm From newroswell at gmail.com Tue Dec 5 11:35:28 2006 From: newroswell at gmail.com (Kevin Sanders) Date: Tue Dec 5 11:35:33 2006 Subject: [Libevent-users] Win32 I/O completion ports code release In-Reply-To: <8c856b690612050821m20432573w7eae4ccd2fdb8c51@mail.gmail.com> References: <4572BF9D.8010900@summerblue.net> <8c856b690612031403j272073a6nad892d6f06435bc6@mail.gmail.com> <4575318C.4@summerblue.net> <375baf50612050656x4118c137x86eaab7b7ade5ab3@mail.gmail.com> <55861.82.195.181.130.1165332937.squirrel@webmail.serve.com> <8c856b690612050821m20432573w7eae4ccd2fdb8c51@mail.gmail.com> Message-ID: <375baf50612050835x2f976c49j11e061ac2cb7d039@mail.gmail.com> On 12/5/06, Gordon Scott wrote: > You might want to do some research on IOCP outside of MSDN. Codeproject has > a number of IOCP server samples you can look at > > While the docs may say that those files you mention CAN be used with IOCP, > they are by no means the ONLY functions that can be used. > > For example my server users AcceptEx for accepting connections and > WSASend and WSARecv for sending and recieving data on the sockets. There is a lot of dodgy stuff on codeproject mixed in with a few good articles. I highly recommend Anthony Jones' Network Programming for Microsoft Windows 2nd Edition. It's out of print, but find a used copy somewhere, or the electronic version if floating around. From steveu at coppice.org Wed Dec 6 08:38:46 2006 From: steveu at coppice.org (Steve Underwood) Date: Wed Dec 6 08:38:54 2006 Subject: [Libevent-users] Web site not accessible from many places Message-ID: <4576C7E6.3030208@coppice.org> Hi, Is monkey.org intentionally censored from some parts of the planet, for some obscure reason? From a number of Asian IP addresses, the mailing list works, but the web site cannot be viewed. A traceroute ends as follows: 16 bb-stlc-jp-01-so-0-0-0.ip.lightcore.net (204.9.121.1) 236.451 ms bb-chci-jp-01-so-1-0-0.ip.lightcore.net (204.9.121.6) 244.763 ms bb-stlc-jp-01-so-0-0-0.ip.lightcore.net (204.9.121.1) 233.060 ms MPLS Label=222096 CoS=0 TTL=1 S=1 17 host.lightcore.net (204.9.123.45) 252.675 ms 256.173 ms bb-chci-jp-01-so-1-0-0.ip.lightcore.net (204.9.121.6) 260.185 ms 18 * host.lightcore.net (204.9.123.45) 261.862 ms * 19 * * * 20 * * * So many people block ICMP, that isn't much of an indication of anything. This is not a temporary fault. It has been the same for at least a few weeks (that's when I first tried). Steve From toby.douglass at summerblue.net Wed Dec 6 12:29:30 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Wed Dec 6 12:29:38 2006 Subject: [Libevent-users] IOCP rewrite Message-ID: <19027.82.195.181.130.1165426170.squirrel@webmail.serve.com> For those of you who are interested, I'm finishing off a rewrite of the IOCP code, such that is handles connect()/accept() behaviour. Which is to say, you init the IOCP state, and all your socket behaviour is then routed through the callback function, which is simply called when an accept, connect or read occurs. You can add listen, to-be-connected or connected sockets to the IOCP. When a listen socket is added, all the user sees after that is that the accept callback is called when an incoming connection occurs and then the recv callback is called whenever a read occurs. The user does *no* other work - for example, he can just return from these functions should he wish. When a to-be-connected socket is added, the user passes in the socket and the remote address, and then the connect callback is called when the connect is successful and then after that the read callback every time a read successfully occurs. Similarly, with a connected sockets, all that happens is the read callback is called whenever a read occurs. So it's basically five functions; iocp_new() iocp_delete() iocp_add_listen_socket() iocp_connect_and_add_socket() iocp_add_connected_socket() And then all the user sees are the callbacks being called. There's one for accept, one for connect, one for recv and one for error. Typical use I think is to add the listen socket, then in the accept allocate your own internal state for that connection (you can in the accept function specify a user state pointer for the accept socket), in the recv callback deal with the data. From alejos at gmail.com Fri Dec 8 09:59:20 2006 From: alejos at gmail.com (Alejo S) Date: Fri Dec 8 09:59:30 2006 Subject: [Libevent-users] Flushing bufferevent writes Message-ID: <3190d0e50612080659r56cf970cnc84a7694f4fc9e46@mail.gmail.com> Hi. Silly question: what's the proper way to flush pending buffered write events before closing a socket. Cheers. Alejo From provos at citi.umich.edu Fri Dec 8 11:19:55 2006 From: provos at citi.umich.edu (Niels Provos) Date: Fri Dec 8 11:19:57 2006 Subject: [Libevent-users] Flushing bufferevent writes In-Reply-To: <3190d0e50612080659r56cf970cnc84a7694f4fc9e46@mail.gmail.com> References: <3190d0e50612080659r56cf970cnc84a7694f4fc9e46@mail.gmail.com> Message-ID: <850f7cbe0612080819o29e4a75aoa06c5c8fa19d1339@mail.gmail.com> You need to wait for the write callback that tells you that the buffer is empty before you can close the socket (or free the buffer event). Niels. On 12/8/06, Alejo S wrote: > Hi. > > Silly question: what's the proper way to flush pending buffered write > events before closing a socket. > > Cheers. > > Alejo > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkey.org/mailman/listinfo/libevent-users > > From rfistman at gmail.com Fri Dec 8 12:49:03 2006 From: rfistman at gmail.com (Rhythmic Fistman) Date: Fri Dec 8 12:49:09 2006 Subject: [Libevent-users] Re: Win32 I/O completion ports code release Message-ID: <131e28b50612080949t3c421111wbc8522dc984924cc@mail.gmail.com> > From: "Toby Douglass" > > Use AcceptEx. > > The docs sayeth; > > "The following functions can be used to start I/O operations that complete > using completion ports." > > (And then the above list is given). > > This to me means that it is these and only these functions which can be > used with IOCP, which in turn means having an overlapped structure doesn't > automatically mean you can use that function with an IOCP. > > Have you used AcceptEx() with an IOCP and found it works? Yes! and Yes! From oz at nixil.net Sat Dec 9 19:54:10 2006 From: oz at nixil.net (Phil Oleson) Date: Sat Dec 9 19:54:35 2006 Subject: [Libevent-users] evtimer complains... Message-ID: <457B5AB2.2050200@nixil.net> Niels, I've taken a little time time to look through my issue with evtimers. Previously, Scott Lamb questioned my code using absolute time with evtimers, but I see no problem with this. It used to work pre-1.2, and I've tracked the issue down to gettime() using CLOCK_MONOTONIC rather than CLOCK_REALTIME. When I've hacked libevent to use CLOCK_REALTIME, my test code works. To me it seems that using CLOCK_MONOTONIC causes issues with calls to gettimeofday. Was there any particular reason to have CLOCK_MONOTONIC as the arg to clock_gettime()? I would just like to understand this better before I rewrite my application. -Phil. From provos at citi.umich.edu Sat Dec 9 20:08:16 2006 From: provos at citi.umich.edu (Niels Provos) Date: Sat Dec 9 20:08:19 2006 Subject: [Libevent-users] Re: evtimer complains... In-Reply-To: <457B5AB2.2050200@nixil.net> References: <457B5AB2.2050200@nixil.net> Message-ID: <850f7cbe0612091708w40063c3am47c916cb1e390f5b@mail.gmail.com> The libevent API has never supported absolute times for timeouts. If they worked before then that was only by accident and never by intention. The switch to clock monotonic was made to support clock resets. So, personally, I am very surprised that absolute times ever worked for you. Is this something that should be documented more clearly in the man page? Niels. On 12/9/06, Phil Oleson wrote: > Niels, > > I've taken a little time time to look through my issue with > evtimers. Previously, Scott Lamb questioned my code using absolute > time with evtimers, but I see no problem with this. It used to work > pre-1.2, and I've tracked the issue down to gettime() using > CLOCK_MONOTONIC rather than CLOCK_REALTIME. When I've hacked libevent to > use CLOCK_REALTIME, my test code works. To me it seems that using > CLOCK_MONOTONIC causes issues with calls to gettimeofday. Was there > any particular reason to have CLOCK_MONOTONIC as the arg to > clock_gettime()? I would just like to understand this better before > I rewrite my application. > > -Phil. > > From schumi.han at gmail.com Sun Dec 10 00:14:17 2006 From: schumi.han at gmail.com (Zhu Han) Date: Sun Dec 10 00:14:22 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO Message-ID: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> I'm afraid WINDOWS Overlapped IO is a critical feature for libevent because some of the servers required it. I try to implement this feature with Completion Port. Is anyone busing on it? If not, I will try to do it. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20061210/3cc6aa63/attachment.htm From toby.douglass at summerblue.net Sun Dec 10 03:48:49 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Sun Dec 10 03:47:29 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> Message-ID: <457BC9F1.6090808@summerblue.net> Zhu Han wrote: > I'm afraid WINDOWS Overlapped IO is a critical feature for libevent because > some of the servers required it. I try to implement this feature with > Completion Port. Is anyone busing on it? If not, I will try to do it. I've written an IOCP library, which is here; http://www.summerblue.net/computing/libiocp/index.html It's not integrated into libevent though, which is something I'm not doing. I've finished rewriting that IOCP library to support listen sockets, so the IOCP stuff will take care of all the accept behaviour, too. Right now I'm writing up test/example code for that, once it tests okay, I'll release, which I expect to do next weekend. From schumi.han at gmail.com Sun Dec 10 07:22:04 2006 From: schumi.han at gmail.com (Zhu Han) Date: Sun Dec 10 07:22:09 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <457BC9F1.6090808@summerblue.net> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> Message-ID: <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> Toby, Good work! There is several questions for your implementation: 1) If you play with the Completion port, there is no reason to use the hEvent in the OVERLAPPED structure. Why do you use it? 2)I suppose socket_internal_iocp_read is called before you invoke the callback to let the callback consume the received data. Why do you call socket_internal_iocp_read firstly? 3)Is there any plan to support all of the Async operations, such as connect, listen, accept, read and write? BTW: your implementation has a lot of difference with libevent. The most important one is libevent is a "single-threaded event-driven" library. This could relieve the programmer from the burden of explicitly synchronization, althouth it can't explore the capability of SMP. best regards, hanzhu On 12/10/06, Toby Douglass wrote: > > Zhu Han wrote: > > I'm afraid WINDOWS Overlapped IO is a critical feature for libevent > because > > some of the servers required it. I try to implement this feature with > > Completion Port. Is anyone busing on it? If not, I will try to do it. > > > I've written an IOCP library, which is here; > > http://www.summerblue.net/computing/libiocp/index.html > > It's not integrated into libevent though, which is something I'm not > doing. > > I've finished rewriting that IOCP library to support listen sockets, so > the IOCP stuff will take care of all the accept behaviour, too. Right > now I'm writing up test/example code for that, once it tests okay, I'll > release, which I expect to do next weekend. > > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkey.org/mailman/listinfo/libevent-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20061210/80817ae9/attachment.htm From toby.douglass at summerblue.net Sun Dec 10 09:06:30 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Sun Dec 10 17:08:04 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> Message-ID: <457C1466.1010806@summerblue.net> Zhu Han wrote: > Toby, > > Good work! > > There is several questions for your implementation: > > 1) If you play with the Completion port, there is no reason to use the > hEvent in the OVERLAPPED structure. Why do you use it? I assumed it was used internally by the IOCP. I'll investigate removing it. > 2)I suppose socket_internal_iocp_read is called before you invoke the > callback to let the callback consume the received data. Why do you call > socket_internal_iocp_read firstly? Well, socket_internal_iocp_read() issues a non-blocking ReadEx() on the socket. The user could do this, but the API can do it for him without any loss of functionality. So, when the user gives me a socket, I issue a read on it; then, when the read completes, I call the callback to pass him the data and issue another read. This way, it's simpler and easier for the user; all he does is add his socket, and then that's it - the callback is called when data arrives. He has nothing else to worry about or so. > 3)Is there any plan to support all of the Async operations, such as > connect, listen, accept, read and write? I added listen and accept last week, and I'm testing them now. I didn't add connect, because ConnectEx() is XP and higher only (it's not available under w2k). I've not added support for writes, because I think people generally issue blocking writes, since non-blocking means that if you return from a function which issues a send you have to ensure the lifetime of the buffer you've sent is non-local. > BTW: your implementation has a lot of difference with libevent. The most > important one is libevent is a "single-threaded event-driven" library. This > could relieve the programmer from the burden of explicitly synchronization, > althouth it can't explore the capability of SMP. Mmm. I can't see how a single threaded approach can work under Windows, since different blocking function calls are needed for different mechanisms - you can't block on WaitForMulitpleObjects(), select() and GetQueuedCompletionStatus() at the same time in the same thread. I've not much read the source for libevent, though, so I don't know how it manages things internally. Single-thread event-driven seems to me to basically mean state machine. State machines are wonderful things for achieving simple, bug-free code, but they have a cost; they are implicitly single-threaded. This can mean you cannot use them in some situations, because you will inherently block whenever you perform work. Also note that with GetQueuedCompletionStatus(), you're supposed, for optimal performance, to have multiple threads (2xCPU) blocking on the IOCP object. Given the advent and growing popularity of multi-core CPUs, single threaded blocking seems inappropriate. Note though that with GetQueuedCompletionStatus(), the user has no synchronization work to do. The API handles it all behind the scenes. From sgrimm at facebook.com Sun Dec 10 17:29:24 2006 From: sgrimm at facebook.com (Steven Grimm) Date: Sun Dec 10 17:29:26 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <457C1466.1010806@summerblue.net> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> Message-ID: <457C8A44.2000003@facebook.com> Toby Douglass wrote: > Single-thread event-driven seems to me to basically mean state > machine. State machines are wonderful things for achieving simple, > bug-free code, but they have a cost; they are implicitly > single-threaded. This can mean you cannot use them in some > situations, because you will inherently block whenever you perform work. That's not strictly true; you can, for example, have multiple state machines running concurrently (the implementation strategy I used when I added thread support to memcached). Or you can have a single thread responsible for I/O operations that hands work off to other threads that perform whatever blocking operations they need. Or you can combine the two and have a small set of I/O management threads and a larger set of worker threads. The right strategy depends on the particulars of the application, of course. -Steve From toby.douglass at summerblue.net Sun Dec 10 17:48:37 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Sun Dec 10 17:48:41 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <457C8A44.2000003@facebook.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <457C8A44.2000003@facebook.com> Message-ID: <457C8EC5.8060409@summerblue.net> Steven Grimm wrote: > Toby Douglass wrote: >> Single-thread event-driven seems to me to basically mean state >> machine. State machines are wonderful things for achieving simple, >> bug-free code, but they have a cost; they are implicitly >> single-threaded. This can mean you cannot use them in some >> situations, because you will inherently block whenever you perform work. > That's not strictly true; you can, for example, have multiple state > machines running concurrently (the implementation strategy I used when I > added thread support to memcached). I had a situation where I had a large number of pipes being waited on, in a state machine - so there was a state which was where I called WaitForMultipleObjects() and sat there waiting for one of them to come back to me. When one of them did come back to me, I'd go off into the state machine and process its request. Of course, while doing that, I couldn't respond to any of the other pipes. If the request was time consuming, I was stuffed! Now, as you say, I could have written a state machine to go and do the work for that pipe...but that means running that in another thread. This is what I did - and began running into the synchronization problems that avoiding was the point of having a state machine in the first place. (E.g. has that first request been serviced yet, will the requests other people make in the meantime depend on the results of that first request, etc). > Or you can have a single thread > responsible for I/O operations that hands work off to other threads that > perform whatever blocking operations they need. Or you can combine the > two and have a small set of I/O management threads and a larger set of > worker threads. I think the more threads you have, the more synchronization you'll need to be doing between the state machines, and the more likely you are to get it wrong. That's the lovely thing about a state machine; it serialises operations. That removes a whole class of mistakes. From provos at citi.umich.edu Sun Dec 10 18:49:18 2006 From: provos at citi.umich.edu (Niels Provos) Date: Sun Dec 10 18:49:21 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <457C8A44.2000003@facebook.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <457C8A44.2000003@facebook.com> Message-ID: <850f7cbe0612101549y7141c647lb064128e7fd29976@mail.gmail.com> There are many different ways to integrate a non-blocking IO model into multi-threaded applications. You can run different event loops per thread. You can dispatch work based on event notifications to worker threads, etc. It's not possible to write a high-performance network server without an abstraction like that. Please, think about that before flaming. Niels. On 12/10/06, Steven Grimm wrote: > Toby Douglass wrote: > > Single-thread event-driven seems to me to basically mean state > > machine. State machines are wonderful things for achieving simple, > > bug-free code, but they have a cost; they are implicitly > > single-threaded. This can mean you cannot use them in some > > situations, because you will inherently block whenever you perform work. > > That's not strictly true; you can, for example, have multiple state > machines running concurrently (the implementation strategy I used when I > added thread support to memcached). Or you can have a single thread > responsible for I/O operations that hands work off to other threads that > perform whatever blocking operations they need. Or you can combine the > two and have a small set of I/O management threads and a larger set of > worker threads. > > The right strategy depends on the particulars of the application, of course. > > -Steve > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkey.org/mailman/listinfo/libevent-users > > From newroswell at gmail.com Sun Dec 10 20:46:39 2006 From: newroswell at gmail.com (Kevin Sanders) Date: Sun Dec 10 20:46:44 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <457C1466.1010806@summerblue.net> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> Message-ID: <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> On 12/10/06, Toby Douglass wrote: > I've not added support for writes, because I > think people generally issue blocking writes, since non-blocking means > that if you return from a function which issues a send you have to > ensure the lifetime of the buffer you've sent is non-local. If you're doing even a small amount of writing, you're going to have dismal performance (at best) using blocking writes. If you're talking to a peer socket (real world) that is no longer responding, this write may take more than a minute to error out. Make the writes async, use a callback when the write completes, similar to the read completion. Basically your buffer management should be careful to never reuse or free a buffer that has a pending IO. You're already doing this for the reads, AcceptEx and ConnectEx. A very tempting and huge mistake would be to call a blocking write from your read completion callback (using its IOCP thread). That would then block that IOCP thread, which can't process completions until the write completes or errors out. This is very bad. However, issuing an async write from the read callback is a good idea if you have the data available. One of my coworkers recently observed, that handles associated with a IOCP seem to have CPU affinity, at least sometimes. In a read completion callback, he posted another read (which is fine and encouraged) and then went off and did a lot of processing which preventing it from calling GQCS for about 20 seconds (very bad). Even though there were 3 other threads waiting on GQCS, they couldn't pop the completion status for the read from the IOCP even though the read had completed. Finally, as soon as the original thread came back around and called GQCS, it popped the completion instead of the other threads which had been waiting the whole time. This makes sense, because a running thread that is reading & writing would suffer a CPU cache flush if it changed CPUs. This was on a true dual CPU box, not a dual core, or hyperthreaded. I've never read anything that confirms this, but we did see it in this case. The lesson here is you don't want the IOCP threads doing anything except issuing async IO, popping completions and a quick state machine change (see below) and issue another async IO if needed. If more processing is needed, put a work item in a queue for another thread to process. That work thread can call your state machine callback when it is finished, and that may in turn cause further async IO. > Single-thread event-driven seems to me to basically mean state machine. > State machines are wonderful things for achieving simple, bug-free > code, but they have a cost; they are implicitly single-threaded. This > can mean you cannot use them in some situations, because you will > inherently block whenever you perform work. I'm not sure I follow this. Are you saying you can't use state machines in a multi-threaded application because they cause threads to block? State machines hold the status of some hypothetical object. If that state changes, and the new state dictates to send or receive data, the IO should be issued asynchronously, and state changed to reflect it is pending. In other words, if you have some "state" that requires calculations or IO, that can't be determined or completed quickly then the task of doing the calculation or IO should, in itself, be a different specific case of the state machine. > Also note that with GetQueuedCompletionStatus(), you're supposed, for > optimal performance, to have multiple threads (2xCPU) blocking on the > IOCP object. > > Given the advent and growing popularity of multi-core CPUs, single > threaded blocking seems inappropriate. Bingo, use async writes! > Note though that with GetQueuedCompletionStatus(), the user has no > synchronization work to do. The API handles it all behind the scenes. Kevin From schumi.han at gmail.com Sun Dec 10 21:56:00 2006 From: schumi.han at gmail.com (Zhu Han) Date: Sun Dec 10 21:56:03 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <457C1466.1010806@summerblue.net> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> Message-ID: <4e777ed10612101856m133580b0l13fb4003ea6c4a87@mail.gmail.com> > > > 2)I suppose socket_internal_iocp_read is called before you invoke the > > callback to let the callback consume the received data. Why do you call > > socket_internal_iocp_read firstly? > > Well, socket_internal_iocp_read() issues a non-blocking ReadEx() on the > socket. The user could do this, but the API can do it for him without > any loss of functionality. So, when the user gives me a socket, I issue > a read on it; then, when the read completes, I call the callback to pass > him the data and issue another read. This way, it's simpler and easier > for the user; all he does is add his socket, and then that's it - the > callback is called when data arrives. He has nothing else to worry > about or so. I have made some mistake when I type the above words. I just mean you should issue socket_internal_iocp_read firstly and then let the callbacks to consume the data. However, in your code, you invoke the callbacks before socket_internal_iocp_read. See the following snippet: siss->callback_function( siss->socket, SOCKET_IOCP_SOCKET_RECV_SUCCESS, siss->read_buffer, byte_count, (void *) siss->user_state ); socket_internal_iocp_read( siss ); > 3)Is there any plan to support all of the Async operations, such as > > connect, listen, accept, read and write? > > I added listen and accept last week, and I'm testing them now. I didn't > add connect, because ConnectEx() is XP and higher only (it's not > available under w2k). I've not added support for writes, because I > think people generally issue blocking writes, since non-blocking means > that if you return from a function which issues a send you have to > ensure the lifetime of the buffer you've sent is non-local. As others have pointed out, Async WRITE is important for high-performance server. Single-thread event-driven seems to me to basically mean state machine. > State machines are wonderful things for achieving simple, bug-free > code, but they have a cost; they are implicitly single-threaded. This > can mean you cannot use them in some situations, because you will > inherently block whenever you perform work. > > Also note that with GetQueuedCompletionStatus(), you're supposed, for > optimal performance, to have multiple threads (2xCPU) blocking on the > IOCP object. > > Given the advent and growing popularity of multi-core CPUs, single > threaded blocking seems inappropriate. > > Note though that with GetQueuedCompletionStatus(), the user has no > synchronization work to do. The API handles it all behind the scenes. Single-thread event-driven model just means the event loop is running in one thread's context. There a lot of ways to combine it with the multi-thread worker. _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkey.org/mailman/listinfo/libevent-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20061211/675a257b/attachment.htm From schumi.han at gmail.com Sun Dec 10 22:10:37 2006 From: schumi.han at gmail.com (Zhu Han) Date: Sun Dec 10 22:10:41 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> Message-ID: <4e777ed10612101910hff1235bxe9ecf56949608b68@mail.gmail.com> Kevin, please see the commets inside the body. On 12/11/06, Kevin Sanders wrote: > > One of my coworkers recently observed, that handles associated with a > IOCP seem to have CPU affinity, at least sometimes. In a read > completion callback, he posted another read (which is fine and > encouraged) and then went off and did a lot of processing which > preventing it from calling GQCS for about 20 seconds (very bad). Even > though there were 3 other threads waiting on GQCS, they couldn't pop > the completion status for the read from the IOCP even though the read > had completed. Finally, as soon as the original thread came back > around and called GQCS, it popped the completion instead of the other > threads which had been waiting the whole time. > > This makes sense, because a running thread that is reading & writing > would suffer a CPU cache flush if it changed CPUs. This was on a true > dual CPU box, not a dual core, or hyperthreaded. I've never read > anything that confirms this, but we did see it in this case. What' the limit for the running thread for the IOCP? If you choose 0 for it and the platform is UP, there could be only one thread which can running for the IOCP. I just can't believe it what you have observed. Are you sure the 2nd read operation is completed before the 1st thread back to the GQCS? Do you mean only the 2nd read operation's result can't be get by GQCS? Does the other IO operations completed during the time be get by GQCS? best reagards, hanzhu -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20061211/1842a542/attachment-0001.htm From newroswell at gmail.com Mon Dec 11 00:17:25 2006 From: newroswell at gmail.com (Kevin Sanders) Date: Mon Dec 11 00:17:29 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <4e777ed10612101910hff1235bxe9ecf56949608b68@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> <4e777ed10612101910hff1235bxe9ecf56949608b68@mail.gmail.com> Message-ID: <375baf50612102117n7c056627i3bcb1df0113a2a47@mail.gmail.com> On 12/10/06, Zhu Han wrote: > Kevin, please see the commets inside the body. > On 12/11/06, Kevin Sanders wrote: > > > One of my coworkers recently observed, that handles associated with a > > IOCP seem to have CPU affinity, at least sometimes. In a read > > completion callback, he posted another read (which is fine and > > encouraged) and then went off and did a lot of processing which > > preventing it from calling GQCS for about 20 seconds (very bad). Even > > though there were 3 other threads waiting on GQCS, they couldn't pop > > the completion status for the read from the IOCP even though the read > > had completed. Finally, as soon as the original thread came back > > around and called GQCS, it popped the completion instead of the other > > threads which had been waiting the whole time. > > > > This makes sense, because a running thread that is reading & writing > > would suffer a CPU cache flush if it changed CPUs. This was on a true > > dual CPU box, not a dual core, or hyperthreaded. I've never read > > anything that confirms this, but we did see it in this case. > > What' the limit for the running thread for the IOCP? If you choose 0 for it > and the platform is UP, there could be only one thread which can running for > the IOCP. I'm not sure what limit your asking about. Are you talking about the GQCS milliseconds timeout value? In any case I'm not sure. He was using his own IOCP code. > I just can't believe it what you have observed. Are you sure the 2nd read > operation is completed before the 1st thread back to the GQCS? That's what we kept thinking. Hard to believe. At one point he ran the thread in an infinite loop after posting the second read and the completion would never pop out of the IOCP with another thread/CPU. > Do you mean only the 2nd read operation's result can't be get by GQCS? Does > the other IO operations completed during the time be get by GQCS? Oh I'm not saying this is fact, only something we observed that we can't explain. The handle appeared to have some kind of affinity for that thread in his code, on that machine, that day. I actually forgot about this until this discussion, tomorrow I'll try to reproduce this with my code. Kevin From schumi.han at gmail.com Mon Dec 11 03:02:53 2006 From: schumi.han at gmail.com (Zhu Han) Date: Mon Dec 11 03:03:19 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <375baf50612102117n7c056627i3bcb1df0113a2a47@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> <4e777ed10612101910hff1235bxe9ecf56949608b68@mail.gmail.com> <375baf50612102117n7c056627i3bcb1df0113a2a47@mail.gmail.com> Message-ID: <4e777ed10612110002t48ec0472o7e6b9f03242100f1@mail.gmail.com> On 12/11/06, Kevin Sanders wrote: > > I'm not sure what limit your asking about. Are you talking about the > GQCS milliseconds timeout value? In any case I'm not sure. He was > using his own IOCP code. I mean the value of NumberOfConcurrentThreads* *when invoke CreateIoCompletionPort. What's the value for it? > Oh I'm not saying this is fact, only something we observed that we > can't explain. The handle appeared to have some kind of affinity for > that thread in his code, on that machine, that day. I actually forgot > about this until this discussion, tomorrow I'll try to reproduce this > with my code. Thanks a lot. If you can reproduce it, please let me known. I'll try to reproduce it when some box are available at at hands. I suspect this types of CPU affinity is non-sense since it could badly hurt the performance. > -- best regards, hanzhu -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20061211/174c82dc/attachment.htm From toby.douglass at summerblue.net Mon Dec 11 03:18:31 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Mon Dec 11 03:18:35 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> Message-ID: <457D1457.4060104@summerblue.net> Kevin Sanders wrote: > On 12/10/06, Toby Douglass wrote: >> I've not added support for writes, because I >> think people generally issue blocking writes, since non-blocking means >> that if you return from a function which issues a send you have to >> ensure the lifetime of the buffer you've sent is non-local. > > If you're doing even a small amount of writing, you're going to have > dismal performance (at best) using blocking writes. If you're talking > to a peer socket (real world) that is no longer responding, this write > may take more than a minute to error out. True. I non-block and select and give it a couple of seconds, but of course even a couple of seconds is still hugely long for some uses. > One of my coworkers recently observed, that handles associated with a > IOCP seem to have CPU affinity, at least sometimes. In a read > completion callback, he posted another read (which is fine and > encouraged) and then went off and did a lot of processing which > preventing it from calling GQCS for about 20 seconds (very bad). Even > though there were 3 other threads waiting on GQCS, they couldn't pop > the completion status for the read from the IOCP even though the read > had completed. Finally, as soon as the original thread came back > around and called GQCS, it popped the completion instead of the other > threads which had been waiting the whole time. Oh man...! > The lesson here is you don't want the IOCP threads doing anything > except issuing async IO, popping completions and a quick state machine > change (see below) and issue another async IO if needed. If more > processing is needed, put a work item in a queue for another thread to > process. That work thread can call your state machine callback when > it is finished, and that may in turn cause further async IO. True. But you realise in the code I've written the IOCP threads are internal to the library itself - the user doesn't see them or touch them. All they do is call GQCS. If the user did blocking writes, they would be outside the IOCP mechanism and they wouldn't be using the IOCP threads. >> Single-thread event-driven seems to me to basically mean state machine. >> State machines are wonderful things for achieving simple, bug-free >> code, but they have a cost; they are implicitly single-threaded. This >> can mean you cannot use them in some situations, because you will >> inherently block whenever you perform work. > > I'm not sure I follow this. Are you saying you can't use state > machines in a multi-threaded application because they cause threads to > block? No - I'm saying state machines inherently serialise, and so if you need parallelism, you have a problem. From toby.douglass at summerblue.net Mon Dec 11 03:22:45 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Mon Dec 11 03:22:53 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <4e777ed10612101856m133580b0l13fb4003ea6c4a87@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <4e777ed10612101856m133580b0l13fb4003ea6c4a87@mail.gmail.com> Message-ID: <457D1555.1040801@summerblue.net> Zhu Han wrote: > I have made some mistake when I type the above words. I just mean you > should > issue socket_internal_iocp_read firstly and then let the callbacks to > consume the data. However, in your code, you invoke the callbacks before > socket_internal_iocp_read. See the following snippet: > siss->callback_function( siss->socket, > SOCKET_IOCP_SOCKET_RECV_SUCCESS, siss->read_buffer, byte_count, (void *) > siss->user_state ); > socket_internal_iocp_read( siss ); Ah. Go look at socket_iocp_add_socket(). You'll find the very first call to socket_internal_iocp_read() occurs at the end of *that* function, which gets the read ball rolling. > As others have pointed out, Async WRITE is important for high-performance > server. Yes, it's clear. I'm going to add it. >> Note though that with GetQueuedCompletionStatus(), the user has no >> synchronization work to do. The API handles it all behind the scenes. > > Single-thread event-driven model just means the event loop is running in > one thread's context. There a lot of ways to combine it with the multi-thread > worker. Ye-e-e-s-s...and no. I think I understand you to mean that we could, for example, arrange it so we have 2xCPU threads running GQCS and when one of those threads returns with a complete, we trigger or signal the main event loop thread? the problem with that surely is going to be the large amount of thread switching. From toby.douglass at summerblue.net Mon Dec 11 03:24:44 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Mon Dec 11 03:24:51 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <850f7cbe0612101549y7141c647lb064128e7fd29976@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <457C8A44.2000003@facebook.com> <850f7cbe0612101549y7141c647lb064128e7fd29976@mail.gmail.com> Message-ID: <457D15CC.7060401@summerblue.net> Niels Provos wrote: > Please, think about that before flaming. I don't think anyone is flaming anyone here right now. It seems to be a pretty scholarly, polite and reasonable discussion. From schumi.han at gmail.com Mon Dec 11 03:53:16 2006 From: schumi.han at gmail.com (Zhu Han) Date: Mon Dec 11 03:53:24 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <457D1555.1040801@summerblue.net> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <4e777ed10612101856m133580b0l13fb4003ea6c4a87@mail.gmail.com> <457D1555.1040801@summerblue.net> Message-ID: <4e777ed10612110053p62a9a335pe6a2f0cb97bc2203@mail.gmail.com> On 12/11/06, Toby Douglass wrote: > > > Ah. Go look at socket_iocp_add_socket(). You'll find the very first > call to socket_internal_iocp_read() occurs at the end of *that* > function, which gets the read ball rolling. Yeah, you're right! I didn't pay attention to the prior socket_internal_iocp_read. Ye-e-e-s-s...and no. I think I understand you to mean that we could, > for example, arrange it so we have 2xCPU threads running GQCS and when > one of those threads returns with a complete, we trigger or signal the > main event loop thread? the problem with that surely is going to be the > large amount of thread switching. You may check out this paper:Multiprocessor Support for Event-Driven Programs. > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkey.org/mailman/listinfo/libevent-users > -- best regards, hanzhu -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20061211/1cda0743/attachment.htm From newroswell at gmail.com Mon Dec 11 12:31:39 2006 From: newroswell at gmail.com (Kevin Sanders) Date: Mon Dec 11 12:31:51 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <457D1457.4060104@summerblue.net> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> <457D1457.4060104@summerblue.net> Message-ID: <375baf50612110931h734755a3v125fcd0677fd739d@mail.gmail.com> On 12/11/06, Toby Douglass wrote: > Kevin Sanders wrote: > > The lesson here is you don't want the IOCP threads doing anything > > except issuing async IO, popping completions and a quick state machine > > change (see below) and issue another async IO if needed. If more > > processing is needed, put a work item in a queue for another thread to > > process. That work thread can call your state machine callback when > > it is finished, and that may in turn cause further async IO. > > True. But you realise in the code I've written the IOCP threads are > internal to the library itself - the user doesn't see them or touch > them. All they do is call GQCS. If the user did blocking writes, they > would be outside the IOCP mechanism and they wouldn't be using the IOCP > threads. I haven't looked at you're code yet, sorry I don't know the function names. I'm referring to when the IOCP thread calls GQCS and sees the read completion, it calls a read completion callback I believe? If someone made a blocking call from this callback (the callback is running on the IOCP thread) then that would be bad (performance wise). So the IOCP threads aren't totally internal because they run the callbacks. Unless these IOCP threads are just triggering an event somewhere that the user threads are waiting on (please say no)? Kevin From newroswell at gmail.com Mon Dec 11 13:00:14 2006 From: newroswell at gmail.com (Kevin Sanders) Date: Mon Dec 11 13:00:26 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <4e777ed10612110002t48ec0472o7e6b9f03242100f1@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> <4e777ed10612101910hff1235bxe9ecf56949608b68@mail.gmail.com> <375baf50612102117n7c056627i3bcb1df0113a2a47@mail.gmail.com> <4e777ed10612110002t48ec0472o7e6b9f03242100f1@mail.gmail.com> Message-ID: <375baf50612111000h519738id9a85c7e4b35914@mail.gmail.com> On 12/11/06, Zhu Han wrote: > > > On 12/11/06, Kevin Sanders wrote: > > I'm not sure what limit your asking about. Are you talking about the > > GQCS milliseconds timeout value? In any case I'm not sure. He was > > using his own IOCP code. > > I mean the value of NumberOfConcurrentThreads when invoke > CreateIoCompletionPort. > What's the value for it? Ah, that's a good point. We're pretty sure it was 0, which means allow as many as physical processors, but if it was 1, that would explain it. Another clue with this is that if the first thread blocked (in our test we called Sleep(60000), one of the other IOCP threads would then be able to pop that sockets completion notification. Kevin From toby.douglass at summerblue.net Mon Dec 11 13:38:59 2006 From: toby.douglass at summerblue.net (Toby Douglass) Date: Mon Dec 11 13:39:04 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <375baf50612110931h734755a3v125fcd0677fd739d@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> <457D1457.4060104@summerblue.net> <375baf50612110931h734755a3v125fcd0677fd739d@mail.gmail.com> Message-ID: <457DA5C3.2040100@summerblue.net> Kevin Sanders wrote: > I haven't looked at you're code yet, sorry I don't know the function > names. I'm referring to when the IOCP thread calls GQCS and sees the > read completion, it calls a read completion callback I believe? If > someone made a blocking call from this callback (the callback is > running on the IOCP thread) then that would be bad (performance wise). > > So the IOCP threads aren't totally internal because they run the > callbacks. Ah, yes, quite so. > Unless these IOCP threads are just triggering an event > somewhere that the user threads are waiting on (please say no)? No, they're not. :-) From nickm at freehaven.net Mon Dec 11 13:50:06 2006 From: nickm at freehaven.net (Nick Mathewson) Date: Mon Dec 11 13:50:12 2006 Subject: [Libevent-users] [Patch] Fix a bug related to DNS timeout counting Message-ID: <20061211184933.GZ29964@totoro.wangafu.net> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: not available Url : http://monkeymail.org/archives/libevent-users/attachments/20061211/acd6eaa2/attachment.bin From provos at citi.umich.edu Mon Dec 11 23:02:51 2006 From: provos at citi.umich.edu (Niels Provos) Date: Mon Dec 11 23:03:19 2006 Subject: [Libevent-users] [Patch] Fix a bug related to DNS timeout counting In-Reply-To: <20061211184933.GZ29964@totoro.wangafu.net> References: <20061211184933.GZ29964@totoro.wangafu.net> Message-ID: <850f7cbe0612112002t7d21011bvdcd32674b9f7eed@mail.gmail.com> Thank you. I have applied the patch to trunk. Niels. On 12/11/06, Nick Mathewson wrote: > Hi, all! This patch fixes a bug in nameserver timeouts in evdns.c. > Previously, we would count the number of successive requests that had > timed out in a row for each nameserver, but we would never actually > reset the timeout count to zero. This, obviously, would create > problems: see the Tor bugtracker entry at > http://bugs.noreply.org/flyspray/index.php?id=326&do=details > > This patch resets the successive timeout count to zero when: > - A nameserver comes up > - We receive a reply from a nameserver > - We decide to not use the nameserver for a while because of its > timeout count. > > This patch also changes the timeout threshold from 3 to 5 seconds. > Probably, it should be easier to adjust. There may also be other > issues that cause spurious nameserver timeouts: see the final comment > in the bugtracker link above. > > yrs, > -- > Nick Mathewson > > > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkey.org/mailman/listinfo/libevent-users > > > > From oz at nixil.net Tue Dec 12 00:04:26 2006 From: oz at nixil.net (Phil Oleson) Date: Tue Dec 12 00:04:47 2006 Subject: [Libevent-users] Re: evtimer complains... In-Reply-To: <850f7cbe0612091708w40063c3am47c916cb1e390f5b@mail.gmail.com> References: <457B5AB2.2050200@nixil.net> <850f7cbe0612091708w40063c3am47c916cb1e390f5b@mail.gmail.com> Message-ID: <457E385A.1060607@nixil.net> Ya.. I think some better documentation is in order.. I also am thinking that you might want to convert gettime() to evgettime() and export it for use with the library to keep those that might have a system that doesn't have CLOCK_MONOTONIC, which defaults to CLOCK_REALTIME or even defaults to gettimeofday() (all possible scenarios depending on the system), in order to have a common way to manipulate timers that match libevent. I've satisfied my questions.. and used a relative timer in my code. -Phil. Niels Provos wrote: > The libevent API has never supported absolute times for timeouts. If > they worked before then that was only by accident and never by > intention. The switch to clock monotonic was made to support clock > resets. So, personally, I am very surprised that absolute times ever > worked for you. > > Is this something that should be documented more clearly in the man page? > > Niels. > > On 12/9/06, Phil Oleson wrote: >> Niels, >> >> I've taken a little time time to look through my issue with >> evtimers. Previously, Scott Lamb questioned my code using absolute >> time with evtimers, but I see no problem with this. It used to work >> pre-1.2, and I've tracked the issue down to gettime() using >> CLOCK_MONOTONIC rather than CLOCK_REALTIME. When I've hacked libevent to >> use CLOCK_REALTIME, my test code works. To me it seems that using >> CLOCK_MONOTONIC causes issues with calls to gettimeofday. Was there >> any particular reason to have CLOCK_MONOTONIC as the arg to >> clock_gettime()? I would just like to understand this better before >> I rewrite my application. >> >> -Phil. >> >> From schumi.han at gmail.com Tue Dec 12 00:48:19 2006 From: schumi.han at gmail.com (Zhu Han) Date: Tue Dec 12 00:48:22 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <375baf50612111000h519738id9a85c7e4b35914@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> <4e777ed10612101910hff1235bxe9ecf56949608b68@mail.gmail.com> <375baf50612102117n7c056627i3bcb1df0113a2a47@mail.gmail.com> <4e777ed10612110002t48ec0472o7e6b9f03242100f1@mail.gmail.com> <375baf50612111000h519738id9a85c7e4b35914@mail.gmail.com> Message-ID: <4e777ed10612112148x268f1580g6b65c11ee7b5dcd7@mail.gmail.com> On 12/12/06, Kevin Sanders wrote: > > On 12/11/06, Zhu Han wrote: > > Ah, that's a good point. We're pretty sure it was 0, which means > allow as many as physical processors, but if it was 1, that would > explain it. Another clue with this is that if the first thread > blocked (in our test we called Sleep(60000), one of the other IOCP > threads would then be able to pop that sockets completion > notification. If the number is 0, the platform is UP and the IOCP thread never blocks at any point, it is possible another thread will never get the chance be waken up. Can you reproduce the CPU affinity problem? -- best regards, hanzhu -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20061212/e8c7309c/attachment.htm From newroswell at gmail.com Tue Dec 12 10:17:18 2006 From: newroswell at gmail.com (Kevin Sanders) Date: Tue Dec 12 10:17:22 2006 Subject: [Libevent-users] Add support for WINDOWS Overlapped IO In-Reply-To: <4e777ed10612112148x268f1580g6b65c11ee7b5dcd7@mail.gmail.com> References: <4e777ed10612092114w64923c57ocb824ed4c73f7aa8@mail.gmail.com> <457BC9F1.6090808@summerblue.net> <4e777ed10612100422g1ed6ec16kca175eb98f786867@mail.gmail.com> <457C1466.1010806@summerblue.net> <375baf50612101746o280f0297g82e614f6cbb250e1@mail.gmail.com> <4e777ed10612101910hff1235bxe9ecf56949608b68@mail.gmail.com> <375baf50612102117n7c056627i3bcb1df0113a2a47@mail.gmail.com> <4e777ed10612110002t48ec0472o7e6b9f03242100f1@mail.gmail.com> <375baf50612111000h519738id9a85c7e4b35914@mail.gmail.com> <4e777ed10612112148x268f1580g6b65c11ee7b5dcd7@mail.gmail.com> Message-ID: <375baf50612120717q6ef0bdd0me1c4237394944458@mail.gmail.com> On 12/11/06, Zhu Han wrote: > > > On 12/12/06, Kevin Sanders wrote: > > On 12/11/06, Zhu Han wrote: > > > > Ah, that's a good point. We're pretty sure it was 0, which means > > allow as many as physical processors, but if it was 1, that would > > explain it. Another clue with this is that if the first thread > > blocked (in our test we called Sleep(60000), one of the other IOCP > > threads would then be able to pop that sockets completion > > notification. > > > If the number is 0, the platform is UP and the IOCP thread never blocks at > any point, it is possible another thread will never get the chance be waken > up. Right that's what I understand from MSDN. We all have dual CPU development boxes at my shop, but... > Can you reproduce the CPU affinity problem? I couldn't reproduce it yesterday, using my code, on my dual CPU box. I was too busy too spend more than a few minutes on it though. I'm thinking my coworker must have been using a UP box. This is unexpected behavior (for me) though. I would think if you have one thread in a while(1) ; loop, another thread would eventually get a time slice and pop the completion from the IOCP. Kevin From dsze at alumni.uwaterloo.ca Thu Dec 14 12:31:35 2006 From: dsze at alumni.uwaterloo.ca (David Sze) Date: Thu Dec 14 12:32:15 2006 Subject: [Libevent-users] Patch for signal handling Message-ID: <20061214173135.GA81457@mail.distrust.net> Hi, I have an application that repeatedly forks many short-lived child processes and waits for SIGCHLD notification. Frequently, the application ends up blocking in the read() call in evsignal_cb(). I think there's a condition where more than one signal is received and evsignal_handler() is called multiple times before evsignal_cb() gets called. When evsignal_cb() finally runs, it drains all the notifications from the socketpair, so the subsequent calls to evsignal_cb() block in read(). Attached is a patch that fixes the problem in my application, but I'm not a libevent expert so corrections would be welcome. -------------- next part -------------- --- libevent-1.2a/signal.c.orig 2006-10-27 23:28:57.000000000 -0400 +++ libevent-1.2a/signal.c 2006-12-14 11:19:27.000000000 -0500 @@ -71,7 +71,7 @@ ssize_t n; n = read(fd, signals, sizeof(signals)); - if (n == -1) + if (n == -1 && errno != EAGAIN && errno != EWOULDBLOCK) event_err(1, "%s: read", __func__); event_add(ev, NULL); } @@ -102,6 +102,7 @@ FD_CLOSEONEXEC(ev_signal_pair[1]); fcntl(ev_signal_pair[0], F_SETFL, O_NONBLOCK); + fcntl(ev_signal_pair[1], F_SETFL, O_NONBLOCK); event_set(&ev_signal, ev_signal_pair[1], EV_READ, evsignal_cb, &ev_signal); From nickm at freehaven.net Fri Dec 15 01:27:14 2006 From: nickm at freehaven.net (Nick Mathewson) Date: Fri Dec 15 01:27:39 2006 Subject: [Libevent-users] [Patch] Add dns server support, ipv6 support, and misc cleanups to evdns Message-ID: <20061215062714.GF25249@totoro.wangafu.net> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: not available Url : http://monkeymail.org/archives/libevent-users/attachments/20061215/6cab0e5f/attachment-0001.bin From gerrit at trispen.com Mon Dec 18 06:32:07 2006 From: gerrit at trispen.com (Gerrit Niezen (Trispen)) Date: Mon Dec 18 06:32:32 2006 Subject: [Libevent-users] Assertion failed - Invalid signal or error Message-ID: <45867C37.5070504@trispen.com> Hi, I have a Win32 build of libevent (from http://www.datanerds.net/~mike/libevent.html) and I'm trying to run it in Visual Studio 2005. Everything builds fine, but when I try to run the example event_test it fails on an assertion: Program: winsig.c Line: 419 Expression: Invalid signal or error Call Stack shows the following: event_test.exe!signal(int signum=4072, void (int)* sigact=0x00000001) Line 419 + 0x40 bytes C event_test.exe!win32_del(win32op * arg=0x0045b018, event * ev=0x0012fef0) Line 152 + 0xe bytes C event_test.exe!event_del(event * ev=0x0012fef0) Line 401 + 0x18 bytes C event_test.exe!win32_dispatch(void * arg=0x0045b018, timeval * tv=0x0012fd28) Line 138 + 0x9 bytes C event_test.exe!event_loop(int flags=0) Line 255 + 0x18 bytes C event_test.exe!event_dispatch() Line 207 + 0x7 bytes C event_test.exe!main(int argc=1, char * * argv=0x00333528) Line 131 C event_test.exe!__tmainCRTStartup() Line 318 + 0x19 bytes C event_test.exe!mainCRTStartup() Line 187 C Does this mean it crashes when the event is deleted? Why would something like this happen? Thank you in advance, Gerrit Niezen From bmw at borderware.com Tue Dec 19 20:06:31 2006 From: bmw at borderware.com (Bruce Walker) Date: Tue Dec 19 20:37:25 2006 Subject: [Libevent-users] Building from svn co: missing stuff? Message-ID: <45888C97.6000500@borderware.com> Forgive me if this is a trivial blunder, but when I checkout a release or the trunk from svn, there's a whole whack of missing files and I can't build. Files like configure, config.sub, config.guess, config.h.in, Makefile.in. Then there's libtool ... I've been copying in missing bits from the libevent-1.2a.tar.gz tarball and it almost builds. I'm stuck at, /usr/local/bin/bash ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I. -Icompat -O -pipe -g -O2 -Wall -c -o event.lo `test -f 'event.c' || echo './'`event.c libtool: compile: unable to infer tagged configuration libtool: compile: specify a tag with `--tag' *** Error code 1 So can someone enlighten me? Where's my files at? :-) Thanks! From bmw at borderware.com Tue Dec 19 21:31:30 2006 From: bmw at borderware.com (Bruce Walker) Date: Tue Dec 19 21:31:32 2006 Subject: [Libevent-users] Building from svn co: missing stuff? In-Reply-To: <45888C97.6000500@borderware.com> References: <45888C97.6000500@borderware.com> Message-ID: <4588A082.9060201@borderware.com> Bruce Walker wrote: > I've been copying in missing bits from the libevent-1.2a.tar.gz > tarball and it almost builds. I'm stuck at, > > /usr/local/bin/bash ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. > -I. -I. -Icompat -O -pipe -g -O2 -Wall -c -o event.lo `test -f > 'event.c' || echo './'`event.c > libtool: compile: unable to infer tagged configuration > libtool: compile: specify a tag with `--tag' > *** Error code 1 Ok, turns out that *that* error was caused by me copying in files that had been configured in the ports tree on a FreeBSD 6.1 system to my compile box running FreeBSD 4.10. Fixed by copying files from the 4.10 ports tree. D'oh! But I'm still mystified by the lack of configure files in the svn tree. I'd still be interested in the 10-cent tour of that. From william at 25thandClement.com Tue Dec 19 23:16:47 2006 From: william at 25thandClement.com (William Ahern) Date: Tue Dec 19 23:16:58 2006 Subject: [Libevent-users] Building from svn co: missing stuff? In-Reply-To: <4588A082.9060201@borderware.com> References: <45888C97.6000500@borderware.com> <4588A082.9060201@borderware.com> Message-ID: <20061220041647.GA1799@wilbur.25thandClement.com> On Tue, Dec 19, 2006 at 09:31:30PM -0500, Bruce Walker wrote: > Bruce Walker wrote: > >I've been copying in missing bits from the libevent-1.2a.tar.gz > >tarball and it almost builds. I'm stuck at, > > > >/usr/local/bin/bash ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. > >-I. -I. -Icompat -O -pipe -g -O2 -Wall -c -o event.lo `test -f > >'event.c' || echo './'`event.c > >libtool: compile: unable to infer tagged configuration > >libtool: compile: specify a tag with `--tag' > >*** Error code 1 > > Ok, turns out that *that* error was caused by me copying in files that > had been configured in the ports tree on a FreeBSD 6.1 system to my > compile box running FreeBSD 4.10. Fixed by copying files from the 4.10 > ports tree. D'oh! > > But I'm still mystified by the lack of configure files in the svn tree. > I'd still be interested in the 10-cent tour of that. Many (most?) projects don't commit a configure script. The configure script is generated from configure.ac (or previously configure.in). Arguably you don't want to commit generated code, only the source. Typically, the configure scripts (and other odds and ends) are attended to while creating a release tarball. To generate it yourself, you would do something like this from the source directory: aclocal autoheader automake autoconf Or something like that. GNU Autotools is notoriously difficult to wield, not the least because each independent revision of the various tools mentioned above creates intolerable incompatibilities with every other version. It quickly becomes something of a dark art (for the blessed few) or more typically an excercise in self-immolation. And that's coming from somebody who actually uses and appreciates M4, the macro language/parser which is employed heavily by autotools because it's one of the few dependable utilities common and compatible amongst all Unix platforms. From bmw at borderware.com Wed Dec 20 08:28:52 2006 From: bmw at borderware.com (Bruce Walker) Date: Wed Dec 20 08:29:06 2006 Subject: [Libevent-users] Building from svn co: missing stuff? In-Reply-To: <20061220041647.GA1799@wilbur.25thandClement.com> References: <45888C97.6000500@borderware.com> <4588A082.9060201@borderware.com> <20061220041647.GA1799@wilbur.25thandClement.com> Message-ID: <45893A94.7060900@borderware.com> William Ahern wrote: > On Tue, Dec 19, 2006 at 09:31:30PM -0500, Bruce Walker wrote: > >> I'm still mystified by the lack of configure files in the svn tree. >> I'd still be interested in the 10-cent tour of that. >> > > Typically, the configure scripts (and other odds and ends) are attended to > while creating a release tarball. Thank you William! You have given me much more than the 10-cent tour, and now I owe you. :-) Perhaps a reference to the Autoconf tools (and specific version no. if req'd) in either README or at the top of configure.in could be inserted to save future head-scratching. Fortunately after the release tree is configured once I can drop the svn files on top and build. Cheers! From Shanti.Subramanyam at Sun.COM Wed Dec 20 11:27:02 2006 From: Shanti.Subramanyam at Sun.COM (Shanti Subramanyam) Date: Wed Dec 20 11:26:52 2006 Subject: [Libevent-users] Build problems on Solaris In-Reply-To: <45888C97.6000500@borderware.com> References: <45888C97.6000500@borderware.com> Message-ID: <6BEDD1F5-8F66-4CE8-AE5E-68133AEF420C@sun.com> I'm trying to build libevent 1.2a on Solaris 10 using Sun Studio 11 compilers and am running into a couple of issues : 1) Compiling files event_tagging.c and http.c, gives a syntax error for the functions declared as __inline (decode_int_internal in event_tagging.c and evhttp_send in http.c) I edited these files to change '__inline' to 'inline' Is this the right fix or is there something in configure that must be fixed ? 2) I get the following error during linking : cc -I../compat -o .libs/event-test event-test.o -L/usr/sfw/ lib ../.libs/libevent.so -lsocket -R/opt/coolstack/lib Undefined first referenced symbol in file inet_aton ../.libs/libevent.so A grep of 'inet_aton' indicates that this function is defined in evdns.c, so why is this symbol undefined ? Thanks in advance for your help Shanti From oz at nixil.net Thu Dec 21 04:23:46 2006 From: oz at nixil.net (Phil Oleson) Date: Thu Dec 21 04:24:19 2006 Subject: [Libevent-users] evdns.h c++ patch. Message-ID: <458A52A2.10105@nixil.net> I was checking my little program for c++ cleanliness and noticed that evdns.h didn't have these little patches.. Can we get this patch commited? Index: evdns.h =================================================================== --- evdns.h (revision 304) +++ evdns.h (working copy) @@ -237,6 +237,10 @@ #ifndef EVENTDNS_H #define EVENTDNS_H +#ifdef __cplusplus +extern "C" { +#endif + /* Error codes 0-5 are as described in RFC 1035. */ #define DNS_ERR_NONE 0 /* The name server was unable to interpret the query */ @@ -303,4 +307,7 @@ #define DNS_NO_SEARCH 1 +#ifdef __cplusplus +} +#endif #endif // !EVENTDNS_H From william at opensource4you.com Mon Dec 25 13:16:25 2006 From: william at opensource4you.com (william@opensource4you.com) Date: Mon Dec 25 13:19:04 2006 Subject: [Libevent-users] looking for a swig interface for libevent Message-ID: <55193.81.242.147.176.1167070585.squirrel@mail.opensource4you.com> Hello, I'm python developer and using libevent via pyevent (pyrex). But, is there any one having a Swig interface for libevent ? I've tried a simple one (example.i): """ %module example %{ #include "http-internal.h" %} %include "http-internal.h" """ but got error, when doing "swig -python example.i": """ http-internal.h:40: Error: Syntax error in input(3). http-internal.h:52: Warning(305): Bad constant value (ignored). """ line 40 is: """ TAILQ_ENTRY(evhttp_connection) next; """ Thanks. From nickm at freehaven.net Wed Dec 27 12:10:24 2006 From: nickm at freehaven.net (Nick Mathewson) Date: Wed Dec 27 12:10:40 2006 Subject: [Libevent-users] [Patch] Avoid conflicts with platform strlcpy Message-ID: <20061227171024.GB12940@totoro.wangafu.net> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 652 bytes Desc: not available Url : http://monkeymail.org/archives/libevent-users/attachments/20061227/924658c8/attachment-0001.bin