mirror of https://github.com/yandex/odyssey.git
machinarium: detach fd from event loop during close and connect
This commit is contained in:
parent
edc5ed4f65
commit
b28c02d16d
|
@ -75,12 +75,18 @@ MACHINE_API int
|
||||||
machine_close(machine_io_t obj)
|
machine_close(machine_io_t obj)
|
||||||
{
|
{
|
||||||
mm_io_t *io = obj;
|
mm_io_t *io = obj;
|
||||||
/*mm_io_read_stop(io);*/
|
mm_t *machine = machine = io->machine;
|
||||||
if (io->fd == -1) {
|
if (io->fd == -1) {
|
||||||
mm_io_set_errno(io, EBADF);
|
mm_io_set_errno(io, EBADF);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
close(io->fd);
|
int rc;
|
||||||
|
rc = mm_loop_delete(&machine->loop, &io->handle);
|
||||||
|
if (rc == -1)
|
||||||
|
mm_io_set_errno(io, errno);
|
||||||
|
rc = close(io->fd);
|
||||||
|
if (rc == -1)
|
||||||
|
mm_io_set_errno(io, errno);
|
||||||
io->connected = 0;
|
io->connected = 0;
|
||||||
io->fd = -1;
|
io->fd = -1;
|
||||||
io->handle.fd = -1;
|
io->handle.fd = -1;
|
||||||
|
|
|
@ -109,6 +109,7 @@ mm_connect(mm_io_t *io, struct sockaddr *sa, uint64_t time_ms)
|
||||||
|
|
||||||
rc = io->connect_status;
|
rc = io->connect_status;
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
mm_loop_delete(&machine->loop, &io->handle);
|
||||||
mm_io_set_errno(io, rc);
|
mm_io_set_errno(io, rc);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue