[Libevent-users] Write quirks in default eventbuffer implementation?

2010-09-09 Thread Kelly Brock
Hi folks, First off, let me preface this in terms that I've used 1.x libevent a bit in the past but given the 2.x release candidate I'm experimenting with, I can't say what is proper and what is actually a bug. So, with that in mind I'm not certain if this is me using things incorrectly o

[Libevent-users] Forwarding events to a different event base.

2010-10-26 Thread Kelly Brock
Hi Folks, So, given the latest rc does not support listener sockets under Win IOCP (unless that has changed), something I would like to do is push listener events into a different event base. The simple reasoning is that I would like my worker threads to get both the read/write/timer and

RE: [Libevent-users] Forwarding events to a different event base.

2010-10-26 Thread Kelly Brock
Hi Nick, > >        So, given the latest rc does not support listener sockets under > Win > > IOCP (unless that has changed), > > Are you talking about the IOCP based evconnlistener stuff? It's > supposed to be working; if it isn't, you should open a bug on the > tracker. I tried it las

RE: [Libevent-users] Forwarding events to a different event base.

2010-10-28 Thread Kelly Brock
Hi Nick, > >> >        So, given the latest rc does not support listener sockets > under > >> Win > >> > IOCP (unless that has changed), > >> > >> Are you talking about the IOCP based evconnlistener stuff?  It's > >> supposed to be working; if it isn't, you should open a bug on the > >> tracker. >

[Libevent-users] Proper socket shutdown.

2010-10-28 Thread Kelly Brock
Hi Folks, I was cleaning up some experimental code and wanted to fix up the network connections to perform a correct/clean socket shutdown handshake. Unfortunately I can't seem to find any way of doing this through the existing API, documentation or example code and I'm hoping that I'm sim

RE: [Libevent-users] Proper socket shutdown.

2010-10-29 Thread Kelly Brock
Ok, so figured out a way to do this and it seems clean and works with the select based backend but not the iocp based backend. Basically I just set the watermark for write to 1 and 0 and set a flag for "shutting down write". When I get the write callback at this point, I just call the shutdown wri

RE: [Libevent-users] Proper socket shutdown.

2010-10-30 Thread Kelly Brock
Hi Nick, > > Ok, so figured out a way to do this and it seems clean and works with > the > > select based backend but not the iocp based backend.  Basically I just > set > > > > But, it does not seem to work on the IOCP version which seems a bit odd > > since this should be handled at the OS level

RE: [Libevent-users] Proper socket shutdown.

2010-10-30 Thread Kelly Brock
Hi, Writing this in between errands. > >        Just a note before the details.  I would suggest adding a little > > section to the manual covering the proper method of handshaked shutdown. > > It's just a minor thing but figuring out the watermark method is non- > obvious > > till you gi

RE: [Libevent-users] Proper socket shutdown.

2010-11-03 Thread Kelly Brock
Hi Nick, Any luck on this? > > >        Anywhere, here is a quick and dirty testbed for the problem. > > > > > > http://pastebin.com/QF4N2DEw > > > > > >        If you leave "USE_IOCP" set to 0 everything shuts down > correctly. > > > If you turn that flag on though, the EOF's are never s

RE: [Libevent-users] Proper socket shutdown.

2010-11-03 Thread Kelly Brock
Hi again, > So, I've managed to poke around just a little since sending the > example code and not really found anything interesting as of yet but had > an > evil thought. I started wondering about the "shutdown" function being > unreliable with IOCP from your information. I can't say for

RE: [Libevent-users] Proper socket shutdown.

