Ben Short | 20 Jun 2012 11:32
Picon
Gravatar

Shutting down the echo server

Hi, 


I've used the echo server example to implement my own server. I call the event_base_dispatch in a new thread.

Is there anyway to do an orderly shutdown of the event dispatcher?

I've tried event_base_loopbreak which returns 0 but the event_base_dispatch doesn't return.

I'm using libevent 2.0.19.

Ben
Nick Mathewson | 20 Jun 2012 16:38

Re: Shutting down the echo server

On Wed, Jun 20, 2012 at 5:32 AM, Ben Short <ben <at> benshort.co.uk> wrote:
> Hi,
>
> I've used the echo server example to implement my own server. I call
> the event_base_dispatch in a new thread.
>
> Is there anyway to do an orderly shutdown of the event dispatcher?
>
> I've tried event_base_loopbreak which returns 0 but the event_base_dispatch
> doesn't return.

If you're calling event_base_loopbreak from another thread and it
isn't shutting down the main event_base_dispatch loop, it sounds like
you probably didn't enable threading before creating the event base.

Have a look at the evthread_use_pthreads() and
evthread_use_windows_threads() functions and their documentation?

--

-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

Ben Short | 22 Jun 2012 11:23
Picon
Gravatar

Re: Shutting down the echo server

Thanks Nick that worked.

On 20 June 2012 15:38, Nick Mathewson <nickm <at> freehaven.net> wrote:
On Wed, Jun 20, 2012 at 5:32 AM, Ben Short <ben <at> benshort.co.uk> wrote:
> Hi,
>
> I've used the echo server example to implement my own server. I call
> the event_base_dispatch in a new thread.
>
> Is there anyway to do an orderly shutdown of the event dispatcher?
>
> I've tried event_base_loopbreak which returns 0 but the event_base_dispatch
> doesn't return.

If you're calling event_base_loopbreak from another thread and it
isn't shutting down the main event_base_dispatch loop, it sounds like
you probably didn't enable threading before creating the event base.

Have a look at the evthread_use_pthreads() and
evthread_use_windows_threads() functions and their documentation?

--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.

Unixservice Support | 23 Jun 2012 22:52

anybody recommend a udp proxy server

Anybody recommend a simple but powerful open source Linux UDP proxy server?

It needs to handle 1000 simultaneous connections.

For SIP dynamic routing application.

Thanks!
Gary
***********************************************************************
To unsubscribe, send an e-mail to majordomo <at> freehaven.net with
unsubscribe libevent-users    in the body.


Gmane