Re: [Libevent-users] TCP client not calling writecb

2013-04-20 Thread Nir Soffer
On Apr 21, 2013, at 1:28 AM, Jan Danielsson wrote: > Hello, > > I have a server which waits for incoming connections, and I want the > client to connect to the server, and immediately send over a port > number. In the client's main() I do this: > > ---

Re: [Libevent-users] Evhttp client + conneciton pool

2013-03-30 Thread Nir Soffer
On Mar 29, 2013, at 6:32 PM, lesa Le wrote: > > I'm trying to write a program to retrieve data using evhttp_make_request(). > It needs to handle a significant amount of requests per second, to a decent > amount of servers. Somewhere in the neighbourhood of 100s of servers, issuing > several re

Re: [Libevent-users] Problem in receiving HTTP Post request

2013-02-06 Thread Nir Soffer
On Feb 6, 2013, at 10:50 PM, Alap Kumar Sinha wrote: > I am facing a problem where a HTTP request does not reach my HTTP server > (based on libevent). Following is the scenario. > > 1. 1. JavaScript Application -> Posts HTTP request to Browser > 2. 2. Browser sends the request to

Re: [Libevent-users] multithreading problem

2013-01-08 Thread Nir Soffer
> really profit from multithreading this way because all of the ssl > stuff is done in the main thread. > > 2013/1/8 Nir Soffer : > > > > On Jan 8, 2013, at 12:55 AM, Björn K. wrote: > > > > That piece of code should distribute the incoming connections over the > &

Re: [Libevent-users] multithreading problem

2013-01-08 Thread Nir Soffer
On Jan 8, 2013, at 12:55 AM, Björn K. wrote: > That piece of code should distribute the incoming connections over the > threads (I want to change that code later to select the thread with > the lowest number of handled connections). If I don't use this code > and use instead > bev = bufferevent_o

Re: [Libevent-users] Q: Exception callbacks and events that should run immediately

2012-12-05 Thread Nir Soffer
On Wed, Dec 5, 2012 at 10:54 AM, Sashan Govender wrote: > Hi! > > >> 1) I don't see any notion of event notification on FD exception - e.g. >> socket close. >> There are some words for buffer events, but nothing for regular file >> descriptor based callbacks. So what is a good way to get

Re: [Libevent-users] Beginners' question: multi-threaded HTTP service

2012-11-19 Thread Nir Soffer
On Nov 20, 2012, at 12:34 AM, Pander wrote: only this works: char buf[1024]; int n; while ((n = evbuffer_remove(req->buffer_in, buf, sizeof(buf))) > 0) { fwrite(buf, 1, n, stdout); } printf("\n"); Because in POST, browsers send the parameters in the request body. For example, this form

Re: [Libevent-users] Beginners' question: multi-threaded HTTP service

2012-11-19 Thread Nir Soffer
On Mon, Nov 19, 2012 at 7:26 PM, Pander wrote: > Second question is regarding buffer_in in request. I can't seem to find > a proper example with helpers to retrieve the POST parameters. If you want to support the default form encoding (application/x-www-form-urlencoded), you can use evhttp_parse

Re: [Libevent-users] Beginners' question: multi-threaded HTTP service

2012-11-19 Thread Nir Soffer
On Mon, Nov 19, 2012 at 12:43 PM, Pander wrote: > On 2012-11-16 15:19, Nick Mathewson wrote: > > > > > > > > On Fri, Nov 16, 2012 at 5:49 AM, Pander > > wrote: > > > > Hi all, > > > > I am new to libevent and am wondering what to choose for a > > m

Re: [Libevent-users] Problems with outbound HTTP posts

2012-10-31 Thread Nir Soffer
On Tue, Oct 30, 2012 at 3:53 PM, Ringel, Rick wrote: > > You don't need the while loop around event_base_dispatch - it is your > loop. > > I've used Boost for a few things, and in that library, I found the service > thread does return occasionally. It was defensive code, sort of my seat > belt.

Re: [Libevent-users] Problems with outbound HTTP posts

2012-10-24 Thread Nir Soffer
On Wed, Oct 24, 2012 at 6:09 PM, Ringel, Rick wrote: > Thanks for taking a look. > > ** ** > > | Did you initialize libevent threading? > > | > > | See http://www.wangafu.net/~nickm/libevent-book/Ref1_libsetup.html > Section "Locks and threading" > > ** ** > > I just reviewed tha

Re: [Libevent-users] Problems with outbound HTTP posts

2012-10-24 Thread Nir Soffer
On Tue, Oct 23, 2012 at 10:09 PM, Ringel, Rick wrote: > My code is pretty basic, but I am sure I am missing something. It smells > like a multi-thread issue – the initialization code runs in a different > thread than the app generating the outbound HTTP messages, and in a > different thread than

Re: [Libevent-users] epoll_wait-like timeout with libevent (tick generation)

2012-10-16 Thread Nir Soffer
On Oct 16, 2012, at 1:35 PM, Programmist Setevik wrote: Portability issues aside, is there a way to ask event_base_* functions to enforce epoll_wait()-like timeout ? I need to have an ability to generate "ticks" - say once every 100 msec or thereabouts and run some callbacks whenever ticks occ

Re: [Libevent-users] how to jude is the bufferevent has been free

2012-10-09 Thread Nir Soffer
On Oct 9, 2012, at 6:12 AM, rqslt wrote: I want know how to jude is the bufferevent has been free. In function A , i use bufferevent_free free the bufferevetn; In fuction B, how to jude is the bufferevent has been free ? Who can tell me what to do ? Thanks. Check if the pointer is N

Re: [Libevent-users] Equivalent of event_self_cbarg() in libevent-2.0?

