mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 12:20:41 +00:00
Fix issue #109
This commit is contained in:
@@ -815,6 +815,22 @@ report_accept(struct socket_server *ss, struct socket *s, struct socket_message
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
clear_closed_event(struct socket_server *ss, struct socket_message * result, int type) {
|
||||||
|
if (type == SOCKET_CLOSE || type == SOCKET_ERROR) {
|
||||||
|
int id = result->id;
|
||||||
|
int i;
|
||||||
|
for (i=ss->event_index; i<ss->event_n; i++) {
|
||||||
|
struct event *e = &ss->ev[i];
|
||||||
|
struct socket *s = e->s;
|
||||||
|
if (s) {
|
||||||
|
if (s->type == SOCKET_TYPE_INVALID && s->id == id) {
|
||||||
|
e->s = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// return type
|
// return type
|
||||||
int
|
int
|
||||||
@@ -823,9 +839,10 @@ socket_server_poll(struct socket_server *ss, struct socket_message * result, int
|
|||||||
if (ss->checkctrl) {
|
if (ss->checkctrl) {
|
||||||
if (has_cmd(ss)) {
|
if (has_cmd(ss)) {
|
||||||
int type = ctrl_cmd(ss, result);
|
int type = ctrl_cmd(ss, result);
|
||||||
if (type != -1)
|
if (type != -1) {
|
||||||
|
clear_closed_event(ss, result, type);
|
||||||
return type;
|
return type;
|
||||||
else
|
} else
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
ss->checkctrl = 0;
|
ss->checkctrl = 0;
|
||||||
@@ -865,12 +882,14 @@ socket_server_poll(struct socket_server *ss, struct socket_message * result, int
|
|||||||
int type = send_buffer(ss, s, result);
|
int type = send_buffer(ss, s, result);
|
||||||
if (type == -1)
|
if (type == -1)
|
||||||
break;
|
break;
|
||||||
|
clear_closed_event(ss, result, type);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
if (e->read) {
|
if (e->read) {
|
||||||
int type = forward_message(ss, s, result);
|
int type = forward_message(ss, s, result);
|
||||||
if (type == -1)
|
if (type == -1)
|
||||||
break;
|
break;
|
||||||
|
clear_closed_event(ss, result, type);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user