Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling evthread_use_pthreads() after calling ev_base_new() #191

Closed
tohava opened this issue Nov 30, 2014 · 4 comments
Closed

Calling evthread_use_pthreads() after calling ev_base_new() #191

tohava opened this issue Nov 30, 2014 · 4 comments

Comments

@tohava
Copy link

tohava commented Nov 30, 2014

libevent allows doing this, which causes bugs, since locks are sometimes used and sometimes not. I would expect that at least with the debug flag on, I will get an error message for this.

@nmathewson
Copy link
Member

That's a fine idea. I'd be glad to apply a patch for this.

@ghazel
Copy link
Contributor

ghazel commented Dec 20, 2014

+1 for at least an error message, if it's not possible to make it just work. I ran in to this bug today.

@errzey
Copy link
Contributor

errzey commented May 7, 2015

Off the top of my head, I would suggest using event_enable_debug_mode type features:

#ifndef EVENT__DISABLE_DEBUG_MODE
int event_base_created_ = 0;
#endif

/* .... */

struct event_base *
event_base_new_with_config(const struct event_config *cfg) 
{
       /* ... */
#ifndef EVENT__DISABLE_DEBUG_MODE
        if (event_debug_mode_on_)
            event_base_created_ += 1;
#endif
       /* ... */
}

/* ..... */

int
evthread_use_pthreads(void)
{
#ifndef EVENT__DISABLE_DEBUG_MODE
        if (event_debug_mode_on_ && event_base_created_) 
           event_errx(1, "evthread_use_pthreads must be called BEFORE any events")
#endif
        /* .... */
}

@errzey
Copy link
Contributor

errzey commented May 29, 2015

#251 Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants