From wenewboy at gmail.com Thu Jan 3 02:06:52 2008 From: wenewboy at gmail.com (wenew zhang) Date: Thu Jan 3 02:07:03 2008 Subject: [Libevent-users] hi, i install libevent1.3 and 1.4beta on freebsd7 beta, and it cant' run the test normal In-Reply-To: <20071231204629.GF29624@catbus.wangafu.net> References: <4eaa09eb0712280316h27ad5720s14c803c87c0d947c@mail.gmail.com> <20071231204629.GF29624@catbus.wangafu.net> Message-ID: <4eaa09eb0801022306t13241fa7rdbaa1d4d0e600d10@mail.gmail.com> Dear All, i'm gotta tell you the detail message abouts this,"regress.c1242error:'from_name' undeclared..."just happened when i make the test only,so i think that's maybe not a bug, or just like Nick said, "are generated with an old version of the RPC python script", if you make all the libevent,it's works,(make clean;make). but i think,test.sh skips all the test on freebsd7 beta4 and freebsd6.2,it's a bug,i got message like: wenewboy# sh test.sh Running tests: KQUEUE Skipping test DEVPOLL Skipping test POLL Skipping test SELECT Skipping test RTSIG Skipping test EPOLL Skipping test yrs Wenew On 1/1/08, Nick Mathewson wrote: > > On Fri, Dec 28, 2007 at 07:16:45PM +0800, wenew zhang wrote: > > when i try to run test.sh, > > it's skip all include kqueue, > > and then: > > make clean, > > make > > i got a message:regress.c1242 error:'from_name' undeclared(first use in > this > > function) > > ...... > > > > i get the same message in libevent1.41 and 1.3e > > > > It looks like maybe the regress.gen.c and regress.gen.h files are > generated with an old version of the RPC python script; the new > definition of EVTAG_ASSIGN should not give that error. > > Is anybody else seeing this message? I'm trying to reproduce it, but > I haven't found any way to do so. > > yrs, > -- > Nick > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20080103/3eb52e1f/attachment.htm From oz at nixil.net Thu Jan 3 17:27:19 2008 From: oz at nixil.net (Phil Oleson) Date: Thu Jan 3 17:27:49 2008 Subject: [Libevent-users] hi, i install libevent1.3 and 1.4beta on freebsd7 beta, and it cant' run the test normal In-Reply-To: <4eaa09eb0801022306t13241fa7rdbaa1d4d0e600d10@mail.gmail.com> References: <4eaa09eb0712280316h27ad5720s14c803c87c0d947c@mail.gmail.com> <20071231204629.GF29624@catbus.wangafu.net> <4eaa09eb0801022306t13241fa7rdbaa1d4d0e600d10@mail.gmail.com> Message-ID: <477D6147.6030606@nixil.net> I've reported this wierdness to Niels in the past. FreeBSD's /bin/sh differs from some other platforms in that when this happens (from test.sh): unset EVENT_NOKQUEUE export EVENT_NOKQUEUE the unset removes the EVENT_NOKQUEUE from the environment, and the export re-adds it with an undefined Rvalue. So as the library just checks for the existence of the EVENT_NOxxxx environment variables to disable a event mechanism, the test.sh program fails. The behavior of /bin/sh differs on other platforms and as the ports tree version of libevent never actually runs the test.sh script, it hasn't been a big concern. ( to fix for yourself edit the test.sh and remove the export lines after the unset line ) -Phil. wenew zhang wrote: > Dear All, > i'm gotta tell you the detail message abouts this,"regress.c1242 > error:'from_name' undeclared..."just happened when > i make the test only,so i think that's maybe not a bug, or just like > Nick said, "are generated with an old version of the RPC python script", > if you make all the libevent,it's works,(make clean;make). > but i think,test.sh skips all the test on freebsd7 beta4 and > freebsd6.2,it's a bug,i got message like: > wenewboy# sh test.sh > Running tests: > KQUEUE > Skipping test > DEVPOLL > Skipping test > POLL > Skipping test > SELECT > Skipping test > RTSIG > Skipping test > EPOLL > Skipping test > > yrs > Wenew > > > On 1/1/08, *Nick Mathewson* > wrote: > > On Fri, Dec 28, 2007 at 07:16:45PM +0800, wenew zhang wrote: > > when i try to run test.sh, > > it's skip all include kqueue, > > and then: > > make clean, > > make > > i got a message:regress.c1242 error:'from_name' undeclared(first > use in this > > function) > > ...... > > > > i get the same message in libevent1.41 and 1.3e > > > > It looks like maybe the regress.gen.c and regress.gen.h files are > generated with an old version of the RPC python script; the new > definition of EVTAG_ASSIGN should not give that error. > > Is anybody else seeing this message? I'm trying to reproduce it, but > I haven't found any way to do so. > > yrs, > -- > Nick > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkeymail.org/mailman/listinfo/libevent-users From william at opensource4you.com Fri Jan 4 09:48:22 2008 From: william at opensource4you.com (william@opensource4you.com) Date: Fri Jan 4 09:50:02 2008 Subject: [Libevent-users] libevent-1.4.0 beta released In-Reply-To: <850f7cbe0711122204l5a80cb82ra91c7958c457dfa@mail.gmail.com> References: <850f7cbe0711112359v11ed7736r17864294b8a95a5d@mail.gmail.com> <59248.81.247.4.131.1194857741.squirrel@mail.opensource4you.com> <850f7cbe0711122204l5a80cb82ra91c7958c457dfa@mail.gmail.com> Message-ID: <50810.81.244.87.144.1199458102.squirrel@mail.opensource4you.com> First of all happy new year to all ;-). Second, sorry for the delay, but free time is more and more difficult to find. I propose here a patch for "evhttp_dispatch_callback" that allow him to treat wild char in registered uri. (patch is based on libevent-1.4.1-beta) in attach you will find a test: "libevent-test.c" that will implement such uri. In the sample, I register "/test*" to the function "callback_http_index". That means that this function will be triggered when the browser will request the uri /test/12345/read (for example). This give much more flexibility. Thanks > Hi William, > > I think the most straightforward approach is to extend the set > callback mechanism to accept a wild card character such as *. I will > take a look at it. For now, progress is tracked in the source forge > tracker. > > Niels. > > On Nov 12, 2007 12:55 AM, wrote: >> I'm no more able to use my wsgi python binding to libevent, because the >> evhttp_dispatch_callback ( or evhttp_handle_request) function is now >> static. >> >> Indeed, as I've mentioned in my mail of "Sun, October 14, 2007 10:22 >> am", >> I've been forced to update this function. >> >> Because the function is not static, I'm able, with libevent-1.3 able to >> over-write it in my own code: >> Line 46 here >> http://www.opensource4you.com/cgi-bin/gitweb.cgi?p=fapws2;a=blob;f=fapws2/_evhttp.c;h=eb0cd0aebcb31b48874842335575827b89091596;hb=05ec30b72f106120d1aa2c7913ba609a1a1fe4a4 >> This is no more possible with libevent-1.4. >> >> >> Thanks to provide possibilities for extension like mine. >> Or, if I'm not using libevent as it should be, thanks to provide me a >> better way. >> >> >> Thanks >> >> >> PS: >> I remind here that my goal is to call a callback based on the start of >> the >> url. For example, if I have a callback associated to the url:/static/, >> all >> the following urls will trigger this call back: >> /static/img/logo.png >> /static/css/main.css >> /static/js/hello.js >> >> As specified in the wsgi specs ( www.wsgi.org), and url is composed of >> different elements: >> url = quote(environ.get('SCRIPT_NAME','')) >> url += quote(environ.get('PATH_INFO','')) >> if environ.get('QUERY_STRING'): >> url += '?' + environ['QUERY_STRING'] >> >> In my first example associated variable will be: >> environ['SCRIPT_NAME']="/static/", >> environ["PATH_INFO"]="img/logo.png", and >> environ["QUERY_STRING"]="". >> >> >> >> >> >> >> >> >> >> >> >> > Hi everyone, >> > >> > I am pleased to announce the release of libevent-1.4.0-beta. This >> > release contains major new features: >> > >> > - RPC subsystem that makes it easy to write distributed servers and >> > clients >> > - almost everything is documented via Doxygen now >> > - many fixes and improvements to evdns and evhttp >> > - libevent now builds two additional libraries: libevent_core >> > (containing only the event core) and libevent_extras (contained evdns, >> > evhttp and evrpc) >> > - performance improvements due to using a heap instead of red-black >> > trees for timeouts >> > - Solaris' event ports are better supported >> > >> > Plus many other fixes - see the ChangeLog file for more details. >> > >> > You can download libevent from >> > >> > http://www.monkey.org/~provos/libevent/ >> > >> > I would like to thank Charles Kerr, Christopher Layne, Hannah >> > Schroeter, Lubomir Marinov, Magne Mahre, Mark Heily, Maxim >> > Yegorushkin, Nick Mathewson, Prakash Sangappa and Trond Norbye for >> > their help. >> > >> > If you encounter any problems or would like to submit patches, let >> > either Nick Mathewson or myself know or use the tracker at: >> > >> > https://sourceforge.net/tracker/?group_id=50884 >> > >> > Thanks, >> > Niels. >> > _______________________________________________ >> > Libevent-users mailing list >> > Libevent-users@monkey.org >> > http://monkeymail.org/mailman/listinfo/libevent-users >> > >> > >> >> >> > > -------------- next part -------------- A non-text attachment was scrubbed... Name: handle_wildchar.patch Type: text/x-patch Size: 879 bytes Desc: not available Url : http://monkeymail.org/archives/libevent-users/attachments/20080104/8d435795/handle_wildchar.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: libevent-test.c Type: text/x-csrc Size: 1357 bytes Desc: not available Url : http://monkeymail.org/archives/libevent-users/attachments/20080104/8d435795/libevent-test.bin From jsobel at facebook.com Fri Jan 4 14:27:57 2008 From: jsobel at facebook.com (Jason Sobel) Date: Fri Jan 4 14:28:03 2008 Subject: [Libevent-users] evhttp and threads Message-ID: Hi everyone- A little background: my name is Jason Sobel, I'm an infrastructure engineer at Facebook and I'm looking at using evhttp as the backbone for Facebook's custom HTTP servers. I am currently working on two specific projects and we'll almost certainly end up writing more down the road so this server is something that will see a lot of use. I know libevent & threaded applications has been discussed before, with the prevailing wisdom provided by fellow Facebook engineer Steven Grimm: http://monkeymail.org/archives/libevent-users/2007-January/000450.html I've been reading over the evhttp code recently (1.4.1-beta) and, from what I can see, the approach Steve describes will not work for evhttp. The problem appears to be that, once a connection is created, the event base cannot be changed. Thus all connection are trapped on the same event base and you can't hand them off to other threads to complete. The only workaround I've found is to hand out some work to a thread, have it put completed requests on a thread-safe queue, and rely on an evtimer to periodically complete all the requests on that queue. Can anyone out there confirm that I'm understanding the code correctly? I've been toying with an idea for changing the code to more readily support multiple threads, however, and was hoping to get some feedback. The basic idea is to change accept_socket: static void accept_socket(int fd, short what, void *arg) { struct evhttp *http = arg; struct sockaddr_storage ss; socklen_t addrlen = sizeof(ss); int nfd; if ((nfd = accept(fd, (struct sockaddr *)&ss, &addrlen)) == -1) { event_warn("%s: bad accept", __func__); return; } if (evutil_make_socket_nonblocking(nfd) < 0) return; evhttp_get_request(http, nfd, (struct sockaddr *)&ss, addrlen); } Instead of accepting a single evhttp instance my idea is to pass in a variable number of evhttp structures, each with a different event base. When calling evhttp_get_request I would somehow (randomly, round-robin, user-defined, etc.) choose a evhttp to pass on. I *think* that this change will correctly trickle down throughout the rest of the code and allow multiple connections to run in parallel on different event bases. Thanks for taking the time to look over this, I hope to get feedback/comments! ???????????????? --jason From rognar at gmail.com Wed Jan 9 05:06:12 2008 From: rognar at gmail.com (Maksim Lapo) Date: Wed Jan 9 05:06:50 2008 Subject: [Libevent-users] Using bufferevent_add with select (Win32) Message-ID: Hi All. Why does bufferevent_add(struct event *ev, int timeout) use "int timeout" instead of "struct timeval *tv" ? Is't imposible to set timeout to 10 ms when bufferevent_add is used under Win32 (select). -- Best regards, Maksim Lapo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20080109/3956c259/attachment-0001.htm From hmd at mail.ru Sat Jan 12 00:49:45 2008 From: hmd at mail.ru (Eugene 'HMage' Bujak) Date: Sat Jan 12 00:50:36 2008 Subject: [Libevent-users] MSVC win32 patch against libevent-1.41-beta Message-ID: <478854F9.4060000@mail.ru> Hi. I'm interested in trying the libevent library for cross-platform capability, but unfortunately have to use msvc under windows. The library required some patching to make it work under msvc, though. The patch isn't final, I had to comment out some things. If you're interested in this patch and want better polished patch, I'll do it. Unfortunately, event-test.c still doesn't work, but another two examples do work as expected. -- - Eugene 'HMage' Bujak. -------------- next part -------------- diff -uNr libevent-1.4.1-beta/WIN32-Code/config.h libevent-1.4.1-beta-win32/WIN32-Code/config.h --- libevent-1.4.1-beta/WIN32-Code/config.h Mon Nov 12 05:37:32 2007 +++ libevent-1.4.1-beta-win32/WIN32-Code/config.h Fri Jan 11 16:28:45 2008 @@ -207,7 +207,7 @@ /* Define to appropriate substitue if compiler doesnt have __func__ */ #if defined(_MSC_VER) && _MSC_VER < 1300 -#define __func__ "??" +#define __func__ __FILE__ #else #define __func__ __FUNCTION__ #endif diff -uNr libevent-1.4.1-beta/WIN32-Code/win32.c libevent-1.4.1-beta-win32/WIN32-Code/win32.c --- libevent-1.4.1-beta/WIN32-Code/win32.c Sat Dec 22 06:03:54 2007 +++ libevent-1.4.1-beta-win32/WIN32-Code/win32.c Fri Jan 11 16:30:00 2008 @@ -48,6 +48,10 @@ #include "log.h" #include "event.h" #include "event-internal.h" + +//#ifndef USE_DEBUG +//#error USE_DEBUG is not defined +//#endif #define XFREE(ptr) do { if (ptr) free(ptr); } while(0) @@ -231,9 +235,30 @@ #define NEVENT 64 void * win32_init(struct event_base *_base) -{ +{ struct win32op *winop; - size_t size; + size_t size; + +#ifdef WIN32 + WORD wVersionRequested; + WSADATA wsaData; + int retval; + + wVersionRequested = MAKEWORD( 2, 2 ); + + retval = WSAStartup( wVersionRequested, &wsaData ); + if (retval != 0) { + event_err(1, "Couldn't initialize WinSock library.\n"); + return NULL; + } + + if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) { + event_err(1, "WinSock library is not acceptable version.\n"); + return NULL; + } + +#endif + if (!(winop = calloc(1, sizeof(struct win32op)))) return NULL; winop->fd_setsz = NEVENT; @@ -422,7 +447,9 @@ free(win32op->writeset_out); if (win32op->exset_out) free(win32op->exset_out); - /* XXXXX free the tree. */ + /* XXXXX free the tree. */ + + WSACleanup(); memset(win32op, 0, sizeof(win32op)); free(win32op); Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/buffer.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/buffer.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/evbuffer.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/evbuffer.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/evdns.sbr and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/evdns.sbr differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/event.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/event.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/event_tagging.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/event_tagging.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/evrpc.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/evrpc.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/evutil.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/evutil.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/http.sbr and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/http.sbr differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/libevent.bsc and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/libevent.bsc differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/libevent.lib and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/libevent.lib differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/libevent.pch and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/libevent.pch differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/log.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/log.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/misc.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/misc.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/select.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/select.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/signal.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/signal.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/strlcpy.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/strlcpy.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/vc60.idb and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/vc60.idb differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/vc60.pdb and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/vc60.pdb differ Binary files libevent-1.4.1-beta/WIN32-Prj/Debug/win32.obj and libevent-1.4.1-beta-win32/WIN32-Prj/Debug/win32.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/event_test/Debug/event-test.obj and libevent-1.4.1-beta-win32/WIN32-Prj/event_test/Debug/event-test.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/event_test/Debug/event_test.exe and libevent-1.4.1-beta-win32/WIN32-Prj/event_test/Debug/event_test.exe differ Binary files libevent-1.4.1-beta/WIN32-Prj/event_test/Debug/event_test.ilk and libevent-1.4.1-beta-win32/WIN32-Prj/event_test/Debug/event_test.ilk differ Binary files libevent-1.4.1-beta/WIN32-Prj/event_test/Debug/event_test.pch and libevent-1.4.1-beta-win32/WIN32-Prj/event_test/Debug/event_test.pch differ Binary files libevent-1.4.1-beta/WIN32-Prj/event_test/Debug/event_test.pdb and libevent-1.4.1-beta-win32/WIN32-Prj/event_test/Debug/event_test.pdb differ Binary files libevent-1.4.1-beta/WIN32-Prj/event_test/Debug/vc60.idb and libevent-1.4.1-beta-win32/WIN32-Prj/event_test/Debug/vc60.idb differ Binary files libevent-1.4.1-beta/WIN32-Prj/event_test/Debug/vc60.pdb and libevent-1.4.1-beta-win32/WIN32-Prj/event_test/Debug/vc60.pdb differ diff -uNr libevent-1.4.1-beta/WIN32-Prj/event_test/event_test.dsp libevent-1.4.1-beta-win32/WIN32-Prj/event_test/event_test.dsp --- libevent-1.4.1-beta/WIN32-Prj/event_test/event_test.dsp Fri Jan 11 16:38:37 2008 +++ libevent-1.4.1-beta-win32/WIN32-Prj/event_test/event_test.dsp Fri Jan 11 08:35:20 2008 @@ -39,6 +39,7 @@ # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c @@ -49,7 +50,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "event_test - Win32 Debug" @@ -62,6 +63,7 @@ # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c @@ -72,7 +74,7 @@ # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF diff -uNr libevent-1.4.1-beta/WIN32-Prj/libevent.dsp libevent-1.4.1-beta-win32/WIN32-Prj/libevent.dsp --- libevent-1.4.1-beta/WIN32-Prj/libevent.dsp Fri Jan 11 16:38:31 2008 +++ libevent-1.4.1-beta-win32/WIN32-Prj/libevent.dsp Fri Jan 11 08:43:39 2008 @@ -41,7 +41,7 @@ # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "..\\" /I "..\WIN32-Code" /I "..\compat" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\WIN32-Code" /I "..\\" /I "..\compat" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "HAVE_CONFIG_H" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -64,7 +64,7 @@ # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\\" /I "..\WIN32-Code" /I "..\compat" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\WIN32-Code" /I "..\\" /I "..\compat" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "HAVE_CONFIG_H" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -85,7 +85,11 @@ # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File -SOURCE=..\log.c +SOURCE=..\buffer.c +# End Source File +# Begin Source File + +SOURCE=..\evbuffer.c # End Source File # Begin Source File @@ -93,10 +97,38 @@ # End Source File # Begin Source File +SOURCE=..\event_tagging.c +# End Source File +# Begin Source File + +SOURCE=..\evrpc.c +# End Source File +# Begin Source File + +SOURCE=..\evutil.c +# End Source File +# Begin Source File + +SOURCE=..\log.c +# End Source File +# Begin Source File + SOURCE="..\WIN32-Code\misc.c" # End Source File # Begin Source File +SOURCE=..\select.c +# End Source File +# Begin Source File + +SOURCE=..\signal.c +# End Source File +# Begin Source File + +SOURCE=..\strlcpy.c +# End Source File +# Begin Source File + SOURCE="..\WIN32-Code\win32.c" # End Source File # End Group @@ -117,11 +149,59 @@ # End Source File # Begin Source File +SOURCE=..\evdns.h +# End Source File +# Begin Source File + +SOURCE="..\event-config.h" +# End Source File +# Begin Source File + +SOURCE="..\event-internal.h" +# End Source File +# Begin Source File + SOURCE=..\event.h # End Source File # Begin Source File +SOURCE=..\evhttp.h +# End Source File +# Begin Source File + +SOURCE="..\evrpc-internal.h" +# End Source File +# Begin Source File + +SOURCE=..\evrpc.h +# End Source File +# Begin Source File + +SOURCE=..\evsignal.h +# End Source File +# Begin Source File + +SOURCE=..\evutil.h +# End Source File +# Begin Source File + +SOURCE="..\http-internal.h" +# End Source File +# Begin Source File + +SOURCE=..\log.h +# End Source File +# Begin Source File + +SOURCE=..\min_heap.h +# End Source File +# Begin Source File + SOURCE="..\WIN32-Code\misc.h" +# End Source File +# Begin Source File + +SOURCE="..\strlcpy-internal.h" # End Source File # End Group # End Target Binary files libevent-1.4.1-beta/WIN32-Prj/libevent.ncb and libevent-1.4.1-beta-win32/WIN32-Prj/libevent.ncb differ Binary files libevent-1.4.1-beta/WIN32-Prj/libevent.opt and libevent-1.4.1-beta-win32/WIN32-Prj/libevent.opt differ Binary files libevent-1.4.1-beta/WIN32-Prj/signal_test/Debug/signal-test.obj and libevent-1.4.1-beta-win32/WIN32-Prj/signal_test/Debug/signal-test.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/signal_test/Debug/signal_test.exe and libevent-1.4.1-beta-win32/WIN32-Prj/signal_test/Debug/signal_test.exe differ Binary files libevent-1.4.1-beta/WIN32-Prj/signal_test/Debug/signal_test.ilk and libevent-1.4.1-beta-win32/WIN32-Prj/signal_test/Debug/signal_test.ilk differ Binary files libevent-1.4.1-beta/WIN32-Prj/signal_test/Debug/signal_test.pch and libevent-1.4.1-beta-win32/WIN32-Prj/signal_test/Debug/signal_test.pch differ Binary files libevent-1.4.1-beta/WIN32-Prj/signal_test/Debug/signal_test.pdb and libevent-1.4.1-beta-win32/WIN32-Prj/signal_test/Debug/signal_test.pdb differ Binary files libevent-1.4.1-beta/WIN32-Prj/signal_test/Debug/vc60.idb and libevent-1.4.1-beta-win32/WIN32-Prj/signal_test/Debug/vc60.idb differ Binary files libevent-1.4.1-beta/WIN32-Prj/signal_test/Debug/vc60.pdb and libevent-1.4.1-beta-win32/WIN32-Prj/signal_test/Debug/vc60.pdb differ diff -uNr libevent-1.4.1-beta/WIN32-Prj/signal_test/signal_test.dsp libevent-1.4.1-beta-win32/WIN32-Prj/signal_test/signal_test.dsp --- libevent-1.4.1-beta/WIN32-Prj/signal_test/signal_test.dsp Fri Jan 11 16:38:36 2008 +++ libevent-1.4.1-beta-win32/WIN32-Prj/signal_test/signal_test.dsp Fri Jan 11 08:35:19 2008 @@ -39,17 +39,18 @@ # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\..\WIN32-Code" /I "..\..\\" /I "..\..\compat" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "HAVE_CONFIG_H" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "signal_test - Win32 Debug" @@ -62,17 +63,18 @@ # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\WIN32-Code" /I "..\..\\" /I "..\..\compat" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "HAVE_CONFIG_H" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF Binary files libevent-1.4.1-beta/WIN32-Prj/time_test/Debug/time-test.obj and libevent-1.4.1-beta-win32/WIN32-Prj/time_test/Debug/time-test.obj differ Binary files libevent-1.4.1-beta/WIN32-Prj/time_test/Debug/time_test.exe and libevent-1.4.1-beta-win32/WIN32-Prj/time_test/Debug/time_test.exe differ Binary files libevent-1.4.1-beta/WIN32-Prj/time_test/Debug/time_test.ilk and libevent-1.4.1-beta-win32/WIN32-Prj/time_test/Debug/time_test.ilk differ Binary files libevent-1.4.1-beta/WIN32-Prj/time_test/Debug/time_test.pch and libevent-1.4.1-beta-win32/WIN32-Prj/time_test/Debug/time_test.pch differ Binary files libevent-1.4.1-beta/WIN32-Prj/time_test/Debug/time_test.pdb and libevent-1.4.1-beta-win32/WIN32-Prj/time_test/Debug/time_test.pdb differ Binary files libevent-1.4.1-beta/WIN32-Prj/time_test/Debug/vc60.idb and libevent-1.4.1-beta-win32/WIN32-Prj/time_test/Debug/vc60.idb differ Binary files libevent-1.4.1-beta/WIN32-Prj/time_test/Debug/vc60.pdb and libevent-1.4.1-beta-win32/WIN32-Prj/time_test/Debug/vc60.pdb differ diff -uNr libevent-1.4.1-beta/WIN32-Prj/time_test/time_test.dsp libevent-1.4.1-beta-win32/WIN32-Prj/time_test/time_test.dsp --- libevent-1.4.1-beta/WIN32-Prj/time_test/time_test.dsp Fri Jan 11 16:38:34 2008 +++ libevent-1.4.1-beta-win32/WIN32-Prj/time_test/time_test.dsp Fri Jan 11 16:37:12 2008 @@ -39,17 +39,18 @@ # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\..\WIN32-Code" /I "..\..\\" /I "..\..\compat" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "HAVE_CONFIG_H" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "time_test - Win32 Debug" @@ -62,17 +63,18 @@ # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\\" /I "..\..\WIN32-Code" /I "..\..\compat" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF diff -uNr libevent-1.4.1-beta/buffer.c libevent-1.4.1-beta-win32/buffer.c --- libevent-1.4.1-beta/buffer.c Mon Nov 12 05:37:32 2007 +++ libevent-1.4.1-beta-win32/buffer.c Fri Jan 11 08:37:34 2008 @@ -154,8 +154,8 @@ #endif va_copy(aq, ap); -#ifdef WIN32 - sz = vsnprintf(buffer, space - 1, fmt, aq); +#ifdef _WIN32 + sz = _vsnprintf(buffer, space - 1, fmt, aq); buffer[space - 1] = '\0'; #else sz = vsnprintf(buffer, space, fmt, aq); diff -uNr libevent-1.4.1-beta/devpoll.c libevent-1.4.1-beta-win32/devpoll.c --- libevent-1.4.1-beta/devpoll.c Fri Dec 14 22:08:14 2007 +++ libevent-1.4.1-beta-win32/devpoll.c Fri Jan 11 08:43:39 2008 @@ -32,8 +32,8 @@ #include #ifdef HAVE_SYS_TIME_H #include -#else -#include +//#else +//#include #endif #include #include diff -uNr libevent-1.4.1-beta/epoll.c libevent-1.4.1-beta-win32/epoll.c --- libevent-1.4.1-beta/epoll.c Fri Dec 14 22:08:14 2007 +++ libevent-1.4.1-beta-win32/epoll.c Fri Jan 11 08:43:39 2008 @@ -33,8 +33,8 @@ #include #ifdef HAVE_SYS_TIME_H #include -#else -#include +//#else +//#include #endif #include #include diff -uNr libevent-1.4.1-beta/evdns.c libevent-1.4.1-beta-win32/evdns.c --- libevent-1.4.1-beta/evdns.c Sat Dec 22 06:03:54 2007 +++ libevent-1.4.1-beta-win32/evdns.c Fri Jan 11 08:39:23 2008 @@ -106,10 +106,10 @@ #include "evdns.h" #include "evutil.h" #include "log.h" -#ifdef WIN32 +#ifdef _WIN32 #include #include -#include +//#include #include #else #include diff -uNr libevent-1.4.1-beta/event-config.h libevent-1.4.1-beta-win32/event-config.h --- libevent-1.4.1-beta/event-config.h Sun Dec 23 01:05:46 2007 +++ libevent-1.4.1-beta-win32/event-config.h Fri Jan 11 08:36:11 2008 @@ -105,7 +105,7 @@ #define _EVENT_HAVE_STDARG_H 1 /* Define to 1 if you have the header file. */ -#define _EVENT_HAVE_STDINT_H 1 +//#define _EVENT_HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define _EVENT_HAVE_STDLIB_H 1 @@ -156,7 +156,7 @@ #define _EVENT_HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ -#define _EVENT_HAVE_SYS_TIME_H 1 +//#define _EVENT_HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define _EVENT_HAVE_SYS_TYPES_H 1 diff -uNr libevent-1.4.1-beta/event-internal.h libevent-1.4.1-beta-win32/event-internal.h --- libevent-1.4.1-beta/event-internal.h Fri Dec 14 22:08:14 2007 +++ libevent-1.4.1-beta-win32/event-internal.h Fri Jan 11 16:19:30 2008 @@ -34,6 +34,37 @@ #include "config.h" #include "min_heap.h" #include "evsignal.h" + +#ifdef _WIN32 +#ifndef NFDBITS +typedef long int fd_mask; +#define NFDBITS (8 * sizeof(fd_mask)) +#endif +#endif + +#ifndef timeradd +# define timeradd(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ + if ((result)->tv_usec >= 1000000) \ + { \ + ++(result)->tv_sec; \ + (result)->tv_usec -= 1000000; \ + } \ + } while (0) +#endif +#ifndef timersub +# define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) +#endif struct eventop { const char *name; diff -uNr libevent-1.4.1-beta/event.c libevent-1.4.1-beta-win32/event.c --- libevent-1.4.1-beta/event.c Wed Dec 19 07:50:46 2007 +++ libevent-1.4.1-beta-win32/event.c Fri Jan 11 08:43:39 2008 @@ -37,8 +37,8 @@ #include #ifdef HAVE_SYS_TIME_H #include -#else -#include +//#else +//#include #endif #include #include diff -uNr libevent-1.4.1-beta/event.h libevent-1.4.1-beta-win32/event.h --- libevent-1.4.1-beta/event.h Wed Dec 19 07:50:46 2007 +++ libevent-1.4.1-beta-win32/event.h Fri Jan 11 16:19:22 2008 @@ -174,12 +174,19 @@ /* For int types. */ #include -#ifdef WIN32 -#define WIN32_LEAN_AND_MEAN +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #include #undef WIN32_LEAN_AND_MEAN typedef unsigned char u_char; typedef unsigned short u_short; +#endif + +#ifdef _MSC_VER +#ifdef _DEBUG +#define USE_DEBUG +#endif #endif #define EVLIST_TIMEOUT 0x01 diff -uNr libevent-1.4.1-beta/kqueue.c libevent-1.4.1-beta-win32/kqueue.c --- libevent-1.4.1-beta/kqueue.c Fri Dec 14 22:08:14 2007 +++ libevent-1.4.1-beta-win32/kqueue.c Fri Jan 11 08:43:39 2008 @@ -33,8 +33,8 @@ #include #ifdef HAVE_SYS_TIME_H #include -#else -#include +//#else +//#include #endif #include #include diff -uNr libevent-1.4.1-beta/log.c libevent-1.4.1-beta-win32/log.c --- libevent-1.4.1-beta/log.c Mon Nov 12 05:37:32 2007 +++ libevent-1.4.1-beta-win32/log.c Fri Jan 11 08:43:39 2008 @@ -50,8 +50,8 @@ #include #ifdef HAVE_SYS_TIME_H #include -#else -#include +//#else +//#include #endif #include #include diff -uNr libevent-1.4.1-beta/poll.c libevent-1.4.1-beta-win32/poll.c --- libevent-1.4.1-beta/poll.c Tue Dec 18 20:18:40 2007 +++ libevent-1.4.1-beta-win32/poll.c Fri Jan 11 08:43:39 2008 @@ -33,8 +33,8 @@ #include #ifdef HAVE_SYS_TIME_H #include -#else -#include +//#else +//#include #endif #include #include diff -uNr libevent-1.4.1-beta/sample/event-test.c libevent-1.4.1-beta-win32/sample/event-test.c --- libevent-1.4.1-beta/sample/event-test.c Tue Dec 18 20:18:40 2007 +++ libevent-1.4.1-beta-win32/sample/event-test.c Fri Jan 11 15:58:05 2008 @@ -9,11 +9,12 @@ #include #include -#ifndef WIN32 +#ifndef _WIN32 #include #include #include -#else +#else +#include #include #endif #include diff -uNr libevent-1.4.1-beta/sample/signal-test.c libevent-1.4.1-beta-win32/sample/signal-test.c --- libevent-1.4.1-beta/sample/signal-test.c Tue Dec 18 20:18:40 2007 +++ libevent-1.4.1-beta-win32/sample/signal-test.c Fri Jan 11 16:22:52 2008 @@ -14,7 +14,8 @@ #include #include #include #else +#include #include #endif #include diff -uNr libevent-1.4.1-beta/sample/time-test.c libevent-1.4.1-beta-win32/sample/time-test.c --- libevent-1.4.1-beta/sample/time-test.c Tue Dec 18 20:18:40 2007 +++ libevent-1.4.1-beta-win32/sample/time-test.c Fri Jan 11 16:33:26 2008 @@ -36,7 +36,7 @@ struct event *timeout = arg; int newtime = time(NULL); - printf("%s: called at %d: %d\n", __func__, newtime, + printf("%s: called at %d: %d\n", "timeout_cb", newtime, newtime - lasttime); lasttime = newtime; diff -uNr libevent-1.4.1-beta/select.c libevent-1.4.1-beta-win32/select.c --- libevent-1.4.1-beta/select.c Tue Dec 18 20:18:40 2007 +++ libevent-1.4.1-beta-win32/select.c Fri Jan 11 08:43:05 2008 @@ -33,8 +33,8 @@ #include #ifdef HAVE_SYS_TIME_H #include -#else -#include +//#else +//#include #endif #ifdef HAVE_SYS_SELECT_H #include @@ -43,8 +43,10 @@ #include #include #include #include -#include +#ifndef _WIN32 +#include +#endif #include #ifdef CHECK_INVARIANTS #include From jsobel at facebook.com Tue Jan 15 13:03:50 2008 From: jsobel at facebook.com (Jason Sobel) Date: Tue Jan 15 13:03:12 2008 Subject: [Libevent-users] RE: evhttp and threads In-Reply-To: <61A8D9E3C1BEC44C83743EDB587A00590221D8B01C@sf2pmxb01.thefacebook.com> Message-ID: Just a follow up- Lots of you got in touch with me and I appreciate your thoughts. After I sent out the email I made a few minor rewrites to evhttp to support multiple threads and have successfully been using this new code to run a photo caching server against production traffic for a few days now. I also got an email from Brian O'Kelley and Ilya Martynov describing similar work they had done. I ended up borrowing one of their ideas to improve my implementation, so hopefully they'll get their code in to svn sometime soon! In the meantime, if anyone is interested in the diffs I have, feel free to get in touch with me. No guarantees on correctness or performance but, from my perspective, so far, so good. --jason -----Original Message----- From: Jason Sobel Sent: Friday, January 04, 2008 11:28 AM To: libevent-users@monkey.org Subject: evhttp and threads Hi everyone- A little background: my name is Jason Sobel, I'm an infrastructure engineer at Facebook and I'm looking at using evhttp as the backbone for Facebook's custom HTTP servers. I am currently working on two specific projects and we'll almost certainly end up writing more down the road so this server is something that will see a lot of use. I know libevent & threaded applications has been discussed before, with the prevailing wisdom provided by fellow Facebook engineer Steven Grimm: http://monkeymail.org/archives/libevent-users/2007-January/000450.html I've been reading over the evhttp code recently (1.4.1-beta) and, from what I can see, the approach Steve describes will not work for evhttp. The problem appears to be that, once a connection is created, the event base cannot be changed. Thus all connection are trapped on the same event base and you can't hand them off to other threads to complete. The only workaround I've found is to hand out some work to a thread, have it put completed requests on a thread-safe queue, and rely on an evtimer to periodically complete all the requests on that queue. Can anyone out there confirm that I'm understanding the code correctly? I've been toying with an idea for changing the code to more readily support multiple threads, however, and was hoping to get some feedback. The basic idea is to change accept_socket: static void accept_socket(int fd, short what, void *arg) { struct evhttp *http = arg; struct sockaddr_storage ss; socklen_t addrlen = sizeof(ss); int nfd; if ((nfd = accept(fd, (struct sockaddr *)&ss, &addrlen)) == -1) { event_warn("%s: bad accept", __func__); return; } if (evutil_make_socket_nonblocking(nfd) < 0) return; evhttp_get_request(http, nfd, (struct sockaddr *)&ss, addrlen); } Instead of accepting a single evhttp instance my idea is to pass in a variable number of evhttp structures, each with a different event base. When calling evhttp_get_request I would somehow (randomly, round-robin, user-defined, etc.) choose a evhttp to pass on. I *think* that this change will correctly trickle down throughout the rest of the code and allow multiple connections to run in parallel on different event bases. Thanks for taking the time to look over this, I hope to get feedback/comments! ???????????????? --jason From cia at mud.ro Wed Jan 16 22:34:19 2008 From: cia at mud.ro (adrian ilarion ciobanu) Date: Thu Jan 17 03:25:00 2008 Subject: [Libevent-users] dns mx patch Message-ID: <20080117033419.GC67993@bdx-ev1.pipe2.net> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://monkeymail.org/archives/libevent-users/attachments/20080116/932131af/attachment.bin From ron.arts at neonova.nl Mon Jan 21 19:06:30 2008 From: ron.arts at neonova.nl (Ron Arts) Date: Mon Jan 21 19:06:40 2008 Subject: [Libevent-users] SIGPIPE in multithreaded program Message-ID: <47953386.9040300@neonova.nl> Hi, I am using libevent in a multithreaded program, the main thread containing the libevent loop, and other threads doing disk I/O. From mail from this list, and the changelogs I was under the impression that libevent handles signals better in a multithreaded environment since 1.3, but now I think I was wrong. Is it necessary to specifically ignore signals in every thread I create? Thanks, Ron -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3295 bytes Desc: S/MIME Cryptographic Signature Url : http://monkeymail.org/archives/libevent-users/attachments/20080122/0d6931ea/smime-0001.bin From ron.arts at neonova.nl Mon Jan 21 19:09:11 2008 From: ron.arts at neonova.nl (Ron Arts) Date: Mon Jan 21 19:09:16 2008 Subject: [Libevent-users] SSL enabling libevent programs, is there an example available? Message-ID: <47953427.2040003@neonova.nl> Hi, subject says it all. If there's no example with libevent, can someone recommend another place to look? I tried Googling but couldn't find a concise example. Thanks, Ron -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3295 bytes Desc: S/MIME Cryptographic Signature Url : http://monkeymail.org/archives/libevent-users/attachments/20080122/d5195889/smime.bin From tani at tanihosokawa.org Mon Jan 21 19:14:08 2008 From: tani at tanihosokawa.org (Tani Hosokawa) Date: Mon Jan 21 19:14:06 2008 Subject: [Libevent-users] thread-safety (and performance) Message-ID: <47953550.50901@tanihosokawa.org> When initiating HTTP requests in a multi-threaded process, under any significant load you will start finding horrible memory corruption problems, sometimes resulting in bad requests and sometimes resulting in core dumps. Also, under any significant load, you'll probably find that you are dropping a large number of connections due to the listen queue overflowing while your code is performing some other task. This is a patch that I think largely deals with these. Also, http_hostportfile() is not thread-safe, so I've attached a thread-safe version that can be used in its place (unfortunately I can't think of any clean way to make the current interface thread-safe without introducing a memory leak). /* TH: remember to free() opaque after you're done with this */ int http_hostportfile_r(const char *url, char **phost, u_short *pport, char **pfile,void **opaque) { struct http_hostportfile_threadsafe_opaque { char shost[1024]; char sfile[1024]; } *opaquedata; opaquedata = malloc(sizeof(*opaquedata)); *opaque = opaquedata; char *p, *p2; int len; u_short port; len = strlen(HTTP_PREFIX); if (strncasecmp(url, HTTP_PREFIX, len)) return (-1); url += len; /* We might overrun */ if (strlcpy(opaquedata->shost, url, sizeof(opaquedata->shost)) >= sizeof(opaquedata->shost)) return (-1); p = strchr(opaquedata->shost, '/'); if (p != NULL) { *p = '\0'; p2 = p + 1; } else p2 = NULL; if (pfile != NULL) { /* Generate request file */ if (p2 == NULL) p2 = ""; snprintf(opaquedata->sfile, sizeof(opaquedata->sfile), "/%s", p2); } p = strchr(opaquedata->shost, ':'); if (p != NULL) { *p = '\0'; port = atoi(p + 1); if (port == 0) return (-1); } else port = HTTP_DEFAULTPORT; if (phost != NULL) *phost = opaquedata->shost; if (pport != NULL) *pport = port; if (pfile != NULL) *pfile = opaquedata->sfile; return (0); } Index: http.c =================================================================== --- http.c (revision 1) +++ http.c (working copy) @@ -308,7 +308,7 @@ evhttp_make_header_request(struct evhttp_connection *evcon, struct evhttp_request *req) { - static char line[1024]; + char line[1024]; const char *method; evhttp_remove_header(req->output_headers, "Accept-Encoding"); @@ -378,9 +378,9 @@ evhttp_maybe_add_content_length_header(struct evkeyvalq *headers, long content_length) { + char len[12]; /* XXX: not thread-safe */ if (evhttp_find_header(headers, "Transfer-Encoding") == NULL && evhttp_find_header(headers, "Content-Length") == NULL) { - static char len[12]; /* XXX: not thread-safe */ snprintf(len, sizeof(len), "%ld", content_length); evhttp_add_header(headers, "Content-Length", len); } @@ -394,7 +394,7 @@ evhttp_make_header_response(struct evhttp_connection *evcon, struct evhttp_request *req) { - static char line[1024]; + char line[1024]; snprintf(line, sizeof(line), "HTTP/%d.%d %d %s\r\n", req->major, req->minor, req->response_code, req->response_code_line); @@ -433,7 +433,7 @@ void evhttp_make_header(struct evhttp_connection *evcon, struct evhttp_request *req) { - static char line[1024]; + char line[1024]; struct evkeyval *header; /* @@ -1999,7 +1999,7 @@ if ((fd = bind_socket(address, port)) == -1) return (-1); - if (listen(fd, 10) == -1) { + if (listen(fd, 8192) == -1) { event_warn("%s: listen", __func__); EVUTIL_CLOSESOCKET(fd); return (-1); From william at 25thandClement.com Mon Jan 21 19:28:56 2008 From: william at 25thandClement.com (William Ahern) Date: Mon Jan 21 19:29:02 2008 Subject: [Libevent-users] thread-safety (and performance) In-Reply-To: <47953550.50901@tanihosokawa.org> References: <47953550.50901@tanihosokawa.org> Message-ID: <20080122002856.GA2702@wilbur.25thandClement.com> On Mon, Jan 21, 2008 at 04:14:08PM -0800, Tani Hosokawa wrote: > @@ -1999,7 +1999,7 @@ > if ((fd = bind_socket(address, port)) == -1) > return (-1); > > - if (listen(fd, 10) == -1) { > + if (listen(fd, 8192) == -1) { > event_warn("%s: listen", __func__); > EVUTIL_CLOSESOCKET(fd); > return (-1); Probably better to use SOMAXCONN instead of an arbitrary number. From harningt at gmail.com Mon Jan 21 19:34:25 2008 From: harningt at gmail.com (Thomas Harning) Date: Mon Jan 21 19:37:18 2008 Subject: [Libevent-users] SSL enabling libevent programs, is there an example available? In-Reply-To: <47953427.2040003@neonova.nl> References: <47953427.2040003@neonova.nl> Message-ID: <47953A11.4080003@gmail.com> Ron Arts wrote: > Hi, > > subject says it all. If there's no example with > libevent, can someone recommend another place to look? > I tried Googling but couldn't find a concise example. For example, w/ OpenSSL you can turn the socket to be non-blocking and watch for what openssl 'needs' after a failed attempt to read/write... Ex: int ret = SSL_read(ssl, buffer, len); if(ret < 0) { int err = SSL_get_error(ret); switch(err) { case SSL_ERROR_WANT_WRITE: /* Hook up libevent to wait on write then retry w/ exact same argument */ break; case SSL_ERROR_WANT_READ: /* Hook up libevent to wait on read then ... */ break; default: /* Something else..... */ } } From william at 25thandClement.com Mon Jan 21 19:56:22 2008 From: william at 25thandClement.com (William Ahern) Date: Mon Jan 21 19:58:20 2008 Subject: [Libevent-users] SIGPIPE in multithreaded program In-Reply-To: <47953386.9040300@neonova.nl> References: <47953386.9040300@neonova.nl> Message-ID: <20080122005622.GA26930@wilbur.25thandClement.com> On Tue, Jan 22, 2008 at 01:06:30AM +0100, Ron Arts wrote: > Hi, > > I am using libevent in a multithreaded program, the main > thread containing the libevent loop, and other threads > doing disk I/O. From mail from this list, and the changelogs > I was under the impression that libevent handles signals > better in a multithreaded environment since 1.3, but now > I think I was wrong. > > Is it necessary to specifically ignore signals in every > thread I create? In Unix it's necessary to change the default behavior of SIGPIPE if you don't want your process killed. libevent, AFAIK, won't do this for you. If won't independently setup handlers for all the different signals. Most daemon applications ignore SIGPIPE as part of their initialization. The default behavior caters to simple shell applications that can't be bothered to check the return value of a write. #include struct sigaction sa; sa = sa_initializer; sa.sa_handler = SIG_IGN; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); if (0 != sigaction(SIGPIPE, &sa, 0)) err(EXIT_FAILURE, "sigaction"); From william at 25thandClement.com Mon Jan 21 20:02:19 2008 From: william at 25thandClement.com (William Ahern) Date: Mon Jan 21 20:02:21 2008 Subject: [Libevent-users] SSL enabling libevent programs, is there an example available? In-Reply-To: <47953427.2040003@neonova.nl> References: <47953427.2040003@neonova.nl> Message-ID: <20080122010219.GB26930@wilbur.25thandClement.com> On Tue, Jan 22, 2008 at 01:09:11AM +0100, Ron Arts wrote: > Hi, > > subject says it all. If there's no example with > libevent, can someone recommend another place to look? > I tried Googling but couldn't find a concise example. > http://25thandclement.com/~william/projects/libevnet.html Download the tarball. OpenSSL bindings are in src/tls.c. There's lots more code in the library for integrating with libevent, but I wrote tls.c many years ago (before libevnet, and possibly before libevent), and it should be easy to rip it out and use however you want. At the very least, tls_read_try(), tls_write_try() and tls_accept_try() should help you out. From ron.arts at neonova.nl Tue Jan 22 02:51:55 2008 From: ron.arts at neonova.nl (Ron Arts) Date: Tue Jan 22 02:52:09 2008 Subject: [Libevent-users] SIGPIPE in multithreaded program In-Reply-To: <20080122005622.GA26930@wilbur.25thandClement.com> References: <47953386.9040300@neonova.nl> <20080122005622.GA26930@wilbur.25thandClement.com> Message-ID: <4795A09B.7030501@neonova.nl> William Ahern wrote: > On Tue, Jan 22, 2008 at 01:06:30AM +0100, Ron Arts wrote: >> Hi, >> >> I am using libevent in a multithreaded program, the main >> thread containing the libevent loop, and other threads >> doing disk I/O. From mail from this list, and the changelogs >> I was under the impression that libevent handles signals >> better in a multithreaded environment since 1.3, but now >> I think I was wrong. >> >> Is it necessary to specifically ignore signals in every >> thread I create? > > In Unix it's necessary to change the default behavior of SIGPIPE if you > don't want your process killed. libevent, AFAIK, won't do this for you. If > won't independently setup handlers for all the different signals. Most > daemon applications ignore SIGPIPE as part of their initialization. The > default behavior caters to simple shell applications that can't be bothered > to check the return value of a write. > > #include > > struct sigaction sa; > > sa = sa_initializer; > sa.sa_handler = SIG_IGN; > sa.sa_flags = 0; > > sigemptyset(&sa.sa_mask); > > if (0 != sigaction(SIGPIPE, &sa, 0)) > err(EXIT_FAILURE, "sigaction"); Oops, I'm sorry, I did not make myself clear, while writing the email I edited it a lot, and forgot to mention that indeed I ignore SIGPIPE in my initialisation code: struct event evsigpipe; event_init(); event_set(&evsigpipe, SIGPIPE, EV_SIGNAL|EV_PERSIST, signal_cb, &evsigpipe); event_add(&evsigpipe, NULL); event_dispatch(); void signal_cb(int fd, short event, void *arg) { struct event *signal = arg; extern int reload_database; switch(EVENT_SIGNAL(signal)) { case SIGTERM: // sigterm fprintf(stderr, "Killed"); exit(1); break; case SIGHUP: // sighup fprintf(stderr, "Got SIGHUP"); reload_config = TRUE; break; case SIGUSR1: // reload entire database fprintf(stderr, "Got SIGUSR1"); reload_database = TRUE; break; default: fprintf(stderr, "%s: got signal %d", __func__, EVENT_SIGNAL(signal)); break; } } But my program is still being killed with SIGPIPE occasionally. I am using threads, and I presume sometimes one of the other threads receives the SIGPIPE signal instead of the main thread, and I *think* that in such a case my program exits. But what I meant to ask was: isn't libevent supposed (since 1.3) to handle multithreading and ensure that only one thread receives the signal? Or should I specifically add code at the beginning of each thread to ignore SIGPIPE? Thanks, Ron > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkeymail.org/mailman/listinfo/libevent-users -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3295 bytes Desc: S/MIME Cryptographic Signature Url : http://monkeymail.org/archives/libevent-users/attachments/20080122/ae41efba/smime-0001.bin From william at 25thandClement.com Tue Jan 22 03:52:51 2008 From: william at 25thandClement.com (William Ahern) Date: Tue Jan 22 03:52:55 2008 Subject: [Libevent-users] SIGPIPE in multithreaded program In-Reply-To: <4795A09B.7030501@neonova.nl> References: <47953386.9040300@neonova.nl> <20080122005622.GA26930@wilbur.25thandClement.com> <4795A09B.7030501@neonova.nl> Message-ID: <20080122085251.GB1020@wilbur.25thandClement.com> On Tue, Jan 22, 2008 at 08:51:55AM +0100, Ron Arts wrote: > Oops, I'm sorry, I did not make myself clear, while writing the > email I edited it a lot, and forgot to mention that indeed I > ignore SIGPIPE in my initialisation code: > > > But my program is still being killed with SIGPIPE occasionally. > I am using threads, and I presume sometimes one of the other threads > receives the SIGPIPE signal instead of the main thread, and I > *think* that in such a case my program exits. > > But what I meant to ask was: isn't libevent supposed (since 1.3) to handle > multithreading and ensure that only one thread receives the signal? Neither libevent nor anything else can specify that any particular thread receive a signal. All that can be done is to block a signal in all threads except for one, which gives the same effect in a round-about manner. Since libevent doesn't create the threads, it can't block them like this. And, in any event, it would be evil for libevent to fiddle with signals this way behind a process' back. I wouldn't want libevent to preemptively block all signals from event_init(). > Or should I specifically add code at the beginning of each thread > to ignore SIGPIPE? Signal handlers and masks are inherited across fork() and pthread_create(). And masks are inherited across exec(), too, I think. You could add code to each thread to do this. Of course, there are race conditions. Imagine if a signal is raised after a thread starts but before it can block the signal. This is especially troublesome if you dynamically create threads. With SIGPIPE the answer is simple, though. Block the signal from the main thread before creating any other threads. All threads will inherit the block, and SIGPIPE can never squeeze through. But, by block I mean actually using sigaction(2) (see the code I posted earlier), not by installing a libevent handler. Installing a SIGPIPE handler through libevent is pointless and a waste of CPU, and of course it doesn't do what you want anyway. Signals are probably the most complex and difficult to understand concept in Unix, and understanding how to safely use them is even more difficult. I suggest you find a copy of Richard Stevens' Advanced Programming in the UNIX Environment. If Knuth and Stevens have (had) one thing in common, it's that no engineer would ever question why you one of their books sat on your book shelf. From ron.arts at neonova.nl Tue Jan 22 04:04:24 2008 From: ron.arts at neonova.nl (Ron Arts) Date: Tue Jan 22 04:04:31 2008 Subject: [Libevent-users] SIGPIPE in multithreaded program In-Reply-To: <20080122085251.GB1020@wilbur.25thandClement.com> References: <47953386.9040300@neonova.nl> <20080122005622.GA26930@wilbur.25thandClement.com> <4795A09B.7030501@neonova.nl> <20080122085251.GB1020@wilbur.25thandClement.com> Message-ID: <4795B198.4030801@neonova.nl> William Ahern schreef: > > Signal handlers and masks are inherited across fork() and pthread_create(). > And masks are inherited across exec(), too, I think. > Yes, of course, I should've thought of that myself. > You could add code to each thread to do this. Of course, there are race > conditions. Imagine if a signal is raised after a thread starts but before > it can block the signal. This is especially troublesome if you dynamically > create threads. > > With SIGPIPE the answer is simple, though. Block the signal from the main > thread before creating any other threads. All threads will inherit the > block, and SIGPIPE can never squeeze through. > > But, by block I mean actually using sigaction(2) (see the code I posted > earlier), not by installing a libevent handler. Installing a SIGPIPE handler > through libevent is pointless and a waste of CPU, and of course it doesn't > do what you want anyway. > Why is it pointless? I indeed noticed it doesn't catch signals (I think my other signals do not get through as well), but libevent comes with an example program. > Signals are probably the most complex and difficult to understand concept in > Unix, and understanding how to safely use them is even more difficult. I > suggest you find a copy of Richard Stevens' Advanced Programming in the UNIX > Environment. > > If Knuth and Stevens have (had) one thing in common, it's that no engineer > would ever question why you one of their books sat on your book shelf. I know, and I used to own them both, but the former was hijacked by my oldest son, and the latter just magically disappeared from my bookshelf... Thanks, Ron > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkeymail.org/mailman/listinfo/libevent-users -- NeoNova BV, The Netherlands Professional internet and VoIP solutions http://www.neonova.nl Kruislaan 419 1098 VA Amsterdam info: 020-5628292 servicedesk: 020-5628292 fax: 020-5628291 KvK Amsterdam 34151241 The following disclaimer applies to this email: http://www.neonova.nl/maildisclaimer -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 3295 bytes Desc: S/MIME Cryptographic Signature Url : http://monkeymail.org/archives/libevent-users/attachments/20080122/822f13eb/smime.bin From hannah at schlund.de Tue Jan 22 08:08:40 2008 From: hannah at schlund.de (Hannah Schroeter) Date: Tue Jan 22 08:08:43 2008 Subject: [Libevent-users] SIGPIPE in multithreaded program In-Reply-To: <20080122085251.GB1020@wilbur.25thandClement.com> References: <47953386.9040300@neonova.nl> <20080122005622.GA26930@wilbur.25thandClement.com> <4795A09B.7030501@neonova.nl> <20080122085251.GB1020@wilbur.25thandClement.com> Message-ID: <20080122130839.GA3786@schlund.de> Hi! On Tue, Jan 22, 2008 at 12:52:51AM -0800, William Ahern wrote: >Signal handlers and masks are inherited across fork() and pthread_create(). >And masks are inherited across exec(), too, I think. >You could add code to each thread to do this. Of course, there are race >conditions. Imagine if a signal is raised after a thread starts but before >it can block the signal. This is especially troublesome if you dynamically >create threads. A way to avoid the race is to block all signals (using pthread_sigmask) in main() early and unblock them in *one* thread (which is in duty for signal handling) *only* later, after having created the other threads. If you create threads afterwards, block them again before pthread_create and unblock again afterwards, again. Then the other threads all inherit the signal mask blocking all signals so there's always only at maximum one thread which gets the signals. >With SIGPIPE the answer is simple, though. Block the signal from the main >thread before creating any other threads. All threads will inherit the >block, and SIGPIPE can never squeeze through. I think you mean *ignore* SIGPIPE. >But, by block I mean actually using sigaction(2) (see the code I posted >earlier), not by installing a libevent handler. Installing a SIGPIPE handler >through libevent is pointless and a waste of CPU, and of course it doesn't >do what you want anyway. sigaction doesn't *block* signals in Unix/POSIX terminology. It sets up signal *handling*, to either default handling, user handling or ignoring the signal. With libevent, you either ignore a signal using sigaction or you handle it using libevent and don't touch it yourself with sigaction (but you may block/unblock it using sigprocmask [in single threaded programs] or pthread_sigmask [in multithreaded programs]). Your recommendation of *ignoring* SIGPIPE still stands, and instead you handle EPIPE in write(2) (or send(2)). >[...] Kind regards, Hannah. From william at 25thandClement.com Tue Jan 22 08:23:59 2008 From: william at 25thandClement.com (William Ahern) Date: Tue Jan 22 08:24:06 2008 Subject: [Libevent-users] SIGPIPE in multithreaded program In-Reply-To: <20080122130839.GA3786@schlund.de> References: <47953386.9040300@neonova.nl> <20080122005622.GA26930@wilbur.25thandClement.com> <4795A09B.7030501@neonova.nl> <20080122085251.GB1020@wilbur.25thandClement.com> <20080122130839.GA3786@schlund.de> Message-ID: <20080122132359.GA26143@wilbur.25thandClement.com> On Tue, Jan 22, 2008 at 02:08:40PM +0100, Hannah Schroeter wrote: > >With SIGPIPE the answer is simple, though. Block the signal from the main > >thread before creating any other threads. All threads will inherit the > >block, and SIGPIPE can never squeeze through. > > I think you mean *ignore* SIGPIPE. > Right. It's late. (Or was late; now it's morning again.) At this point I've lost enough points that I ought to take a refresher course myself ;) From tani at tanihosokawa.org Tue Jan 22 12:45:43 2008 From: tani at tanihosokawa.org (Tani Hosokawa) Date: Tue Jan 22 12:46:45 2008 Subject: [Libevent-users] thread-safety (and performance) In-Reply-To: <20080122075207.32D3218E71@postal.monkey.org> References: <20080122075207.32D3218E71@postal.monkey.org> Message-ID: <47962BC7.90109@tanihosokawa.org> > On Mon, Jan 21, 2008 at 04:14:08PM -0800, Tani Hosokawa wrote: > >> > @@ -1999,7 +1999,7 @@ >> > if ((fd = bind_socket(address, port)) == -1) >> > return (-1); >> > >> > - if (listen(fd, 10) == -1) { >> > + if (listen(fd, 8192) == -1) { >> > event_warn("%s: listen", __func__); >> > EVUTIL_CLOSESOCKET(fd); >> > return (-1); > Probably better to use SOMAXCONN instead of an arbitrary number. On Linux, you can set somaxconn in proc (|/proc/sys/net/core/somaxconn) to much higher than the value in the header files (128). I could pull the sysctl value, but that isn't all that portable and in any case it's silently truncated to the system's real maximum if you specify something higher. As libevent is typically used for high performance products, it makes sense to me to set it above the system's actual maximum, and let the system limits drag it down. If anyone has some portable code for determining the real somaxconn across all systems, that'd probably be handy. | From cartermichael at gmail.com Wed Jan 23 10:15:32 2008 From: cartermichael at gmail.com (Michael Carter) Date: Wed Jan 23 10:15:56 2008 Subject: [Libevent-users] Libevent's http server for HTTP push? Message-ID: <3a05072b0801230715j5752bf36v2d5da7cb98e3c264@mail.gmail.com> Hello, Thanks for the great networking library. Its made my life countless time easier. I'm the lead developer of the Orbited project (www.orbited.org) which is a python server built using pyevent (libevent wrapper for python) that maintains many long-standing HTTP connections for the purpose of HTTP push (Also known as Comet, see: http://en.wikipedia.org/wiki/Comet_(programming). There is a fair amount of python code in Orbited devoted to implementing an HTTP server and proxy. For speed, memory usage, and maintainability, It would make a lot more sense to simply use the libevent http server/client, if its a good idea. In order to implement an HTTP push client in browsers though, all sorts of tricks are necessary. There are two hard requirements for the server: - Keep-alive support. HTTP push applications must have a keep-alive support to reduce latency in responding to the server - Incremental response - Orbited needs to be able to send some headers right away, then later send part of the body, then later send some more. For instance, one method of doing http push is to send "" every time some new data becomes available. The connection might be open for 5 hours with bits and pieces coming in every few minutes. I couldn't tell from the docs whether these two items are possible with the libevent http server. Thanks, Michael Carter -------------- next part -------------- An HTML attachment was scrubbed... URL: http://monkeymail.org/archives/libevent-users/attachments/20080123/66344524/attachment-0001.htm From jon at oberheide.org Wed Jan 23 10:26:24 2008 From: jon at oberheide.org (Jon Oberheide) Date: Wed Jan 23 10:26:31 2008 Subject: [Libevent-users] Libevent's http server for HTTP push? In-Reply-To: <3a05072b0801230715j5752bf36v2d5da7cb98e3c264@mail.gmail.com> References: <3a05072b0801230715j5752bf36v2d5da7cb98e3c264@mail.gmail.com> Message-ID: <1201101984.5680.4.camel@apollo> Take a look at multipart/x-mixed-replace for HTTP server push. Dug's msgbus (http://code.google.com/p/msgbus/) is an pub/sub implementation of multipart/x-mixed-replace that uses libevent/pyevent. The current state in SVN is not very buildable, but I can provide you with a working tree off-list if you're interested. Regards, Jon Oberheide On Wed, 2008-01-23 at 07:15 -0800, Michael Carter wrote: > Hello, > > Thanks for the great networking library. Its made my life countless > time easier. > > I'm the lead developer of the Orbited project (www.orbited.org) which > is a python server built using pyevent (libevent wrapper for python) > that maintains many long-standing HTTP connections for the purpose of > HTTP push (Also known as Comet, see: > http://en.wikipedia.org/wiki/Comet_(programming). There is a fair > amount of python code in Orbited devoted to implementing an HTTP > server and proxy. For speed, memory usage, and maintainability, It > would make a lot more sense to simply use the libevent http > server/client, if its a good idea. > > In order to implement an HTTP push client in browsers though, all > sorts of tricks are necessary. There are two hard requirements for the > server: > > - Keep-alive support. HTTP push applications must have a keep-alive > support to reduce latency in responding to the server > - Incremental response - Orbited needs to be able to send some headers > right away, then later send part of the body, then later send some > more. For instance, one method of doing http push is to send > "" every time some new data > becomes available. The connection might be open for 5 hours with bits > and pieces coming in every few minutes. > > I couldn't tell from the docs whether these two items are possible > with the libevent http server. > > Thanks, > > Michael Carter > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkeymail.org/mailman/listinfo/libevent-users -- Jon Oberheide GnuPG Key: 1024D/F47C17FE Fingerprint: B716 DA66 8173 6EDD 28F6 F184 5842 1C89 F47C 17FE From peter at cerebus.co.za Tue Jan 29 02:31:46 2008 From: peter at cerebus.co.za (Peter Hinz) Date: Tue Jan 29 02:35:08 2008 Subject: [Libevent-users] Where is struct evkeyvalq defined. In-Reply-To: <1201101984.5680.4.camel@apollo> References: <3a05072b0801230715j5752bf36v2d5da7cb98e3c264@mail.gmail.com> <1201101984.5680.4.camel@apollo> Message-ID: <003e01c86249$0082b5c0$01882140$@co.za> I'm looking for the definition of struct evkeyvalq; All I can find is the above line in evhttp.h. Where is the real definition. Peter From cia at mud.ro Tue Jan 29 04:12:34 2008 From: cia at mud.ro (adrian ilarion ciobanu) Date: Tue Jan 29 09:02:36 2008 Subject: [Libevent-users] Where is struct evkeyvalq defined. In-Reply-To: <003e01c86249$0082b5c0$01882140$@co.za> References: <3a05072b0801230715j5752bf36v2d5da7cb98e3c264@mail.gmail.com> <1201101984.5680.4.camel@apollo> <003e01c86249$0082b5c0$01882140$@co.za> Message-ID: <20080129091234.GA60323@bdx-ev1.pipe2.net> Skipped content of type multipart/mixed-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available Url : http://monkeymail.org/archives/libevent-users/attachments/20080129/842cacbd/attachment.bin From provos at citi.umich.edu Tue Jan 29 12:04:47 2008 From: provos at citi.umich.edu (Niels Provos) Date: Tue Jan 29 12:08:20 2008 Subject: [Libevent-users] Where is struct evkeyvalq defined. In-Reply-To: <003e01c86249$0082b5c0$01882140$@co.za> References: <3a05072b0801230715j5752bf36v2d5da7cb98e3c264@mail.gmail.com> <1201101984.5680.4.camel@apollo> <003e01c86249$0082b5c0$01882140$@co.za> Message-ID: <850f7cbe0801290904r2bef683jc349e7711c6f107f@mail.gmail.com> It's defined in event.h Niels On Jan 28, 2008 11:31 PM, Peter Hinz wrote: > I'm looking for the definition of > struct evkeyvalq; > > All I can find is the above line in evhttp.h. Where is the real definition. > > Peter > > > > _______________________________________________ > Libevent-users mailing list > Libevent-users@monkey.org > http://monkeymail.org/mailman/listinfo/libevent-users > >