2012-09-18 Thread Nir Soffer
On Sep 18, 2012, at 2:28 PM, Chirag Kantharia wrote: Hi, I had a signal handler which used libevent-1.4.x, and which looked like this: int main (void) { ... struct event sigev; memset(&sigev, 0, sizeof(sigev)); event_set(&sigev, SIGINT, EV_SIGNAL|EV_PERSIST, sig_handler, &sigev); ... ev

Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-09-03 Thread Nir Soffer
problem. However, if you get lot of write failures, it means that you send too much data and the real problem is how to limit and monitor your message queue size. On Mon, Sep 3, 2012 at 7:03 PM, Nir Soffer wrote: On Mon, Sep 3, 2012 at 1:05 PM, Parvez Shaikh wrote: Thanks Oleg and Ni

Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-09-03 Thread Nir Soffer
you can continue to drain your messages queue when socket is ready. The way you work with EV_WRITE is not related to working with threads. > On Sun, Sep 2, 2012 at 3:45 PM, Nir Soffer wrote: > >> >> >> On Sun, Sep 2, 2012 at 6:54 AM, Parvez Shaikh wrote: >> >>>

Re: [Libevent-users] EV_WRITE - Wait for a socket or FD to become writeable.

2012-09-02 Thread Nir Soffer
On Sun, Sep 2, 2012 at 6:54 AM, Parvez Shaikh wrote: > Thanks Oleg, > > Second approach is what I am doing. > > Why disabled EV_WRITE in write callback? > > I'd wish to have this callback called again whenever send buffer has > space, so disabling EV_WRITE will prevent this. You want to enable E

Re: [Libevent-users] parse query string

2012-08-11 Thread Nir Soffer
On Aug 11, 2012, at 6:30 PM, Riccardo Tacconi wrote: Hi, I have the following code called from libevent's http-server.c demo: #include "servlet.h" void servlet(struct evhttp_request *req, struct evbuffer *evb) { size_t len = evbuffer_get_length(evhttp_request_get_input_buffer(req));

Re: [Libevent-users] Deadlock when calling bufferevent_free from an other thread

2012-08-06 Thread Nir Soffer
On Mon, Aug 6, 2012 at 9:42 PM, Matthieu Nottale < mnott...@aldebaran-robotics.com> wrote: > Hi. > > I'm experiencing a deadlock on 2.0.19 while calling bufferevent_free frome > thread A, while thread B is in event_base_dispatch. > > Here are the two relevant backtraces: > > (gdb) bt > #0 0xb7fe1

Re: [Libevent-users] Crash in my simple multi-threaded evhttp app [code incl.]

2012-07-11 Thread Nir Soffer
On Thu, Jun 28, 2012 at 7:38 AM, Julian Bui wrote: > Thanks for replying, Nick. > > I probably cannot use libevhtp because it appears to be too small of a > project to get company approval for my application. We worry about support > and maintenance issues. > > Does anyone have any other suggest

Re: [Libevent-users] event_base_dispatch returning -1 - help debugging

2012-06-13 Thread Nir Soffer
On Jun 12, 2012, at 11:21 PM, Nick Mathewson wrote: Actually I think it's a C error. Check out the documentation for event_pending(): /* @return true if the event is pending on any of the events in 'what', (that is to say, it has been added), or 0 if the event is not added. */ Note that

Re: [Libevent-users] Crash in evhttp_send_reply_chunk()

2012-05-31 Thread Nir Soffer
The example code you sent is expected to crash and burn randomly: - You use multiple threads, but you do not configure libevent to use multithreading - You do not synchronize the threads in your own code. For example, accessing startSend and req from multiple threads. - You do not handle the conne

Re: [Libevent-users] a dead looping bug when changing system time backward

2012-04-19 Thread Nir Soffer
On Apr 19, 2012, at 7:30 AM, Nick Mathewson wrote: On Tue, Apr 10, 2012 at 7:21 PM, Nir Soffer wrote: On Apr 10, 2012, at 6:15 PM, Nick Mathewson wrote: And there's a third way for libevent to see a big jump forward in time: if the program calls event_base_loop() sporadically,

Re: [Libevent-users] How to activate read callback when not all data was read

2012-04-10 Thread Nir Soffer
On Apr 10, 2012, at 6:33 PM, Nick Mathewson wrote: Instead you can simply say: ev = event_new(base, -1, 0, process_work_queue_cb, NULL); event_active(ev, EV_TIMEOUT, 1); The second approach is better because it doesn't require you to put the event in the timeout heap at all: instead, Libe

Re: [Libevent-users] a dead looping bug when changing system time backward

2012-04-10 Thread Nir Soffer
On Apr 10, 2012, at 6:15 PM, Nick Mathewson wrote: And there's a third way for libevent to see a big jump forward in time: if the program calls event_base_loop() sporadically, it is free to wait as long as it wants between invocations. So, what's the right behavior for periodic events in these

Re: [Libevent-users] Strange timeout scheduling in 1.4

2011-08-08 Thread Nir Soffer
On Aug 4, 2011, at 9:36 PM, Nick Mathewson wrote: On Thu, Jul 28, 2011 at 3:35 AM, Nicholas Marriott wrote: Interesting. We have seen problems in the past with gettimeofday() not being very deterministic on Linux, with occasional spikes in the time it takes, although I don't have the numbers

[Libevent-users] Re: [Libevent-users] httpserver.cpp:190: error: invalid application of ‘sizeof’ to incomplete type ‘evkeyvalq’

2011-06-30 Thread Nir Soffer
On Thu, Jun 30, 2011 at 11:36 AM, 李白|字一日 wrote: > hi, all > i am trying to extract the query information from uri, > and i found the evkeyvalq is used in input_headers. > > so i copied the way the input_headers created by the following line: > > evkeyvalq *query = (evkeyvalq *)calloc(1, sizeof(

Re: [Libevent-users] [PATCH] evbuffer_search_range fails when searching the last byte

2011-06-13 Thread Nir Soffer
On Jun 14, 2011, at 12:06 AM, Nick Mathewson wrote: On Wed, Jun 8, 2011 at 8:38 PM, Nir Soffer wrote: [...] Also, there's another problem with my original patch. By my logic, if the buffer is empty and has no chains at all, then evbuffer_ptr_set(buf, ptr, 0, EVBUFFER_PTR_SET) oug

Re: [Libevent-users] Test failures on Mac OS X 10.5.8

2011-06-10 Thread Nir Soffer
On Jun 11, 2011, at 12:28 AM, Nick Mathewson wrote: On Wed, Jun 8, 2011 at 9:28 PM, Nir Soffer wrote: Hi, I'm getting some random dns failures with versions from the last week: The failures are random - sometimes all the tests pass, sometimes some of the backends fail in the

Re: [Libevent-users] [PATCH] evbuffer_search_range fails when searching the last byte

2011-06-09 Thread Nir Soffer
On Jun 9, 2011, at 3:38 AM, Nir Soffer wrote: I think I have a working patch. <0003-Allow-searching-up-to-the-end-of-the-buffer.patch> This patch fixes a race condition when checking for the special "end of buffer" ptr. 0004-Fix-race-codition-when-checking-for-the-sp

[Libevent-users] Test failures on Mac OS X 10.5.8

2011-06-08 Thread Nir Soffer
Hi, I'm getting some random dns failures with versions from the last week: The failures are random - sometimes all the tests pass, sometimes some of the backends fail in the same place, and sometimes all of them fail in the same place. I did not see these errors in 2.0.11-stable, but maybe

Re: [Libevent-users] [PATCH] evbuffer_search_range fails when searching the last byte

2011-06-08 Thread Nir Soffer
On Jun 8, 2011, at 8:50 PM, Nick Mathewson wrote: On Tue, Jun 7, 2011 at 9:30 AM, Nir Soffer wrote: On Jun 7, 2011, at 4:03 AM, Nick Mathewson wrote: On Mon, Jun 6, 2011 at 8:37 PM, Nir Soffer wrote: Here's another patch that might make stuff work. Before I'd apply it, I

Re: [Libevent-users] Re: Dead or wrong code

2011-06-07 Thread Nir Soffer
On Jun 7, 2011, at 8:48 PM, Gilad Benjamini wrote: 955 buf->first = chain; 956 if (chain) { 957 chain->misalign += remaining; 958 chain->off -= remaining; 959 } Draining all the buffer trigger this code. Adding an assert in line 957 cause the t

Re: [Libevent-users] [PATCH] evbuffer_search_range fails when searching the last byte

2011-06-07 Thread Nir Soffer
On Jun 7, 2011, at 5:01 PM, Andrew W. Nosenko wrote: On Tue, Jun 7, 2011 at 16:30, Nir Soffer wrote: On Jun 7, 2011, at 4:03 AM, Nick Mathewson wrote: On Mon, Jun 6, 2011 at 8:37 PM, Nir Soffer wrote: Here's another patch that might make stuff work. Before I'd apply it, I

Re: [Libevent-users] [PATCH] evbuffer_search_range fails when searching the last byte

2011-06-07 Thread Nir Soffer
On Jun 7, 2011, at 4:03 AM, Nick Mathewson wrote: On Mon, Jun 6, 2011 at 8:37 PM, Nir Soffer wrote: Here's another patch that might make stuff work. Before I'd apply it, I'd like to have a look through everything that's using evbuffer_ptr_set() and evbuffer_ptr right n

[Libevent-users] Re: Dead or wrong code

2011-06-07 Thread Nir Soffer
evbuffer_drain has the code below. Can chain ever be NULL in line 956 ? If the while was completed due to the test in line 935, which dereferenced chain, it can’t. If the while was broken in line 950, then line 949 dereferenced chain, so it can’t be NULL either. I.e. either the test in line

Re: [Libevent-users] [PATCH] evbuffer_search_range fails when searching the last byte

2011-06-07 Thread Nir Soffer
On Jun 7, 2011, at 4:03 AM, Nick Mathewson wrote: On Mon, Jun 6, 2011 at 8:37 PM, Nir Soffer wrote: Here's another patch that might make stuff work. Before I'd apply it, I'd like to have a look through everything that's using evbuffer_ptr_set() and evbuffer_ptr right n

Re: [Libevent-users] [PATCH] evbuffer_search_range fails when searching the last byte

2011-06-07 Thread Nir Soffer
On Jun 7, 2011, at 4:03 AM, Nick Mathewson wrote: On Mon, Jun 6, 2011 at 8:37 PM, Nir Soffer wrote: Hi, I found that evbuffer_search_range fails when you try search the last byte with a non null end pointer. You can work around this by checking the buffer length and calling

[Libevent-users] [PATCH] evbuffer_search_range fails when searching the last byte

2011-06-06 Thread Nir Soffer
Hi, I found that evbuffer_search_range fails when you try search the last byte with a non null end pointer. You can work around this by checking the buffer length and calling evbuffer_search() instead, or evbuffer_search_range with a null end pointer. I don't know how to fix it yet, but