File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -401,10 +401,19 @@ tcp_listener_bind(struct context *c)
401401# define LEV_OPT_DEFERRED_ACCEPT 0
402402#endif
403403
404+ /* Until libevent gets support for SO_REUSEPORT we have to break
405+ * evconnlistener_new_bind() into a series of:
406+ * socket(), tcp_tune(), bind(), evconnlistener_new() */
404407 evutil_socket_t fd ;
405408 fd = socket (c -> local_sockaddr .ss_family , SOCK_STREAM , IPPROTO_TCP );
406409
407410 tcp_tune (fd );
411+ evutil_make_socket_nonblocking (fd );
412+
413+ if (bind (fd , (struct sockaddr * ) & c -> local_sockaddr , c -> local_sockaddr_len ) < 0 ) {
414+ logger (LOG_ERR , "Unable to bind (TCP): %s" );
415+ return -1 ;
416+ }
408417
409418 c -> tcp_conn_listener =
410419 evconnlistener_new (c -> event_loop ,
@@ -416,7 +425,7 @@ tcp_listener_bind(struct context *c)
416425 TCP_REQUEST_BACKLOG ,
417426 fd );
418427 if (c -> tcp_conn_listener == NULL ) {
419- logger (LOG_ERR , "Unable to bind (TCP)" );
428+ logger (LOG_ERR , "Unable to create listener (TCP)" );
420429 return -1 ;
421430 }
422431 if (evconnlistener_disable (c -> tcp_conn_listener ) != 0 ) {
You can’t perform that action at this time.
0 commit comments