mirror of https://github.com/yandex/odyssey.git
machinarium: support machine_accept() timeout
This commit is contained in:
parent
c932b593f7
commit
53bcf195b0
|
@ -161,8 +161,8 @@ machine_connected(machine_io_t);
|
||||||
MACHINE_API int
|
MACHINE_API int
|
||||||
machine_bind(machine_io_t, struct sockaddr*);
|
machine_bind(machine_io_t, struct sockaddr*);
|
||||||
|
|
||||||
MACHINE_API int
|
MACHINE_API machine_io_t
|
||||||
machine_accept(machine_io_t, int backlog, machine_io_t *client);
|
machine_accept(machine_io_t, int backlog, uint64_t time_ms);
|
||||||
|
|
||||||
MACHINE_API int
|
MACHINE_API int
|
||||||
machine_read(machine_io_t, char *buf, int size, uint64_t time_ms);
|
machine_read(machine_io_t, char *buf, int size, uint64_t time_ms);
|
||||||
|
|
|
@ -37,7 +37,7 @@ mm_accept_on_read_cb(mm_fd_t *handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mm_accept(mm_io_t *io, int backlog, machine_io_t *client)
|
mm_accept(mm_io_t *io, int backlog, machine_io_t *client, uint64_t time_ms)
|
||||||
{
|
{
|
||||||
mm_t *machine = machine = io->machine;
|
mm_t *machine = machine = io->machine;
|
||||||
mm_fiber_t *current = mm_scheduler_current(&io->machine->scheduler);
|
mm_fiber_t *current = mm_scheduler_current(&io->machine->scheduler);
|
||||||
|
@ -82,7 +82,7 @@ mm_accept(mm_io_t *io, int backlog, machine_io_t *client)
|
||||||
|
|
||||||
/* wait for timedout, cancel or execution status */
|
/* wait for timedout, cancel or execution status */
|
||||||
mm_timer_start(&machine->loop.clock, &io->accept_timer,
|
mm_timer_start(&machine->loop.clock, &io->accept_timer,
|
||||||
mm_accept_timer_cb, io, 0);
|
mm_accept_timer_cb, io, time_ms);
|
||||||
mm_call_begin(¤t->call, mm_accept_cancel_cb, io);
|
mm_call_begin(¤t->call, mm_accept_cancel_cb, io);
|
||||||
io->accept_fiber = current;
|
io->accept_fiber = current;
|
||||||
mm_scheduler_yield(&machine->scheduler);
|
mm_scheduler_yield(&machine->scheduler);
|
||||||
|
@ -121,14 +121,16 @@ mm_accept(mm_io_t *io, int backlog, machine_io_t *client)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MACHINE_API int
|
MACHINE_API machine_io_t
|
||||||
machine_accept(machine_io_t obj, int backlog, machine_io_t *client)
|
machine_accept(machine_io_t obj, int backlog, uint64_t time_ms)
|
||||||
{
|
{
|
||||||
mm_io_t *io = obj;
|
mm_io_t *io = obj;
|
||||||
|
machine_io_t client = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
rc = mm_accept(io, backlog, client);
|
rc = mm_accept(io, backlog, &client, time_ms);
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
return -1;
|
return NULL;
|
||||||
|
return client;
|
||||||
#if 0
|
#if 0
|
||||||
if (! io->tls_obj)
|
if (! io->tls_obj)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue