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
0043 #include <ndebug.h>
0044 #include <atmi.h>
0045 #include <atmi_int.h>
0046 #include <typed_buf.h>
0047 #include <ndrstandard.h>
0048 #include <ubf.h>
0049 #include <Exfields.h>
0050 #include <Excompat.h>
0051 #include <ubfutil.h>
0052 #include <sys_unix.h>
0053
0054 #include "tpadmsv.h"
0055 #include "expr.h"
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 typedef struct
0066 {
0067 char lmid[MAXTIDENT+1];
0068 char rqaddr[NDRX_MAX_Q_SIZE+1];
0069 char state[3+1];
0070 long nqueued;
0071 long rqid;
0072 } ndrx_adm_queue_t;
0073
0074
0075
0076
0077
0078 expublic ndrx_adm_elmap_t ndrx_G_queue_map[] =
0079 {
0080
0081 {TA_LMID, TPADM_EL(ndrx_adm_queue_t, lmid)}
0082 ,{TA_RQADDR, TPADM_EL(ndrx_adm_queue_t, rqaddr)}
0083 ,{TA_STATE, TPADM_EL(ndrx_adm_queue_t, state)}
0084 ,{TA_NQUEUED, TPADM_EL(ndrx_adm_queue_t, nqueued)}
0085
0086
0087
0088 ,{TA_RQID, TPADM_EL(ndrx_adm_queue_t, rqid)}
0089 ,{BBADFLDID}
0090 };
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102 expublic int ndrx_adm_queue_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags)
0103 {
0104 int ret = EXSUCCEED;
0105 string_list_t* qlist = NULL;
0106 string_list_t* elt = NULL;
0107 ndrx_adm_queue_t q;
0108 int idx = 0;
0109 struct mq_attr att;
0110
0111 cursnew->map = ndrx_G_queue_map;
0112
0113 ndrx_growlist_init(&cursnew->list, 100, sizeof(ndrx_adm_queue_t));
0114
0115 qlist = ndrx_sys_mqueue_list_make(G_atmi_env.qpath, &ret);
0116
0117 if (EXSUCCEED!=ret)
0118 {
0119 NDRX_LOG(log_error, "posix queue listing failed!");
0120 EXFAIL_OUT(ret);
0121 }
0122
0123
0124 LL_FOREACH(qlist,elt)
0125 {
0126
0127 if (0!=strncmp(elt->qname,
0128 G_atmi_env.qprefix_match, G_atmi_env.qprefix_match_len))
0129 {
0130 continue;
0131 }
0132
0133 memset(&q, 0, sizeof(q));
0134
0135 NDRX_STRCPY_SAFE(q.rqaddr, elt->qname);
0136
0137 #if defined(EX_USE_SYSVQ) || defined(EX_USE_SVAPOLL)
0138 q.rqid = ndrx_svqshm_get(q.rqaddr, 0, 0);
0139 #endif
0140
0141 snprintf(q.lmid, sizeof(q.lmid), "%ld", tpgetnodeid());
0142 NDRX_STRCPY_SAFE(q.state, "ACT");
0143
0144
0145 if (EXSUCCEED!=ndrx_get_q_attr(elt->qname, &att))
0146 {
0147
0148 continue;
0149 }
0150
0151 q.nqueued = att.mq_curmsgs;
0152
0153 if (EXSUCCEED!=ndrx_growlist_add(&cursnew->list, (void *)&q, idx))
0154 {
0155 NDRX_LOG(log_error, "Growlist on queue failed - out of memory?");
0156 EXFAIL_OUT(ret);
0157 }
0158
0159 idx++;
0160 }
0161
0162 out:
0163 if (NULL!=qlist)
0164 {
0165 ndrx_string_list_free(qlist);
0166 }
0167
0168 if (EXSUCCEED!=ret)
0169 {
0170 ndrx_growlist_free(&cursnew->list);
0171 }
0172
0173 return ret;
0174 }
0175
0176