2010-11-03 Thread Kelly Brock
Hi Nick, > >>       This certainly seems like an evil stupid thing IOCP could be > doing > >> here. :( > > > >        Nope, wasn't this.  Can't even get EOF using the > WSASendDisconnect > > calls, something is definitely wrong at a lower level.  Will dig into it > > more as I find time. > > Were

RE: [Libevent-users] Proper socket shutdown.

2010-11-04 Thread Kelly Brock
Hi Nick, > >>       So, I've managed to poke around just a little since sending the > >> example code and not really found anything interesting as of yet but > had > >> an > >> evil thought.  I started wondering about the "shutdown" function being > >> unreliable with IOCP from your information.  

[Libevent-users] Another possible iocp issue.

2010-11-22 Thread Kelly Brock
Hi Folks, I'm still working up an example testbed for this but figured I'd give you a heads up. Basically I am getting a memory corruption in the following (rather extreme) case: 1. Create a standard listener. 2. Setup 1000 buffer event items. Thread safe, deferred and close o

RE: [Libevent-users] Another possible iocp issue.

2010-11-22 Thread Kelly Brock
Hi Nick, > >        I'll post more info and a testbed as soon as possible. > > Hi, Kelly! Some test code would probably indeed be necessary to fix > any bugs here. Also useful for the time being would be a > cut-and-paste of the info _exactly_ from your debugger, not just a > summary. iow, *wh

RE: [Libevent-users] Another possible iocp issue.

2010-11-23 Thread Kelly Brock
Grr, CNR.. With the little testbed I was unable to reproduce the problem. It is likely a timing issue or I do have a problem somewhere in my code which is of course very possible. I will keep poking at this later tonight and see if I can get a repro case. KB > > >        I'll post more

RE: [Libevent-users] Another possible iocp issue.

2010-11-23 Thread Kelly Brock
Actually I thought of something and ran a quick test. Seems this was definitely my problem. Basically in the process of thinking "single threaded" I forgot that the IOCP backend would still be running in separate threads, so I was not locking the buffers when adding/removing data. This does seem

RE: [Libevent-users] Closing bufferevents sockets from the server side

2010-11-24 Thread Kelly Brock
Hi Sid, > Sorry that got posted by mistake in the wrong thread... here it is > again... > > > Hi, > I am using libevent 2.03 alpha 1 to create an app > . The app structure is as follows: > > A C++ app wraps lib event to listen on a domain socke

RE: [Libevent-users] Closing bufferevents sockets from the server side

2010-11-25 Thread Kelly Brock
Hi, > Hey, > I understand Simon's view on how not to close buffer event sockets, but > can some one explain why thishttps://gist.github.com/714606idea is bad? I don't feel "strongly" that this is incorrect; Simon may have more information on this. But, basically it is just added overhea

RE: [Libevent-users] Closing bufferevents sockets from the server side

2010-11-25 Thread Kelly Brock
Oh, should mention that depending on what you are trying to do in detail, you may not want to use bufferevent_free and instead use "shutdown" calls. I.e. the "correct" way to close a socket (buffer event) is basically the following (sorry if I'm stating the obvious): 1. Server writes the las

RE: [Libevent-users] ANN: Libevent 2.0.9-rc is released

2010-11-30 Thread Kelly Brock
e that we remember it, even if you > mentioned it here, or emailed me personally, or such. > > *** Acknowledgements > > Many thanks to everybody who contributed code, suggestions, or bug > reports to this releas

[Libevent-users] Proper time to request port from a listener.

2010-12-01 Thread Kelly Brock
Hi Folks, Maybe someone has done this before so figured I'd ask while I'm still experimenting with possible solutions. In the process of finishing up some porting to OsX I noticed that I have a race condition in my code related to listener sockets. Previously I would just bring up the li

RE: [Libevent-users] If you have a patch or a bug, *please* put it on the bugtracker

2010-12-01 Thread Kelly Brock
The iocp listener fix posted has a new bug added as: 3124666. Should be able to mark it fixed with the change mentioned previously. KB > -Original Message- > From: owner-libevent-us...@freehaven.net [mailto:owner-libevent- > us...@freehaven.net] On Behalf Of Nick Mathewson > Sent: Tuesda

RE: [Libevent-users] Proper time to request port from a listener.

2010-12-01 Thread Kelly Brock
Please ignore this whole thing. Sheesh, been too long since I've done low level sockets stuff. The end problem was a bit of sloppy code and me misremembering an issue with Win32 specific servers that doesn't apply to linux/osx. > Hi Folks, > > Maybe someone has done this before so figured

RE: [Libevent-users] How do I get the client IP address?

2010-12-10 Thread Kelly Brock
Hi Christian, As a question/suggestion, why are you not using the evconnlistener api, it would give you all the data you desire. I.e. the callback is of the form: void _acceptor( struct evconnlistener* el, evutil_socket_t fd, struct sockaddr* addr, int addrLen, void* context ) T

[Libevent-users] Socket shutdown part 2.

2010-12-18 Thread Kelly Brock
Hi Folks, Added a comment to the shutdown feature request (ID: 3108251) which I figured I should cover in more detail. The basics are covered in the feature details (though probably correcting mistakes here as I think about it further) but I'm not entirely certain I made complete sense in

RE: [Libevent-users] Opaque data on callback?

2010-12-30 Thread Kelly Brock
Hi Harlan, Perhaps I'm missing something but the callback for async dns is: _lookup_response( int errCode, struct evutil_addrinfo* info, void* data ) Where the "data" member is what you pass into evdns_getaddrinfo and can be anything you want. So, you already have a place to put your co

RE: [Libevent-users] Read callback problem

2011-02-06 Thread Kelly Brock
Hi, > I have a simple network application with simple protocol over > TCP\IP. The main idea of protocol is size+message model. So at first i'm > sending size of message (coded in big-endian, first 4 bytes) than the > whole message. > I'm using event2 and read data from OnRead callback

RE: [Libevent-users] Read callback problem

2011-02-08 Thread Kelly Brock
Ack, missed how the read was pulling the data off. Nice catch Nick... > > static void OnRead(struct bufferevent *bev, void *user_data) > > { > > int buf_len = evbuffer_get_length(bufferevent_get_input(bev)); > > ConnectionContext *ctx = user_data; > > uint8_t size_data[4],*data; > >

RE: [Libevent-users] Chicken and Egg when disconnecting users from a threaded base

2011-03-08 Thread Kelly Brock
Hi Kevin, Wish I could give you an answer but this looks very similar to the shutdown issue I had before work pulled me away to other things for the last couple months. With 1000 sockets and 10% at anytime connecting or disconnecting I loose about 1% of the disconnections to this issue, s

RE: [Libevent-users] async event_dispatch?

2011-03-19 Thread Kelly Brock
You should be able to use: int event_base_loop(struct event_base *, int); With the flag EVLOOP_NONBLOCK in order to do this. That should dispatch any outstanding events and return as soon as it is out of events. Unless it returns -1 you can just call this whenever you have time. -1 is of cours

RE: [Libevent-users] Multiplexing protocol using libevent

2011-03-21 Thread Kelly Brock
Hi Michal, Hopefully this is not too verbose but I'm actually going to be rewriting a more complicated variation of this problem myself so figured I'd walk through it in detail as an exercise. This is really not something you need libevent to do for you, in fact libevent wouldn't

RE: [Libevent-users] Multiplexing protocol using libevent

2011-03-21 Thread Kelly Brock
Since libevent supports event's priorities I thought it will be more > efficient to invoke Sender's send() method by many threads writing to the > FIFO's then using traditional priority queue + mutexes. I just have no > idea if it is the most efficient approach. > > Mich

RE: [Libevent-users] Multiple tcp client connections in single thread with using libevent

2011-04-14 Thread Kelly Brock
That looks like the basic outline but for a single thread I would suggest building the buffer events with BEV_OPT_DEFER_CALLBACKS so the callbacks are routed into the main thread. Otherwise the callbacks can be called from the worker threads directly and you could have a lot of threading fun to de

RE: [Libevent-users] Visual C++ Projects

2011-06-30 Thread Kelly Brock
Unfortunately that cmake script is only for "finding" pre-installed libevents and won't be of any use to a Windows user more than likely. I use premake4 myself; I just like lua better than the CMake language. Here is a pair of premake scripts you can use if you can take a little time to rework it