Motr  M0
M0ham

Data Structures

struct  ham_params
 
struct  ham_rpc_ctx
 

Macros

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_HA
 
#define HAM_SERVER_EP_DEFAULT   "0@lo:12345:43:100"
 
#define HAM_CLIENT_EP_DEFAULT   "0@lo:12345:43:101"
 
#define HAM_SERVER_WAIT_DEFAULT   0
 

Enumerations

enum  ham_mode { HM_CONNECT, HM_LISTEN, HM_SELF_CHECK }
 
enum  { HAM_ID = 72 }
 

Functions

static void * xcode_read_as (const struct m0_xcode_type *type, const char *str, int *rc)
 
static bool ha_msg_is_one_way (const struct m0_ha_msg *msg)
 
static void ham_say (const char *format,...)
 
static void ham_xcode_print (const struct m0_xcode_obj *x)
 
static int ham_fread_str (char *dest, size_t size, FILE *src)
 
static void ham_rpc_ctx_init (struct ham_rpc_ctx *ctx, const char *local_endpoint, const struct m0_fid *local_process)
 
static void ham_rpc_ctx_fini (struct ham_rpc_ctx *ctx)
 
static void ham_send (struct m0_ha *ha, struct m0_ha_link *hl, const struct m0_ha_msg *msg)
 
static void ham_entrypoint_request (struct m0_ha *ha, const struct m0_ha_entrypoint_req *req, const struct m0_uint128 *req_id)
 
static void ham_entrypoint_replied (struct m0_ha *ha, struct m0_ha_entrypoint_rep *rep)
 
static void ham_msg_received (struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg, uint64_t tag)
 
static void ham_msg_is_delivered (struct m0_ha *ha, struct m0_ha_link *hl, uint64_t tag)
 
static void ham_msg_is_not_delivered (struct m0_ha *ha, struct m0_ha_link *hl, uint64_t tag)
 
static void ham_link_connected (struct m0_ha *ha, const struct m0_uint128 *req_id, struct m0_ha_link *hl)
 
static void ham_link_reused (struct m0_ha *ha, const struct m0_uint128 *req_id, struct m0_ha_link *hl)
 
static void ham_link_absent (struct m0_ha *ha, const struct m0_uint128 *req_id)
 
static void ham_link_is_disconnecting (struct m0_ha *ha, struct m0_ha_link *hl)
 
static void ham_link_disconnected (struct m0_ha *ha, struct m0_ha_link *hl)
 
static void ham_sighandler (int signum)
 
static int ham_sighandler_init (void)
 
static int ham_params_check (struct ham_params *params)
 
static void ham_help (FILE *stream, char *progname)
 
static int ham_args_parse (struct ham_params *params, int argc, char *const *argv)
 
static void ham_maybe_set (const char **dest, const char *value)
 
int main (int argc, char **argv)
 

Variables

static struct ham_params g_params
 
static struct m0_semaphore g_sem
 
static struct m0_ha_msgg_msg
 
static struct m0_uint128 g_self_req_id
 
static const struct m0_ha_msg ham_self_check_msg_default
 
static const struct m0_ha_ops ham_ha_ops
 

Detailed Description

m0ham (HA messenger) — CLI utility for sending/receiving m0_ha_msg.

Todo:
Fix memory leaks:
Todo:
Implement "Connect/disconnect without m0_ha_msg traffic" scenario. See the comment in ham_link_disconnected().
Todo:
"Server sends, client receives" scenario ==> client crashes.
Todo:
ham_say() entrypoint attributes in ham_entrypoint_replied().

Macro Definition Documentation

◆ HAM_CLIENT_EP_DEFAULT

#define HAM_CLIENT_EP_DEFAULT   "0@lo:12345:43:101"

Definition at line 62 of file ham.c.

◆ HAM_SERVER_EP_DEFAULT

#define HAM_SERVER_EP_DEFAULT   "0@lo:12345:43:100"

Definition at line 61 of file ham.c.

◆ HAM_SERVER_WAIT_DEFAULT

#define HAM_SERVER_WAIT_DEFAULT   0

Definition at line 63 of file ham.c.

◆ M0_TRACE_SUBSYSTEM

#define M0_TRACE_SUBSYSTEM   M0_TRACE_SUBSYS_HA

Definition at line 43 of file ham.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HAM_ID 

Definition at line 67 of file ham.c.

◆ ham_mode

enum ham_mode
Enumerator
HM_CONNECT 
HM_LISTEN 
HM_SELF_CHECK 

Definition at line 65 of file ham.c.

Function Documentation

