Motr  M0
rpc_helpers.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #include "reqh/reqh.h"
24 #include "reqh/reqh_service.h"
25 #include "rpc/rpc.h"
26 #include "ut/ut.h"
27 
28 static struct m0_reqh g_reqh;
29 static struct m0_net_domain g_net_dom;
31 
33  const struct m0_reqh_service_type *type)
34 {
35  int rc;
36 
38  if (rc != 0)
39  return rc;
42  return 0;
43 }
44 
45 /* XXX Code duplication! See m0_ha_ut_rpc_ctx_init(). */
47  struct m0_net_xprt *xprt,
48  const char *ep_addr)
49 {
50  enum { NR_TMS = 1 };
51  int rc;
52 
53  M0_SET0(&g_reqh);
57  if (rc != 0)
58  return rc;
59 
63  NR_TMS),
64  NR_TMS);
65  if (rc != 0)
66  goto net;
67 
69  .rhia_dtm = (void *)1,
70  .rhia_mdstore = (void *)1,
71  .rhia_fid = &g_process_fid,
72  );
73  if (rc != 0)
74  goto buf_pool;
76 
81  if (rc == 0) {
82  M0_POST(mach->rm_tm.ntm_dom->nd_xprt == xprt);
83  return 0;
84  }
85 buf_pool:
87 net:
89  return rc;
90 }
91 
92 /* XXX Code duplication! See m0_ha_ut_rpc_ctx_fini(). */
93 M0_INTERNAL void m0_ut_rpc_machine_stop(struct m0_rpc_machine *mach)
94 {
101 }
void m0_rpc_machine_fini(struct m0_rpc_machine *machine)
Definition: rpc_machine.c:233
M0_INTERNAL int m0_reqh_service_start(struct m0_reqh_service *service)
Definition: reqh_service.c:343
M0_INTERNAL void m0_reqh_services_terminate(struct m0_reqh *reqh)
Definition: reqh.c:675
void m0_net_domain_fini(struct m0_net_domain *dom)
Definition: domain.c:71
#define NULL
Definition: misc.h:38
static const char * ep_addr
Definition: rpc_machine.c:35
#define M0_REQH_INIT(reqh,...)
Definition: reqh.h:262
static struct m0_net_domain g_net_dom
Definition: rpc_helpers.c:29
M0_INTERNAL int m0_ut_rpc_machine_start(struct m0_rpc_machine *mach, struct m0_net_xprt *xprt, const char *ep_addr)
Definition: rpc_helpers.c:46
static struct m0_addb2_mach * mach
Definition: storage.c:42
#define M0_SET0(obj)
Definition: misc.h:64
M0_INTERNAL void m0_reqh_fini(struct m0_reqh *reqh)
Definition: reqh.c:320
M0_INTERNAL void m0_reqh_shutdown_wait(struct m0_reqh *reqh)
Definition: reqh.c:647
M0_INTERNAL int m0_rpc_net_buffer_pool_setup(struct m0_net_domain *ndom, struct m0_net_buffer_pool *app_pool, uint32_t bufs_nr, uint32_t tm_nr)
Definition: rpc.c:229
M0_INTERNAL uint32_t m0_rpc_bufs_nr(uint32_t len, uint32_t tms_nr)
Definition: rpc.c:271
M0_INTERNAL int m0_rpc_machine_init(struct m0_rpc_machine *machine, struct m0_net_domain *net_dom, const char *ep_addr, struct m0_reqh *reqh, struct m0_net_buffer_pool *receive_pool, uint32_t colour, m0_bcount_t msg_size, uint32_t queue_len)
Definition: rpc_machine.c:123
#define M0_POST(cond)
static struct m0_reqh g_reqh
Definition: rpc_helpers.c:28
M0_INTERNAL int m0_reqh_service_allocate(struct m0_reqh_service **out, const struct m0_reqh_service_type *stype, struct m0_reqh_context *rctx)
Definition: reqh_service.c:185
Definition: reqh.h:94
M0_INTERNAL void m0_reqh_service_init(struct m0_reqh_service *service, struct m0_reqh *reqh, const struct m0_fid *fid)
Definition: reqh_service.c:428
M0_INTERNAL void m0_reqh_start(struct m0_reqh *reqh)
Definition: reqh.c:711
M0_INTERNAL int m0_ut_rpc_service_start(struct m0_reqh_service **service, const struct m0_reqh_service_type *type)
Definition: rpc_helpers.c:32
int m0_net_domain_init(struct m0_net_domain *dom, const struct m0_net_xprt *xprt)
Definition: domain.c:36
static struct m0_net_buffer_pool g_buf_pool
Definition: rpc_helpers.c:30
M0_INTERNAL void m0_ut_rpc_machine_stop(struct m0_rpc_machine *mach)
Definition: rpc_helpers.c:93
static struct m0_addb2_net * net
Definition: net.c:27
static struct m0_net_buffer_pool * buf_pool
Definition: bulkio_ut.c:261
int type
Definition: dir.c:1031
struct m0_net_xprt * xprt
Definition: module.c:61
void m0_rpc_net_buffer_pool_cleanup(struct m0_net_buffer_pool *app_pool)
Definition: rpc.c:264
static struct m0_reqh_service * service[REQH_IN_UT_MAX]
Definition: long_lock_ut.c:46
int32_t rc
Definition: trigger_fop.h:47
struct m0_fid g_process_fid
Definition: ut.c:689