File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -401,10 +401,19 @@ tcp_listener_bind(struct context *c)
401
401
# define LEV_OPT_DEFERRED_ACCEPT 0
402
402
#endif
403
403
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() */
404
407
evutil_socket_t fd ;
405
408
fd = socket (c -> local_sockaddr .ss_family , SOCK_STREAM , IPPROTO_TCP );
406
409
407
410
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
+ }
408
417
409
418
c -> tcp_conn_listener =
410
419
evconnlistener_new (c -> event_loop ,
@@ -416,7 +425,7 @@ tcp_listener_bind(struct context *c)
416
425
TCP_REQUEST_BACKLOG ,
417
426
fd );
418
427
if (c -> tcp_conn_listener == NULL ) {
419
- logger (LOG_ERR , "Unable to bind (TCP)" );
428
+ logger (LOG_ERR , "Unable to create listener (TCP)" );
420
429
return -1 ;
421
430
}
422
431
if (evconnlistener_disable (c -> tcp_conn_listener ) != 0 ) {
You can’t perform that action at this time.
0 commit comments