◆ ha_msg_is_one_way()

static bool ha_msg_is_one_way ( const struct m0_ha_msg msg)
static
Todo:
Move to ha/msg.[hc].

Definition at line 149 of file ham.c.

Here is the caller graph for this function:

◆ ham_args_parse()

static int ham_args_parse ( struct ham_params params,
int  argc,
char *const *  argv 
)
static
Return values
0Success.
1Help message printed. The program should be terminated.
-ExxxError.

Definition at line 493 of file ham.c.

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

◆ ham_entrypoint_replied()

static void ham_entrypoint_replied ( struct m0_ha ha,
struct m0_ha_entrypoint_rep rep 
)
static

Handles "entrypoint reply received" event. Is executed by entrypoint client.

Definition at line 346 of file ham.c.

Here is the call graph for this function:

◆ ham_entrypoint_request()

static void ham_entrypoint_request ( struct m0_ha ha,
const struct m0_ha_entrypoint_req req,
const struct m0_uint128 req_id 
)
static

Handles "entrypoint request received" event. Is executed by entrypoint server.

Definition at line 319 of file ham.c.

Here is the call graph for this function:

◆ ham_fread_str()

static int ham_fread_str ( char *  dest,
size_t  size,
FILE *  src 
)
static
Returns
the number of bytes read or negative error code.

Definition at line 201 of file ham.c.

Here is the caller graph for this function:

◆ ham_help()

static void ham_help ( FILE *  stream,
char *  progname 
)
static

Definition at line 467 of file ham.c.

Here is the caller graph for this function:

◆ ham_link_absent()

static void ham_link_absent ( struct m0_ha ha,
const struct m0_uint128 req_id 
)
static

Definition at line 391 of file ham.c.

◆ ham_link_connected()

static void ham_link_connected ( struct m0_ha ha,
const struct m0_uint128 req_id,
struct m0_ha_link hl 
)
static

Is executed by entrypoint server.

Definition at line 375 of file ham.c.

Here is the call graph for this function:

◆ ham_link_disconnected()

static void ham_link_disconnected ( struct m0_ha ha,
struct m0_ha_link hl 
)
static

Definition at line 401 of file ham.c.

Here is the call graph for this function:

◆ ham_link_is_disconnecting()

static void ham_link_is_disconnecting ( struct m0_ha ha,
struct m0_ha_link hl 
)
static

Definition at line 396 of file ham.c.

Here is the call graph for this function:

◆ ham_link_reused()

static void ham_link_reused ( struct m0_ha ha,
const struct m0_uint128 req_id,
struct m0_ha_link hl 
)
static

Definition at line 385 of file ham.c.

◆ ham_maybe_set()

static void ham_maybe_set ( const char **  dest,
const char *  value 
)
static

Definition at line 567 of file ham.c.

Here is the caller graph for this function:

◆ ham_msg_is_delivered()

static void ham_msg_is_delivered ( struct m0_ha ha,
struct m0_ha_link hl,
uint64_t  tag 
)
static

Definition at line 363 of file ham.c.

Here is the call graph for this function:

◆ ham_msg_is_not_delivered()

static void ham_msg_is_not_delivered ( struct m0_ha ha,
struct m0_ha_link hl,
uint64_t  tag 
)
static

Definition at line 369 of file ham.c.

Here is the call graph for this function:

◆ ham_msg_received()

static void ham_msg_received ( struct m0_ha ha,
struct m0_ha_link hl,
struct m0_ha_msg msg,
uint64_t  tag 
)
static

Definition at line 352 of file ham.c.

Here is the call graph for this function:

◆ ham_params_check()

static int ham_params_check ( struct ham_params params)
static

Definition at line 574 of file ham.c.

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

◆ ham_rpc_ctx_fini()

static void ham_rpc_ctx_fini ( struct ham_rpc_ctx ctx)
static

Definition at line 266 of file ham.c.

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

◆ ham_rpc_ctx_init()

static void ham_rpc_ctx_init ( struct ham_rpc_ctx ctx,
const char *  local_endpoint,
const struct m0_fid local_process 
)
static

Definition at line 229 of file ham.c.

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

◆ ham_say()

static void ham_say ( const char *  format,
  ... 
)
static

Definition at line 160 of file ham.c.

Here is the caller graph for this function:

◆ ham_send()

static void ham_send ( struct m0_ha ha,
struct m0_ha_link hl,
const struct m0_ha_msg msg 
)
static

Definition at line 298 of file ham.c.

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

◆ ham_sighandler()

static void ham_sighandler ( int  signum)
static

