Motr  M0
conn_pool.c File Reference
#include "lib/trace.h"
#include "lib/memory.h"
#include "lib/string.h"
#include "lib/errno.h"
#include "lib/finject.h"
#include "rpc/session.h"
#include "rpc/link.h"
#include "rpc/conn_pool.h"
#include "rpc/conn_pool_internal.h"
#include "rpc/rpc_machine_internal.h"
Include dependency graph for conn_pool.c:

Go to the source code of this file.

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_RPC
 

Functions

 M0_TL_DESCR_DEFINE (rpc_conn_pool_items, "rpc cpi list", M0_INTERNAL, struct m0_rpc_conn_pool_item, cpi_linkage, cpi_magic, M0_RPC_CONN_POOL_ITEMS_MAGIC, M0_RPC_CONN_POOL_ITEMS_HEAD_MAGIC)
 
 M0_TL_DEFINE (rpc_conn_pool_items, M0_INTERNAL, struct m0_rpc_conn_pool_item)
 
static struct m0_rpc_conn_pool_itemfind_item_by_ep (struct m0_rpc_conn_pool *pool, const char *remote_ep)
 
static struct m0_rpc_conn_pool_itemfind_pool_item (struct m0_rpc_session *session)
 
static bool pool_item_clink_cb (struct m0_clink *link)
 
static int conn_pool_item_init (struct m0_rpc_conn_pool *pool, struct m0_rpc_conn_pool_item *item, const char *remote_ep)
 
static void conn_pool_item_fini (struct m0_rpc_conn_pool_item *item)
 
static struct m0_rpc_conn_pool_itemconn_pool_item_get (struct m0_rpc_conn_pool *pool, const char *remote_ep)
 
M0_INTERNAL int m0_rpc_conn_pool_get_sync (struct m0_rpc_conn_pool *pool, const char *remote_ep, struct m0_rpc_session **session)
 
M0_INTERNAL int m0_rpc_conn_pool_get_async (struct m0_rpc_conn_pool *pool, const char *remote_ep, struct m0_rpc_session **session)
 
M0_INTERNAL void m0_rpc_conn_pool_put (struct m0_rpc_conn_pool *pool, struct m0_rpc_session *session)
 
M0_INTERNAL struct m0_chanm0_rpc_conn_pool_session_chan (struct m0_rpc_session *session)
 
M0_INTERNAL bool m0_rpc_conn_pool_session_established (struct m0_rpc_session *session)
 
M0_INTERNAL int m0_rpc_conn_pool_init (struct m0_rpc_conn_pool *pool, struct m0_rpc_machine *rpc_mach, m0_time_t conn_timeout, uint64_t max_rpcs_in_flight)
 
M0_INTERNAL void m0_rpc_conn_pool_fini (struct m0_rpc_conn_pool *pool)
 
static void pool_item_disconnected_ast (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
static bool pool_item_disconn_cb (struct m0_clink *link)
 
static void pool_item_disconn_ast (struct m0_sm_group *grp, struct m0_sm_ast *ast)
 
M0_INTERNAL void m0_rpc_conn_pool_destroy (struct m0_rpc_conn_pool *pool, struct m0_rpc_session *session)
 

Macro Definition Documentation

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_RPC

Definition at line 23 of file conn_pool.c.

Function Documentation

◆ conn_pool_item_fini()

static void conn_pool_item_fini ( struct m0_rpc_conn_pool_item item)
static

Definition at line 130 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ conn_pool_item_get()

static struct m0_rpc_conn_pool_item* conn_pool_item_get ( struct m0_rpc_conn_pool pool,
const char *  remote_ep 
)
static

Definition at line 142 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ conn_pool_item_init()

static int conn_pool_item_init ( struct m0_rpc_conn_pool pool,
struct m0_rpc_conn_pool_item item,
const char *  remote_ep 
)
static

Definition at line 105 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_item_by_ep()

static struct m0_rpc_conn_pool_item* find_item_by_ep ( struct m0_rpc_conn_pool pool,
const char *  remote_ep 
)
static

Definition at line 46 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_pool_item()

static struct m0_rpc_conn_pool_item* find_pool_item ( struct m0_rpc_session session)
static

Definition at line 69 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_conn_pool_destroy()

M0_INTERNAL void m0_rpc_conn_pool_destroy ( struct m0_rpc_conn_pool pool,
struct m0_rpc_session session 
)

Destroy this rpc session from this pool.

First, the connection pool item will be identified by iterating the connection pool list and removed from the list. Then, the rpc link will be asynchronously disconnect. In the disconnection callback, we will destroy this rpc link.

Definition at line 450 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_conn_pool_fini()

M0_INTERNAL void m0_rpc_conn_pool_fini ( struct m0_rpc_conn_pool pool)

Definition at line 345 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_conn_pool_get_async()

M0_INTERNAL int m0_rpc_conn_pool_get_async ( struct m0_rpc_conn_pool pool,
const char *  remote_ep,
struct m0_rpc_session **  session 
)
Todo:
Potential race if connection is established before clink is added to session channel.
Todo:
Looks like rpc link connect could not be called twice, even in case first attempt fails (phase 2).

Definition at line 230 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_conn_pool_get_sync()

M0_INTERNAL int m0_rpc_conn_pool_get_sync ( struct m0_rpc_conn_pool pool,
const char *  remote_ep,
struct m0_rpc_session **  session 
)

Definition at line 197 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_conn_pool_init()

M0_INTERNAL int m0_rpc_conn_pool_init ( struct m0_rpc_conn_pool pool,
struct m0_rpc_machine rpc_mach,
m0_time_t  conn_timeout,
uint64_t  max_rpcs_in_flight 
)

Definition at line 325 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_conn_pool_put()

M0_INTERNAL void m0_rpc_conn_pool_put ( struct m0_rpc_conn_pool pool,
struct m0_rpc_session session 
)

Definition at line 288 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_conn_pool_session_chan()

M0_INTERNAL struct m0_chan* m0_rpc_conn_pool_session_chan ( struct m0_rpc_session session)

Definition at line 304 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_rpc_conn_pool_session_established()

M0_INTERNAL bool m0_rpc_conn_pool_session_established ( struct m0_rpc_session session)
Todo:
Unprotected access to ->sm_state in this function.

Definition at line 310 of file conn_pool.c.

Here is the caller graph for this function:

◆ M0_TL_DEFINE()

M0_TL_DEFINE ( rpc_conn_pool_items  ,
M0_INTERNAL  ,
struct m0_rpc_conn_pool_item   
)

◆ M0_TL_DESCR_DEFINE()

M0_TL_DESCR_DEFINE ( rpc_conn_pool_items  ,
"rpc cpi list ,
M0_INTERNAL  ,
struct m0_rpc_conn_pool_item  ,
cpi_linkage  ,
cpi_magic  ,
M0_RPC_CONN_POOL_ITEMS_MAGIC  ,
M0_RPC_CONN_POOL_ITEMS_HEAD_MAGIC   
)

◆ pool_item_clink_cb()

static bool pool_item_clink_cb ( struct m0_clink link)
static

Definition at line 86 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pool_item_disconn_ast()

static void pool_item_disconn_ast ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

Definition at line 420 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pool_item_disconn_cb()

static bool pool_item_disconn_cb ( struct m0_clink link)
static

Definition at line 386 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pool_item_disconnected_ast()

static void pool_item_disconnected_ast ( struct m0_sm_group grp,
struct m0_sm_ast ast 
)
static

Definition at line 376 of file conn_pool.c.

Here is the call graph for this function:
Here is the caller graph for this function: