bugfix: dispatch local global message queue

This commit is contained in:
Cloud Wu
2016-01-19 17:14:52 +08:00
parent 9747cf9aee
commit 1da92850a0

View File

@@ -347,13 +347,6 @@ dispatch_name_queue(struct harbor *h, struct keyvalue * node) {
uint32_t handle = node->value;
int harbor_id = handle >> HANDLE_REMOTE_SHIFT;
struct skynet_context * context = h->ctx;
if (harbor_id == 0) {
char tmp [GLOBALNAME_LENGTH+1];
memcpy(tmp, node->key, GLOBALNAME_LENGTH);
tmp[GLOBALNAME_LENGTH] = '\0';
skynet_error(context, "Invalid name (%s) handle :%08x",tmp,handle);
return;
}
struct slave *s = &h->s[harbor_id];
int fd = s->fd;
if (fd == 0) {
@@ -372,6 +365,16 @@ dispatch_name_queue(struct harbor *h, struct keyvalue * node) {
push_queue_msg(s->queue, m);
}
}
if (harbor_id == (h->slave >> HANDLE_REMOTE_SHIFT)) {
// the harbor_id is local
struct harbor_msg * m;
while ((m = pop_queue(s->queue)) != NULL) {
int type = m->header.destination >> HANDLE_REMOTE_SHIFT;
skynet_send(context, m->header.source, handle , type | PTYPE_TAG_DONTCOPY, m->header.session, m->buffer, m->size);
}
release_queue(s->queue);
s->queue = NULL;
}
}
return;
}