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 <ndrx_config.h>
0035 #include <string.h>
0036 #include <stdio.h>
0037 #include <stdlib.h>
0038 #include <memory.h>
0039 #include <utlist.h>
0040
0041 #include <ndrstandard.h>
0042
0043 #include <ndebug.h>
0044 #include <userlog.h>
0045 #include <ndrxd.h>
0046 #include <ndrxdcmn.h>
0047
0048 #include "cmd_processor.h"
0049 #include <atmi_shm.h>
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 expublic void shm_psvc_reply_mod(command_reply_t *reply, size_t *send_size, mod_param_t *params)
0064 {
0065 command_reply_shm_psvc_t * shm_psvc_info = (command_reply_shm_psvc_t *)reply;
0066 shm_svcinfo_t *p_shm = (shm_svcinfo_t *)params->mod_param1;
0067 int cnt;
0068
0069 reply->msg_type = NDRXD_CALL_TYPE_PM_SHM_PSVC;
0070
0071 *send_size += (sizeof(command_reply_shm_psvc_t) - sizeof(command_reply_t));
0072
0073
0074 NDRX_STRCPY_SAFE(shm_psvc_info->service, p_shm->service);
0075 shm_psvc_info->flags = p_shm->flags;
0076 shm_psvc_info->slot = params->param2;
0077 shm_psvc_info->srvs = p_shm->srvs;
0078
0079 shm_psvc_info->csrvs = p_shm->csrvs;
0080 shm_psvc_info->resnr = p_shm->resnr;
0081 shm_psvc_info->totclustered = p_shm->totclustered;
0082 shm_psvc_info->cnodes_max_id = p_shm->cnodes_max_id;
0083 memcpy(shm_psvc_info->cnodes, p_shm->cnodes, sizeof(p_shm->cnodes));
0084
0085 shm_psvc_info->resids[0].resid = 0;
0086 shm_psvc_info->resids[0].cnt = 0;
0087
0088 #if defined(EX_USE_POLL) || defined(EX_USE_SYSVQ)
0089
0090 cnt = p_shm->resnr;
0091 if (cnt > CONF_NDRX_MAX_SRVIDS_XADMIN)
0092 {
0093 cnt = CONF_NDRX_MAX_SRVIDS_XADMIN;
0094 }
0095 memcpy(shm_psvc_info->resids, p_shm->resids, cnt*sizeof(p_shm->resids[0]));
0096 #endif
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 NDRX_LOG(log_debug, "magic: %ld", shm_psvc_info->rply.magic);
0107 }
0108
0109
0110
0111
0112
0113
0114
0115 exprivate void shm_psvc_progress(command_call_t * call, shm_svcinfo_t *p_shm, int slot)
0116 {
0117 int ret=EXSUCCEED;
0118 mod_param_t params;
0119
0120 NDRX_LOG(log_debug, "startup_progress enter");
0121 memset(¶ms, 0, sizeof(mod_param_t));
0122
0123
0124 params.mod_param1 = (void *)p_shm;
0125 params.param2 = slot;
0126
0127 if (EXSUCCEED!=simple_command_reply(call, ret, NDRXD_CALL_FLAGS_RSPHAVE_MORE,
0128
0129 ¶ms, shm_psvc_reply_mod, 0L, 0, NULL))
0130 {
0131 userlog("Failed to send progress back to [%s]", call->reply_queue);
0132 }
0133
0134
0135 NDRX_LOG(log_debug, "startup_progress exit");
0136 }
0137
0138
0139
0140
0141
0142
0143 expublic int cmd_shm_psvc (command_call_t * call, char *data, size_t len, int context)
0144 {
0145 int ret=EXSUCCEED;
0146 int i;
0147 shm_svcinfo_t *svcinfo = (shm_svcinfo_t *) G_svcinfo.mem;
0148
0149
0150 for (i=0; i<G_max_svcs; i++)
0151 {
0152
0153
0154
0155 if (SHM_SVCINFO_INDEX(svcinfo, i)->srvs>0 &&
0156 EXEOS!=SHM_SVCINFO_INDEX(svcinfo, i)->service[0])
0157 {
0158 shm_psvc_progress(call, SHM_SVCINFO_INDEX(svcinfo, i), i);
0159 }
0160 }
0161
0162 if (EXSUCCEED!=simple_command_reply(call, ret, 0L, NULL, NULL, 0L, 0, NULL))
0163 {
0164 userlog("Failed to send reply back to [%s]", call->reply_queue);
0165 }
0166 NDRX_LOG(log_warn, "cmd_shm_psvc returns with status %d", ret);
0167
0168 out:
0169 return ret;
0170 }
0171
0172