mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
error on call an invalid address
This commit is contained in:
@@ -147,6 +147,19 @@ expand_queue(struct message_queue *q) {
|
||||
q->queue = new_queue;
|
||||
}
|
||||
|
||||
static void
|
||||
_unlock(struct message_queue *q) {
|
||||
// this api use in push a unlock message, so the in_global flags must not be 0 ,
|
||||
// but the q is not exist in global queue.
|
||||
if (q->in_global == MQ_LOCKED) {
|
||||
skynet_globalmq_push(q);
|
||||
q->in_global = MQ_IN_GLOBAL;
|
||||
} else {
|
||||
assert(q->in_global == MQ_DISPATCHING);
|
||||
}
|
||||
q->lock_session = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_pushhead(struct message_queue *q, struct skynet_message *message) {
|
||||
int head = q->head - 1;
|
||||
@@ -162,15 +175,7 @@ _pushhead(struct message_queue *q, struct skynet_message *message) {
|
||||
q->queue[head] = *message;
|
||||
q->head = head;
|
||||
|
||||
// this api use in push a unlock message, so the in_global flags must not be 0 ,
|
||||
// but the q is not exist in global queue.
|
||||
if (q->in_global == MQ_LOCKED) {
|
||||
skynet_globalmq_push(q);
|
||||
q->in_global = MQ_IN_GLOBAL;
|
||||
} else {
|
||||
assert(q->in_global == MQ_DISPATCHING);
|
||||
}
|
||||
q->lock_session = 0;
|
||||
_unlock(q);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -211,6 +216,13 @@ skynet_mq_lock(struct message_queue *q, int session) {
|
||||
UNLOCK(q)
|
||||
}
|
||||
|
||||
void
|
||||
skynet_mq_unlock(struct message_queue *q) {
|
||||
LOCK(q)
|
||||
_unlock(q);
|
||||
UNLOCK(q)
|
||||
}
|
||||
|
||||
void
|
||||
skynet_mq_init() {
|
||||
struct global_queue *q = malloc(sizeof(*q));
|
||||
|
||||
@@ -24,6 +24,7 @@ uint32_t skynet_mq_handle(struct message_queue *);
|
||||
int skynet_mq_pop(struct message_queue *q, struct skynet_message *message);
|
||||
void skynet_mq_push(struct message_queue *q, struct skynet_message *message);
|
||||
void skynet_mq_lock(struct message_queue *q, int session);
|
||||
void skynet_mq_unlock(struct message_queue *q);
|
||||
|
||||
void skynet_mq_force_push(struct message_queue *q);
|
||||
void skynet_mq_pushglobal(struct message_queue *q);
|
||||
|
||||
@@ -384,6 +384,14 @@ skynet_command(struct skynet_context * context, const char * cmd , const char *
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp(cmd,"UNLOCK") == 0) {
|
||||
if (context->init == false) {
|
||||
return NULL;
|
||||
}
|
||||
skynet_mq_unlock(context->queue);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp(cmd,"REG") == 0) {
|
||||
if (param == NULL || param[0] == '\0') {
|
||||
sprintf(context->result, ":%x", context->handle);
|
||||
|
||||
Reference in New Issue
Block a user