From d438fcdcbe4b16d754d4346073038384c2dcb197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Wed, 2 Dec 1998 09:49:18 +0100 Subject: [PATCH] Invoke gc. Rev: src/gc.h:1.2 Rev: src/io.c:1.30 --- src/gc.h | 6 ++++-- src/io.c | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gc.h b/src/gc.h index 29829f29..abc6d15b 100644 --- a/src/gc.h +++ b/src/gc.h @@ -29,8 +29,10 @@ #include "lsh_types.h" void gc_register(struct lsh_object *o); -int gc(struct lsh_object *root); -int gc_maybe(struct lsh_object *root, int busy); +void gc_kill(struct lsh_object *o); + +void gc(struct lsh_object *root); +void gc_maybe(struct lsh_object *root, int busy); #if 0 void gc_mark(struct lsh_object *o); diff --git a/src/io.c b/src/io.c index 431b8cbc..f0b46a3e 100644 --- a/src/io.c +++ b/src/io.c @@ -46,12 +46,18 @@ #include "write_buffer.h" #include "xalloc.h" +/* If there's nothing to do for this amount of time (ms), do + * spontaneous gc. */ + +#define IDLE_TIME 100 + int io_iter(struct io_backend *b) { unsigned long nfds; /* FIXME: Should be nfds_t if that type is defined */ struct pollfd *fds; - int timeout; + /* FIXME: Callouts not implemented */ + /* int timeout; */ int res; nfds = 0; @@ -105,9 +111,6 @@ int io_iter(struct io_backend *b) * * NOTE: There might be some callouts left, but we won't wait for them. */ return 0; - - /* FIXME: Callouts not implemented */ - timeout = -1; fds = alloca(sizeof(struct pollfd) * nfds); @@ -142,8 +145,14 @@ int io_iter(struct io_backend *b) } } - res = poll(fds, nfds, timeout); + res = poll(fds, nfds, IDLE_TIME); + if (!res) + { + gc_maybe(&b->super, 0); + res = poll(fds, nfds, -1); + } + if (!res) { /* Callouts are not implemented */ -- GitLab