mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 19:43:09 +00:00
socket accept can do more than once for transfer
This commit is contained in:
@@ -265,4 +265,14 @@ function socket.unlock(id)
|
||||
until skynet.wakeup(co)
|
||||
end
|
||||
|
||||
-- abandon use to forward socket id to other service
|
||||
-- you must call socket.accept(id) later in other service
|
||||
function socket.abandon(id)
|
||||
local s = socket_pool[id]
|
||||
if s and s.buffer then
|
||||
driver.clear(s.buffer)
|
||||
end
|
||||
socket_pool[id] = nil
|
||||
end
|
||||
|
||||
return socket
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user