socket accept can do more than once for transfer

This commit is contained in:
云风
2013-08-22 18:58:52 +08:00
parent 4d8390ba66
commit 35b0f28fcc
2 changed files with 16 additions and 4 deletions

View File

@@ -498,12 +498,14 @@ accept_socket(struct socket_server *ss, struct request_accept *request, struct s
result->ud = 0;
result->data = NULL;
struct socket *s = &ss->slot[id % MAX_SOCKET];
if (s->type != SOCKET_TYPE_NOTACCEPT || s->id !=id) {
if (s->type == SOCKET_TYPE_INVALID || s->id !=id) {
return SOCKET_ERROR;
}
if (sp_add(ss->event_fd, s->fd, s)) {
s->type = SOCKET_TYPE_INVALID;
return SOCKET_ERROR;
if (s->type == SOCKET_TYPE_NOTACCEPT) {
if (sp_add(ss->event_fd, s->fd, s)) {
s->type = SOCKET_TYPE_INVALID;
return SOCKET_ERROR;
}
}
s->type = SOCKET_TYPE_CONNECTED;
s->opaque = request->opaque;