Definition at line 437 of file ham.c.

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

◆ ham_sighandler_init()

static int ham_sighandler_init ( void  )
static

Definition at line 446 of file ham.c.

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

◆ ham_xcode_print()

static void ham_xcode_print ( const struct m0_xcode_obj x)
static

Definition at line 177 of file ham.c.

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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 602 of file ham.c.

Here is the call graph for this function:

◆ xcode_read_as()

static void* xcode_read_as ( const struct m0_xcode_type type,
const char *  str,
int *  rc 
)
static

Builds m0_xcode_obj from its string representation.

Note
If the call succeeds, the user is responsible for freeing the allocated memory with m0_xcode_free_obj().

Example:

{
struct m0_ha_msg *msg;
int rc;
msg = xcode_read_as(m0_ha_msg_xc, xcode_str, &rc);
if (rc == 0) {
// Use `msg'.
// ...
m0_xcode_free_obj(&M0_XCODE_OBJ(m0_ha_msg_xc, msg));
}
}
Precondition
src != NULL && *src != '\0'
Postcondition
rc == NULL || (retval == NULL ? *rc < 0 : *rc == 0)
See also
m0_xcode_read()
Todo:
XXX Move to xcode/xcode.[hc]. Use this function instead of m0_confstr_parse().

Definition at line 121 of file ham.c.

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

Variable Documentation

◆ g_msg

struct m0_ha_msg* g_msg
static

Definition at line 81 of file ham.c.

◆ g_params

struct ham_params g_params
static

◆ g_self_req_id

struct m0_uint128 g_self_req_id
static

Definition at line 82 of file ham.c.

◆ g_sem

struct m0_semaphore g_sem
static

Definition at line 80 of file ham.c.

◆ ham_ha_ops

const struct m0_ha_ops ham_ha_ops
static
Initial value:
= {
.hao_entrypoint_request = ham_entrypoint_request,
.hao_entrypoint_replied = ham_entrypoint_replied,
.hao_msg_received = ham_msg_received,
.hao_msg_is_delivered = ham_msg_is_delivered,
.hao_msg_is_not_delivered = ham_msg_is_not_delivered,
.hao_link_connected = ham_link_connected,
.hao_link_reused = ham_link_reused,
.hao_link_absent = ham_link_absent,
.hao_link_is_disconnecting = ham_link_is_disconnecting,
.hao_link_disconnected = ham_link_disconnected
}
static void ham_msg_is_delivered(struct m0_ha *ha, struct m0_ha_link *hl, uint64_t tag)
Definition: ham.c:363
static void ham_link_reused(struct m0_ha *ha, const struct m0_uint128 *req_id, struct m0_ha_link *hl)
Definition: ham.c:385
static void ham_msg_received(struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg, uint64_t tag)
Definition: ham.c:352
static void ham_link_connected(struct m0_ha *ha, const struct m0_uint128 *req_id, struct m0_ha_link *hl)
Definition: ham.c:375
static void ham_msg_is_not_delivered(struct m0_ha *ha, struct m0_ha_link *hl, uint64_t tag)
Definition: ham.c:369
static void ham_link_absent(struct m0_ha *ha, const struct m0_uint128 *req_id)
Definition: ham.c:391
static void ham_link_is_disconnecting(struct m0_ha *ha, struct m0_ha_link *hl)
Definition: ham.c:396
static void ham_link_disconnected(struct m0_ha *ha, struct m0_ha_link *hl)
Definition: ham.c:401
static void ham_entrypoint_request(struct m0_ha *ha, const struct m0_ha_entrypoint_req *req, const struct m0_uint128 *req_id)
Definition: ham.c:319
static void ham_entrypoint_replied(struct m0_ha *ha, struct m0_ha_entrypoint_rep *rep)
Definition: ham.c:346

Definition at line 419 of file ham.c.

◆ ham_self_check_msg_default

const struct m0_ha_msg ham_self_check_msg_default
static
Initial value:
= {
.hm_data = {
.hed_type = M0_HA_MSG_NVEC,
.u.hed_nvec = {
.hmnv_type = M0_HA_NVEC_SET,
.hmnv_id_of_get = 0,
.hmnv_ignore_same_state = false,
.hmnv_nr = 1,
.hmnv_arr = {
.hmna_arr = {
{
.no_id = M0_FID_TINIT(
'c', 1, 1),
.no_state = M0_NC_FAILED
}
}
}
}
}
}
#define M0_FID_TINIT(type, container, key)
Definition: fid.h:90

Definition at line 276 of file ham.c.