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

Potential error in bufferevent_socket_new code. #18

Closed
ghost opened this issue Aug 9, 2012 · 2 comments
Closed

Potential error in bufferevent_socket_new code. #18

ghost opened this issue Aug 9, 2012 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 9, 2012

Our application uses evconnlistener that accepts connection requests, creates a buffered event using bufferevent_socket_new for passed fd and assigns it to one of running event loop threads. It seems that in some rare cases file descriptor passed to evconnlistener callback is already invalid. In this case code called from bufferevent_socket_new eventually fails with a warning like that:

[warn] Epoll ADD(1) on fd 45 failed. Old events were 0; read change was 1 (add); write change was 0 (none): Bad file descriptor

but it does not cause a NULL return from bufferevent_socket_new. I think that it's a bug as I do not see an easy way to check whether a file descriptor is valid without actually using it. Probably a result of evbuffer_add_cb define is not checked.

@nmathewson
Copy link
Member

So the only way to get an EBADF from event_add's backend in epoll would seem to be passing one that you've already closed, right? If it's been closed on the other side, it shouldn't give an EBADF.

@ghost
Copy link
Author

ghost commented Sep 12, 2012

Strange, but it has never happened again after this issue was submitted. May be it was caused by some pitfalls in multithreading code. I'm closing this issue as I do not have enough information to provide.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant