0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include <stdio.h>
0035 #include <stdlib.h>
0036 #include <string.h>
0037 #include <errno.h>
0038 #include <regex.h>
0039 #include <utlist.h>
0040 #include <unistd.h>
0041 #include <signal.h>
0042 #include <fcntl.h>
0043
0044 #include <ndebug.h>
0045 #include <atmi.h>
0046 #include <atmi_int.h>
0047 #include <typed_buf.h>
0048 #include <ndrstandard.h>
0049 #include <ubf.h>
0050 #include <Exfields.h>
0051 #include <Excompat.h>
0052 #include <ubfutil.h>
0053 #include <sys_unix.h>
0054 #include <gencall.h>
0055 #include <tpadm.h>
0056 #include "tpadmsv.h"
0057 #include "expr.h"
0058
0059
0060
0061
0062
0063
0064
0065
0066 expublic ndrx_adm_class_map_t ndrx_G_class_map[] =
0067 {
0068
0069 {NDRX_TA_CLASS_CLIENT, "CL", &ndrx_adm_client_get, ndrx_G_client_map}
0070 ,{NDRX_TA_CLASS_DOMAIN, "DM", &ndrx_adm_domain_get, ndrx_G_domain_map}
0071 ,{NDRX_TA_CLASS_MACHINE, "MA", &ndrx_adm_machine_get, ndrx_G_machine_map}
0072 ,{NDRX_TA_CLASS_QUEUE, "QU", &ndrx_adm_queue_get, ndrx_G_queue_map}
0073 ,{NDRX_TA_CLASS_SERVER, "SR", &ndrx_adm_server_get, ndrx_G_server_map}
0074 ,{NDRX_TA_CLASS_SERVICE, "SC", &ndrx_adm_service_get, ndrx_G_service_map}
0075 ,{NDRX_TA_CLASS_SVCGRP, "SG", &ndrx_adm_svcgrp_get, ndrx_G_svcgrp_map}
0076 ,{NDRX_TA_CLASS_BRCON, "BC", &ndrx_adm_brcon_get, ndrx_G_brcon_map}
0077 ,{NULL}
0078 };
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 expublic int ndrx_adm_list_call(int (*p_rsp_process)(command_reply_t *reply, size_t reply_len),
0091 int req_cmd, int resp_cmd, char *dst_qstr)
0092 {
0093 int ret = EXSUCCEED;
0094 command_call_t call;
0095 gencall_args_t call_args[NDRXD_COM_MAX+1];
0096
0097 struct mq_attr new_attr, org_attr;
0098
0099 memset(&call, 0, sizeof(call));
0100
0101 call_args[req_cmd].ndrxd_cmd = req_cmd;
0102 call_args[req_cmd].p_rsp_process = p_rsp_process;
0103 call_args[req_cmd].p_put_output = NULL;
0104 call_args[req_cmd].need_reply = EXTRUE;
0105
0106 call_args[resp_cmd].ndrxd_cmd = resp_cmd;
0107 call_args[resp_cmd].p_rsp_process = NULL;
0108 call_args[resp_cmd].p_put_output = NULL;
0109 call_args[resp_cmd].need_reply = EXFALSE;
0110
0111
0112 memset(&org_attr, 0, sizeof(org_attr));
0113
0114 if (EXSUCCEED!=ndrx_mq_getattr(ndrx_get_G_atmi_conf()->reply_q,
0115 &org_attr))
0116 {
0117 NDRX_LOG(log_error, "Failed to get attr: %s", strerror(errno));
0118 EXFAIL_OUT(ret);
0119 }
0120
0121 memcpy(&new_attr, &org_attr, sizeof(new_attr));
0122 new_attr.mq_flags &= ~O_NONBLOCK;
0123
0124 if (new_attr.mq_flags!=org_attr.mq_flags)
0125 {
0126 NDRX_LOG(log_debug, "change attr to blocked");
0127 if (EXSUCCEED!=ndrx_mq_setattr(ndrx_get_G_atmi_conf()->reply_q,
0128 &new_attr, NULL))
0129 {
0130 NDRX_LOG(log_error, "Failed to set new attr: %s", strerror(errno));
0131 EXFAIL_OUT(ret);
0132 }
0133 }
0134
0135
0136
0137 ret = cmd_generic_listcall(req_cmd, NDRXD_SRC_SERVER,
0138 NDRXD_CALL_TYPE_GENERIC,
0139 &call, sizeof(call),
0140 ndrx_get_G_atmi_conf()->reply_q_str,
0141 ndrx_get_G_atmi_conf()->reply_q,
0142 (mqd_t)EXFAIL,
0143 dst_qstr ,
0144 0, NULL,
0145 NULL,
0146 call_args,
0147 EXFALSE,
0148 0);
0149
0150
0151 if (new_attr.mq_flags!=org_attr.mq_flags)
0152 {
0153 NDRX_LOG(log_debug, "change attr to non blocked");
0154 if (EXSUCCEED!=ndrx_mq_setattr(ndrx_get_G_atmi_conf()->reply_q,
0155 &org_attr, NULL))
0156 {
0157 NDRX_LOG(log_error, "Failed to set old attr: %s", strerror(errno));
0158 EXFAIL_OUT(ret);
0159 }
0160 }
0161
0162 if (EXSUCCEED!=ret)
0163 {
0164 NDRX_LOG(log_error, "Failed to call `%s' to collect infos", dst_qstr);
0165 EXFAIL_OUT(ret);
0166 }
0167
0168 out:
0169 return ret;
0170 }
0171
0172
0173
0174
0175
0176
0177 expublic ndrx_adm_class_map_t *ndrx_adm_class_map_get(char *clazz)
0178 {
0179 int i;
0180
0181 for (i=0; NULL!=ndrx_G_class_map[i].clazz; i++)
0182 {
0183 if (0==strcmp(ndrx_G_class_map[i].clazz, clazz))
0184 {
0185 return &ndrx_G_class_map[i];
0186 }
0187 }
0188
0189 return NULL;
0190 }
0191
0192