13
#include "glusterd-conn-mgmt.h"
14
#include "glusterd-conn-helper.h"
15
#include "glusterd-utils.h"
16
#include "glusterd-messages.h"
19
glusterd_conn_init(glusterd_conn_t *conn, char *sockpath, time_t frame_timeout,
20
glusterd_conn_notify_t notify)
23
dict_t *options = NULL;
24
struct rpc_clnt *rpc = NULL;
25
xlator_t *this = THIS;
26
glusterd_svc_t *svc = NULL;
30
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_DICT_CREATE_FAIL, NULL);
34
svc = glusterd_conn_get_svc_object(conn);
36
gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_SVC_GET_FAIL,
37
"Failed to get the service");
41
ret = rpc_transport_unix_options_build(options, sockpath, frame_timeout);
45
ret = dict_set_int32_sizen(options, "transport.socket.ignore-enoent", 1);
47
gf_smsg(this->name, GF_LOG_ERROR, -ret, GD_MSG_DICT_SET_FAILED,
48
"Key=transport.socket.ignore-enoent", NULL);
53
rpc = rpc_clnt_new(options, this, (char *)svc->name, 16);
59
ret = rpc_clnt_register_notify(rpc, glusterd_conn_common_notify, conn);
63
ret = snprintf(conn->sockpath, sizeof(conn->sockpath), "%s", sockpath);
65
gf_smsg(this->name, GF_LOG_ERROR, errno, GD_MSG_COPY_FAIL, NULL);
71
conn->notify = notify;
85
glusterd_conn_term(glusterd_conn_t *conn)
87
rpc_clnt_unref(conn->rpc);
92
glusterd_conn_connect(glusterd_conn_t *conn)
94
return rpc_clnt_start(conn->rpc);
98
glusterd_conn_disconnect(glusterd_conn_t *conn)
100
rpc_clnt_disable(conn->rpc);
106
__glusterd_conn_common_notify(struct rpc_clnt *rpc, void *mydata,
107
rpc_clnt_event_t event, void *data)
109
glusterd_conn_t *conn = mydata;
116
return conn->notify(conn, event);
120
glusterd_conn_common_notify(struct rpc_clnt *rpc, void *mydata,
121
rpc_clnt_event_t event, void *data)
123
return glusterd_big_locked_notify(rpc, mydata, event, data,
124
__glusterd_conn_common_notify);
128
glusterd_conn_build_socket_filepath(char *rundir, uuid_t uuid, char *socketpath,
131
char sockfilepath[PATH_MAX] = {
135
snprintf(sockfilepath, sizeof(sockfilepath), "%s/run-%s", rundir,
138
glusterd_set_socket_filepath(sockfilepath, socketpath, len);
143
__glusterd_muxsvc_conn_common_notify(struct rpc_clnt *rpc, void *mydata,
144
rpc_clnt_event_t event, void *data)
146
glusterd_conf_t *conf = THIS->private;
147
glusterd_svc_proc_t *mux_proc = mydata;
155
if (event == RPC_CLNT_DESTROY) {
160
if (mux_proc->data) {
161
glusterd_volinfo_unref(mux_proc->data);
162
mux_proc->data = NULL;
167
pthread_mutex_lock(&conf->attach_lock);
169
ret = mux_proc->notify(mux_proc, event);
171
pthread_mutex_unlock(&conf->attach_lock);
177
glusterd_muxsvc_conn_common_notify(struct rpc_clnt *rpc, void *mydata,
178
rpc_clnt_event_t event, void *data)
180
return glusterd_big_locked_notify(rpc, mydata, event, data,
181
__glusterd_muxsvc_conn_common_notify);