mirror of https://github.com/F-Stack/f-stack.git
Nginx: Restore ngx_get_connection and ngx_free_connection
The code that we used to preserve ngx_get_connection and ngx_free_connection thread safety , is not necessary now.
This commit is contained in:
parent
6484644fe3
commit
dcfbe1ad39
|
@ -1076,9 +1076,6 @@ ngx_get_connection(ngx_socket_t s, ngx_log_t *log)
|
|||
ngx_uint_t instance;
|
||||
ngx_event_t *rev, *wev;
|
||||
ngx_connection_t *c;
|
||||
#if (NGX_HAVE_FSTACK)
|
||||
ngx_atomic_uint_t success;
|
||||
#endif
|
||||
|
||||
/* disable warning: Win32 SOCKET is u_int while UNIX socket is int */
|
||||
|
||||
|
@ -1089,35 +1086,7 @@ ngx_get_connection(ngx_socket_t s, ngx_log_t *log)
|
|||
s, ngx_cycle->files_n);
|
||||
return NULL;
|
||||
}
|
||||
#if (NGX_HAVE_FSTACK)
|
||||
#ifndef unlikely
|
||||
#define unlikely(x) __builtin_expect((x),0)
|
||||
#endif
|
||||
/* move ngx_cycle->free_connections atomically */
|
||||
do {
|
||||
/* Restore n as it may change every loop */
|
||||
c = ngx_cycle->free_connections;
|
||||
|
||||
if (c == NULL) {
|
||||
ngx_drain_connections((ngx_cycle_t *) ngx_cycle);
|
||||
c = ngx_cycle->free_connections;
|
||||
}
|
||||
|
||||
if (c == NULL) {
|
||||
ngx_log_error(NGX_LOG_ALERT, log, 0,
|
||||
"%ui worker_connections are not enough",
|
||||
ngx_cycle->connection_n);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
success = ngx_atomic_cmp_set(&ngx_cycle->free_connections, c,
|
||||
c->data);
|
||||
|
||||
} while (unlikely(success == 0));
|
||||
|
||||
ngx_memory_barrier();
|
||||
#else
|
||||
c = ngx_cycle->free_connections;
|
||||
|
||||
if (c == NULL) {
|
||||
|
@ -1134,7 +1103,6 @@ ngx_get_connection(ngx_socket_t s, ngx_log_t *log)
|
|||
}
|
||||
|
||||
ngx_cycle->free_connections = c->data;
|
||||
#endif
|
||||
ngx_cycle->free_connection_n--;
|
||||
|
||||
if (ngx_cycle->files && ngx_cycle->files[s] == NULL) {
|
||||
|
@ -1178,25 +1146,8 @@ ngx_get_connection(ngx_socket_t s, ngx_log_t *log)
|
|||
void
|
||||
ngx_free_connection(ngx_connection_t *c)
|
||||
{
|
||||
#if (NGX_HAVE_FSTACK)
|
||||
ngx_atomic_uint_t success;
|
||||
|
||||
/* move ngx_cycle->free_connections atomically */
|
||||
do {
|
||||
/* Restore n as it may change every loop */
|
||||
c->data = ngx_cycle->free_connections;
|
||||
|
||||
success = ngx_atomic_cmp_set(&ngx_cycle->free_connections, c->data,
|
||||
c);
|
||||
|
||||
} while (unlikely(success == 0));
|
||||
|
||||
ngx_memory_barrier();
|
||||
|
||||
#else
|
||||
c->data = ngx_cycle->free_connections;
|
||||
ngx_cycle->free_connections = c;
|
||||
|
||||
#endif
|
||||
ngx_cycle->free_connection_n++;
|
||||
|
||||
if (ngx_cycle->files && ngx_cycle->files[c->fd] == c) {
|
||||
|
|
Loading…
Reference in New Issue