Motr  M0
reqh_service_internal.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2017-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 #pragma once
24 
25 #ifndef __MOTR_REQH_REQH_SERVICE_INTERNAL_H__
26 #define __MOTR_REQH_REQH_SERVICE_INTERNAL_H__
27 
28 #include "reqh/reqh_service.h"
29 
30 enum {
36 };
37 
38 enum {
39  /* Is set after `sc_rlink` initialisation. */
41  /*
42  * Is set when m0_reqh_service_connect() is called. Remains set
43  * after m0_reqh_service_disconnect().
44  */
47  /* Is set when rpc session can not be cancelled immediately. */
49  /* Is set when urgent link termination requested. */
51 };
52 
53 #define CTX_STATE(ctx) (ctx)->sc_sm.sm_state
54 
56 {
57  m0_sm_group_lock(&ctx->sc_sm_grp);
58 }
59 
61 {
62  m0_sm_group_unlock(&ctx->sc_sm_grp);
63 }
64 
65 static inline bool
67 {
68  return m0_sm_group_is_locked(&ctx->sc_sm_grp);
69 }
70 
71 static inline void
73 {
74  m0_sm_state_set(&ctx->sc_sm, state);
75 }
76 
77 static inline void
79 {
80  ctx->sc_conn_flags |= M0_BITS(flag);
81 }
82 
83 static inline void
85 {
86  ctx->sc_conn_flags &= ~M0_BITS(flag);
87 }
88 
89 static inline bool
91 {
92  return !!(ctx->sc_conn_flags & M0_BITS(flag));
93 }
94 
95 #endif /* __MOTR_REQH_REQH_SERVICE_INTERNAL_H__ */
96 
97 /*
98  * Local variables:
99  * c-indentation-style: "K&R"
100  * c-basic-offset: 8
101  * tab-width: 8
102  * fill-column: 80
103  * scroll-step: 1
104  * End:
105  */
static void reqh_service_ctx_state_move(struct m0_reqh_service_ctx *ctx, int state)
static void reqh_service_ctx_flag_clear(struct m0_reqh_service_ctx *ctx, int flag)
static bool reqh_service_ctx_sm_is_locked(const struct m0_reqh_service_ctx *ctx)
#define M0_BITS(...)
Definition: misc.h:236
static void reqh_service_ctx_sm_unlock(struct m0_reqh_service_ctx *ctx)
M0_INTERNAL void m0_sm_group_unlock(struct m0_sm_group *grp)
Definition: sm.c:96
static void reqh_service_ctx_flag_set(struct m0_reqh_service_ctx *ctx, int flag)
static bool reqh_service_ctx_flag_is_set(const struct m0_reqh_service_ctx *ctx, int flag)
void m0_sm_state_set(struct m0_sm *mach, int state)
Definition: sm.c:478
static void reqh_service_ctx_sm_lock(struct m0_reqh_service_ctx *ctx)
static bool flag
Definition: nucleus.c:266
M0_INTERNAL void m0_sm_group_lock(struct m0_sm_group *grp)
Definition: sm.c:83
Definition: nucleus.c:42
M0_INTERNAL bool m0_sm_group_is_locked(const struct m0_sm_group *grp)
Definition: sm.c:107