Lines Matching defs:res

57 child_cleanup(struct hast_resource *res)
60 proto_close(res->hr_ctrl);
61 res->hr_ctrl = NULL;
62 if (res->hr_event != NULL) {
63 proto_close(res->hr_event);
64 res->hr_event = NULL;
66 if (res->hr_conn != NULL) {
67 proto_close(res->hr_conn);
68 res->hr_conn = NULL;
70 res->hr_workerpid = 0;
75 uint8_t role, struct hast_resource *res, const char *name, unsigned int no)
83 if (res == NULL) {
87 TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) {
88 if (strcmp(res->hr_name, name) == 0)
91 if (res == NULL) {
96 PJDLOG_ASSERT(res != NULL);
99 nv_add_string(nvout, role2str(res->hr_role), "role%u", no);
102 if (role == res->hr_role)
105 pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role));
109 oldrole = res->hr_role;
110 res->hr_role = role;
111 pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role));
117 if (res->hr_workerpid != 0) {
118 if (kill(res->hr_workerpid, SIGTERM) == -1) {
121 (unsigned int)res->hr_workerpid);
122 } else if (waitpid(res->hr_workerpid, NULL, 0) !=
123 res->hr_workerpid) {
126 (unsigned int)res->hr_workerpid);
129 (unsigned int)res->hr_workerpid);
131 child_cleanup(res);
136 hastd_primary(res);
138 hook_exec(res->hr_exec, "role", res->hr_name, role2str(oldrole),
139 role2str(res->hr_role), NULL);
143 control_set_role(struct hast_resource *res, uint8_t role)
146 control_set_role_common(NULL, NULL, role, res, NULL, 0);
150 control_status_worker(struct hast_resource *res, struct nv *nvout,
170 if (hast_proto_send(res, res->hr_ctrl, cnvout, NULL, 0) == -1) {
179 if (hast_proto_recv_hdr(res->hr_ctrl, &cnvin) == -1) {
239 struct hast_resource *res, const char *name, unsigned int no)
249 if (res == NULL) {
250 TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) {
251 if (strcmp(res->hr_name, name) == 0)
254 if (res == NULL) {
259 PJDLOG_ASSERT(res != NULL);
260 nv_add_string(nvout, res->hr_provname, "provname%u", no);
261 nv_add_string(nvout, res->hr_localpath, "localpath%u", no);
262 nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr%u", no);
263 if (res->hr_sourceaddr[0] != '\0')
264 nv_add_string(nvout, res->hr_sourceaddr, "sourceaddr%u", no);
265 switch (res->hr_replication) {
279 nv_add_string(nvout, checksum_name(res->hr_checksum),
281 nv_add_string(nvout, compression_name(res->hr_compression),
283 nv_add_string(nvout, role2str(res->hr_role), "role%u", no);
284 nv_add_int32(nvout, res->hr_workerpid, "workerpid%u", no);
286 switch (res->hr_role) {
288 PJDLOG_ASSERT(res->hr_workerpid != 0);
291 if (res->hr_workerpid != 0)
302 control_status_worker(res, nvout, no);
366 struct hast_resource *res;
371 TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) {
374 control_set_role_common(cfg, nvout, role, res,
375 res->hr_name, ii++);
378 control_status(cfg, nvout, res, res->hr_name,
434 struct hast_resource *res = arg;
439 if (hast_proto_recv_hdr(res->hr_ctrl, &nvin) == -1) {
456 if (res->hr_remotein != NULL &&
457 res->hr_remoteout != NULL) {
462 nv_add_uint32(nvout, (uint32_t)res->hr_extentsize,
464 if (res->hr_role == HAST_ROLE_PRIMARY) {
466 (uint32_t)res->hr_keepdirty, "keepdirty");
468 (uint64_t)(activemap_ndirty(res->hr_amp) *
469 res->hr_extentsize), "dirty");
474 nv_add_uint64(nvout, res->hr_stat_read, "stat_read");
475 nv_add_uint64(nvout, res->hr_stat_write, "stat_write");
476 nv_add_uint64(nvout, res->hr_stat_delete,
478 nv_add_uint64(nvout, res->hr_stat_flush, "stat_flush");
479 nv_add_uint64(nvout, res->hr_stat_activemap_update,
481 nv_add_uint64(nvout, res->hr_stat_read_error,
483 nv_add_uint64(nvout, res->hr_stat_write_error +
484 res->hr_stat_activemap_write_error,
486 nv_add_uint64(nvout, res->hr_stat_delete_error,
488 nv_add_uint64(nvout, res->hr_stat_flush_error +
489 res->hr_stat_activemap_flush_error,
491 res->output_status_aux(nvout);
500 PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY);
501 primary_config_reload(res, nvin);
514 if (hast_proto_send(NULL, res->hr_ctrl, nvout, NULL, 0) == -1) {