Skip to content

Commit

Permalink
Merge pull request #1701 from vitalikvoip/2.4_fix_tcpchild_busy_counter
Browse files Browse the repository at this point in the history
Fix TCP connections load balancing to use all TCP workers evenly
(cherry picked from commit 55d95ec)
  • Loading branch information
bogdan-iancu committed May 28, 2019
1 parent 2cc2036 commit ab79540
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions net/net_tcp.c
Expand Up @@ -1206,6 +1206,8 @@ inline static int handle_tcp_worker(struct tcp_child* tcp_c, int fd_i)
break;
case ASYNC_WRITE:
tcp_c->busy--;
/* fall through*/
case ASYNC_WRITE2:
if (tcpconn->state==S_CONN_BAD){
tcpconn_destroy(tcpconn);
break;
Expand All @@ -1220,6 +1222,8 @@ inline static int handle_tcp_worker(struct tcp_child* tcp_c, int fd_i)
case CONN_EOF:
/* WARNING: this will auto-dec. refcnt! */
tcp_c->busy--;
/* fall through*/
case CONN_ERROR2:
if ((tcpconn->flags & F_CONN_REMOVED) != F_CONN_REMOVED &&
(tcpconn->s!=-1)){
reactor_del_all( tcpconn->s, -1, IO_FD_CLOSING);
Expand Down
4 changes: 2 additions & 2 deletions net/net_tcp_proc.c
Expand Up @@ -79,11 +79,11 @@ void tcp_conn_release(struct tcp_connection* c, int pending_data)
if (c->state==S_CONN_BAD) {
c->lifetime=0;
/* CONN_ERROR will auto-dec refcnt => we must not call tcpconn_put !!*/
tcpconn_release(c, CONN_ERROR,1);
tcpconn_release(c, CONN_ERROR2,1);
return;
}
if (pending_data) {
tcpconn_release(c, ASYNC_WRITE,1);
tcpconn_release(c, ASYNC_WRITE2,1);
return;
}
tcpconn_put(c);
Expand Down
4 changes: 2 additions & 2 deletions net/tcp_conn.h
Expand Up @@ -58,8 +58,8 @@


/* fd communication commands - internal usage ONLY */
enum conn_cmds { CONN_DESTROY=-3, CONN_ERROR=-2, CONN_EOF=-1, CONN_RELEASE,
CONN_GET_FD, CONN_NEW, ASYNC_CONNECT, ASYNC_WRITE, CONN_RELEASE_WRITE };
enum conn_cmds { CONN_DESTROY=-4, CONN_ERROR=-3,CONN_ERROR2=-2, CONN_EOF=-1, CONN_RELEASE,
CONN_GET_FD, CONN_NEW, ASYNC_CONNECT, ASYNC_WRITE, ASYNC_WRITE2, CONN_RELEASE_WRITE };
/* CONN_RELEASE, EOF, ERROR, DESTROY can be used by "reader" processes
* CONN_GET_FD, NEW, ERROR only by writers */

Expand Down

0 comments on commit ab79540

Please sign in to comment.