forked from lei.chen/myxce
save works
This commit is contained in:
parent
b1faeb94b6
commit
b748e30d20
35 changed files with 1247 additions and 2149 deletions
|
|
@ -3,8 +3,10 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "cluster.h"
|
||||
#include "qobj.h"
|
||||
#include "xce/cluster_def.h"
|
||||
#include "xce/types.h"
|
||||
#include "xstring.h"
|
||||
|
||||
void queue_fini(queue_t* q)
|
||||
{
|
||||
|
|
@ -15,12 +17,14 @@ void queue_fini(queue_t* q)
|
|||
|
||||
queue_t* create_queue(cluster_t* c, xce_queue_t* p)
|
||||
{
|
||||
queue_t q1;
|
||||
queue_t* q;
|
||||
|
||||
memcpy(&(q1.queue), p, sizeof(q1.queue));
|
||||
q = calloc(1, sizeof(*q));
|
||||
if (q == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
q = create_obj_by_typename(&(c->objmgr), "xqueue", &q1);
|
||||
q->queue = makeQueue(p);
|
||||
return q;
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +60,11 @@ int queue_ctrl(cluster_t* c, xce_queuectrl_t* ctrl)
|
|||
return -EINVAL;
|
||||
}
|
||||
TRACE("%s queue_ctrl queue %s", __func__, ctrl->queue);
|
||||
q = qmgr_lockq(&(c->qmgr), ctrl->queue, OBJREF_UPDATE);
|
||||
rc = key_find(c->qmgr, (void*)ctrl->queue, (void**)&q);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (q == NULL) {
|
||||
PERROR("qmgr_lockq");
|
||||
return -ENOENT;
|
||||
|
|
@ -64,28 +72,28 @@ int queue_ctrl(cluster_t* c, xce_queuectrl_t* ctrl)
|
|||
|
||||
switch (ctrl->action) {
|
||||
case QUEUE_OPEN:
|
||||
if (!(q->queue.status & QUEUE_STAT_CLOSED)) {
|
||||
if (!(q->queue->status & QUEUE_STAT_CLOSED)) {
|
||||
goto clean;
|
||||
}
|
||||
q->queue.status &= ~QUEUE_STAT_CLOSED;
|
||||
q->queue->status &= ~QUEUE_STAT_CLOSED;
|
||||
break;
|
||||
case QUEUE_CLOSE:
|
||||
if (q->queue.status & QUEUE_STAT_CLOSED) {
|
||||
if (q->queue->status & QUEUE_STAT_CLOSED) {
|
||||
goto clean;
|
||||
}
|
||||
q->queue.status |= QUEUE_STAT_CLOSED;
|
||||
q->queue->status |= QUEUE_STAT_CLOSED;
|
||||
break;
|
||||
case QUEUE_INACTIVE:
|
||||
if (q->queue.status & QUEUE_STAT_INACT_ADMIN) {
|
||||
if (q->queue->status & QUEUE_STAT_INACT_ADMIN) {
|
||||
goto clean;
|
||||
}
|
||||
q->queue.status |= QUEUE_STAT_INACT_ADMIN;
|
||||
q->queue->status |= QUEUE_STAT_INACT_ADMIN;
|
||||
break;
|
||||
case QUEUE_ACTIVE:
|
||||
if (!(q->queue.status & QUEUE_STAT_INACT_ADMIN)) {
|
||||
if (!(q->queue->status & QUEUE_STAT_INACT_ADMIN)) {
|
||||
goto clean;
|
||||
}
|
||||
q->queue.status &= ~QUEUE_STAT_INACT_ADMIN;
|
||||
q->queue->status &= ~QUEUE_STAT_INACT_ADMIN;
|
||||
break;
|
||||
default:
|
||||
rc = -1;
|
||||
|
|
@ -117,7 +125,8 @@ int do_queuecontrol_op(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
|||
|
||||
int get_queue_exec(cluster_t* c, char* queue, char** pre_exec, char** post_exec)
|
||||
{
|
||||
queue_t* q = NULL;
|
||||
queue_t* q = NULL;
|
||||
int rc = 0;
|
||||
|
||||
TRACE("entering %s", __func__);
|
||||
|
||||
|
|
@ -128,22 +137,24 @@ int get_queue_exec(cluster_t* c, char* queue, char** pre_exec, char** post_exec)
|
|||
|
||||
TRACE("%s queue %s", __func__, queue);
|
||||
|
||||
q = qmgr_lockq(&(c->qmgr), queue, OBJREF_READ);
|
||||
rc = key_find(c->qmgr, (void*)queue, (void**)&q);
|
||||
if (rc < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (q == NULL) {
|
||||
PERROR("qmgr_lockq");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
if (q->queue.pre_exec != NULL) {
|
||||
*pre_exec = create_obj_by_typename(&(c->objmgr), "xstring",
|
||||
q->queue.pre_exec);
|
||||
if (q->queue->pre_exec != NULL) {
|
||||
*pre_exec = makeString(q->queue->pre_exec);
|
||||
} else {
|
||||
*pre_exec = NULL;
|
||||
}
|
||||
|
||||
if (q->queue.post_exec != NULL) {
|
||||
*post_exec = create_obj_by_typename(&(c->objmgr), "xstring",
|
||||
q->queue.post_exec);
|
||||
if (q->queue->post_exec != NULL) {
|
||||
*post_exec = makeString(q->queue->post_exec);
|
||||
} else {
|
||||
*post_exec = NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue