Re: [Libevent-users] Guides for switching from select to libevent.
Does anyone know of any well-written guides for switching an application from select based socket handling to libevent? Not really a guide how to switch but a well written libevent guideline http://www.wangafu.net/~nickm/libevent-book/ ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] evhttp chunked response bug?
Shouldn't you call evhttp_send_reply_end in the callback of evhttp_send_reply_chunk which is only called if the sending succeeded? On 9/4/09, Haiping Zhao hz...@facebook.com wrote: Hi, there, I'm reading evhttp's source code, and I'm not sure if I've found a bug, or I just mis-read it. But it seems to me, when I do chunked encoding on response, I'd call three functions sequentially somehow, evhttp_send_reply_start(req, ...); evhttp_send_reply_chunk(req, ...); evhttp_send_reply_end(req, ...); Here's the problem, if any of the 1st two fails to send some packets, i.e., evbuffer_write() returned -1 or 0, it will call evhttp_connection_fail(), which will free the request eventually if connection needs to be closed by evhttp_connection_free(). Now, how does my subsequent call know req is freed? Wouldn't that cause crashes, if I simply call those 3 functions in a row? Or did I miss some correct way of calling them? Thanks. -Haiping ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] evhttp chunked response bug?
Hi, Hmm, that should help. I have several send_reply_chunk() though. Are you suggesting they should form nested callback chains? Afaik it's the only threadsafe way of ensuring to not call reads and writes on already closed descriptors. Although i know it's highly unportable i use gcc's nested functions [1] for such kind of callbacks; it's just extremly nice to read. As long as GCC's your compiler nested functions are great for callbacks. Just never reference data outside the function's scope :-) [1] http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] strange segfault in 2.0.2
Can you provide a minimal version of your programm which crashes on your laptop with these segfaults? ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] libevent cmake scripts
Would it be possible to create cmake scripts for 2.x, too since they will much likely be included into the release ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
[Libevent-users] How to schedule a plain event
Hi, how is it possible to schedule a callback in the next eventloop iteration? Of course i could add a timer event with timeout 0 but this seems like a lot of overhead. I just want a function to be called in the next event iteration (i can't call it directly in another libevent callback because the first callback is called inside the buffer_chain_free method and the method itself wants to write to the buffer). ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] How to schedule a plain event
Hi The easiest thing to do here is to use the event_active() call to make the event active now. But it doesn't do quite what you asked for: the callback will be run later in the current iteration of the loop, not in the next iteration. If it needs to be in the next iteration, I can't offhand think of a better way than adding an event with a 0 callback. no that's exactly what I need. I just have to return form the callback function because buffer_chain_free has to finish and after that the new function can be called. Thanks :-) ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
[Libevent-users] IOCP backend questions
Hi, I have some questions regarding the IOCP backend when used with bufferevents. How much locking is required in the callbacks? For example if I'm waiting for read events, will it be possible that one read event triggers a read callback and while this is running another read callback is triggered on the same socket because there is new data avaiable? Or is there any garantee that a read callback isn't called while it's still running? ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
[Libevent-users] Simple typo fix
Hi, svn.1296, buffer.h, line 500 should be @param n_vec the length of vec_out. If 0, we only count how many instead of @param n_vec the length of n_vec. If 0, we only count how many, shouldn't it? ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
[Libevent-users] Simple Echo server with libevent 2.0
Hi, can somebody guide me how to write a simple echo server using libevent 2.0? I've read into the sources of libevent (especially http.c) because i wanted to know how to bind to a socket, accept new connections and read/write async to the network. But there are so many interal functions (like bind_socket bind_socket_ai) which i have to copy (?) in order to bind to a socket that i think i got something wrong. Can somebody give me a hint? ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users
Re: [Libevent-users] Simple Echo server with libevent 2.0
Hi For one example of how to use the 2.0.1-alpha API, you could have a look at chapter 1 of http://www.wangafu.net/~nickm/libevent-book/ . Would it be possible to link that book on http://monkey.org/~provos/libevent/ ? I've long googled for such reference material but didn't find any That's still a pretty ungainly way to do a server, though. In 2.0.2-alpha, there will be a new evconnlistener API to wrap most of the busywork of listening for new connections. I've attacked a quick echo server written with it to this email. [It works for me on Linux; haven't tested it anywhere else.] Ah cool thanks! I'll try it out. I hope we can get Libevent 2.0.2-alpha released this week. Until then, you can use subversion to fetch the latest code from the repository at https://levent.svn.sourceforge.net/svnroot/levent/trunk/libevent One think I don't understand about buffer events (I haven't read the source yet): If i call struct evbuffer *input = bufferevent_get_input(bev); and then read the contents of input by calling bufferevent_read, is there a way to not remove the data from the input buffer? Perhaps I just want to look at it if it's enought to parse and if not wait for another call of my echo_read_cb? Or do I have to read the input buffer into another buffer to preserve it? If I have to read/write the buffers into each other, are the contents copied each time? ___ Libevent-users mailing list Libevent-users@monkey.org http://monkeymail.org/mailman/listinfo/libevent-users