bugfix: dispatch all message in one socket message

This commit is contained in:
云风
2013-08-26 14:25:42 +08:00
parent caaa8fcdbe
commit c826d4d246
2 changed files with 14 additions and 6 deletions

View File

@@ -183,10 +183,15 @@ _forward(struct gate *g, struct connection * c, int size) {
static void
dispatch_message(struct gate *g, struct connection *c, int id, void * data, int sz) {
int size = databuffer_push(&c->buffer,&g->mp, g->header_size, data, sz);
if (size > 0) {
_forward(g, c, size);
databuffer_reset(&c->buffer);
databuffer_push(&c->buffer,&g->mp, data, sz);
for (;;) {
int size = databuffer_readheader(&c->buffer, &g->mp, g->header_size);
if (size < 0) {
return;
} else if (size > 0) {
_forward(g, c, size);
databuffer_reset(&c->buffer);
}
}
}