~stacyharper/bonsai

512786499b04f4f135db16444e6004abf75e914d — Stacy Harper 4 months ago 680c389
Dont loop perpetually on the pipeout…
1 files changed, 8 insertions(+), 3 deletions(-)

M cmd/bonsaid/socket.ha
M cmd/bonsaid/socket.ha => cmd/bonsaid/socket.ha +8 -3
@@ 70,8 70,8 @@ fn bind(
			...
		},
		poll::pollfd {
			fd = wait_pipes.1,
			events = event::POLLOUT,
			fd = wait_pipes.0,
			events = event::POLLIN,
			...
		}
	]);


@@ 116,11 116,16 @@ fn dispatch(serv: *server) bool = {
			signal::read(serv.signalfd)!;
			return false;
		};
		if (serv.pollfd[2].revents & event::POLLOUT != 0) {
		if (serv.pollfd[2].revents & event::POLLIN != 0) {
			if (bonsai::sync_back_wait_child(&serv.state, false)) {
				bonsai::state_forward_available_transitions(&serv.state);
				bonsai::trigger_delay_transition(&serv.state);
			};

			let wait_pipes = serv.state.wait_pipes as (io::file, io::file);
			io::close(wait_pipes.0)!;
			io::close(wait_pipes.1)!;
			serv.state.wait_pipes = unix::pipe(unix::pipe_flag::NONBLOCK)!;
		};
		for (let i = POLLFD_RESERVED; i < len(serv.pollfd); i += 1) {
			dispatch_client(serv, &serv.clients[i - POLLFD_RESERVED]);