[PATCH v2] iproto: report active connections number

Vladimir Davydov vdavydov.dev at gmail.com
Tue Feb 26 11:18:45 MSK 2019


On Tue, Feb 26, 2019 at 01:36:07AM +0300, Ilya Kosarev wrote:
> diff --git a/src/box/iproto.cc b/src/box/iproto.cc
> index 863eb4f06..386bab239 100644
> --- a/src/box/iproto.cc
> +++ b/src/box/iproto.cc
> @@ -263,14 +263,20 @@ static struct cord net_cord;
>  static struct slab_cache net_slabc;
>  
>  struct rmean *rmean_net;
> +struct rmean *rmean_connections;
>  
>  enum rmean_net_name {
>  	IPROTO_SENT,
>  	IPROTO_RECEIVED,
>  	IPROTO_LAST,
>  };
> +enum rmean_connection_name {
> +    IPROTO_CONNECTIONS,
> +    IPROTO_CONNECTIONS_LAST,
> +};

Why do you use rmean for this at all? You don't need to account RPS,
do you?

I think you don't even need to introduce a new counter - instead you
can simply use mempool_count(iproto_connection_pool).

> diff --git a/test/box/stat_net.result b/test/box/stat_net.result
> index b3e3db11f..dad932f8c 100644
> --- a/test/box/stat_net.result
> +++ b/test/box/stat_net.result
> @@ -46,8 +58,35 @@ box.stat.net.RECEIVED.total > 0
>  ---
>  - true
>  ...
> +box.stat.net.CONNECTIONS.total == 4
> +---
> +- true
> +...
>  -- box.stat.net.EVENTS.total > 0
>  -- box.stat.net.LOCKS.total > 0
> +cn1:close()
> +---
> +...
> +cn2:close()
> +---
> +...
> +fiber.sleep(0.001)

What's fiber.sleep for? If there's a delay after close() you should use
test_run.wait_cond() to exclude any possibility of a race.

> +---
> +...
> +box.stat.net.CONNECTIONS.total == 2
> +---
> +- true
> +...



More information about the Tarantool-patches mailing list