From 8944edd649e74e4864f36d7293921385ba5ca2c7 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 26 Jun 2014 18:56:42 +0100 Subject: convert all frontends to scheduled fetch operation --- monkey/poll.c | 82 +++++++++++++++++++++++++---------------------------------- 1 file changed, 34 insertions(+), 48 deletions(-) (limited to 'monkey/poll.c') diff --git a/monkey/poll.c b/monkey/poll.c index 414d458bd..d5b49f059 100644 --- a/monkey/poll.c +++ b/monkey/poll.c @@ -22,7 +22,7 @@ #include "desktop/gui.h" #include "monkey/schedule.h" #include "monkey/browser.h" -#include "content/fetchers/curl.h" +#include "content/fetchers.h" #include "monkey/dispatch.h" #include "monkey/poll.h" @@ -90,58 +90,48 @@ monkey_prepare_input(void) void monkey_poll(bool active) { - CURLMcode code; fd_set read_fd_set, write_fd_set, exc_fd_set; int max_fd; GPollFD *fd_list[1000]; unsigned int fd_count = 0; bool block = true; - + + fetcher_fdset(&read_fd_set, &write_fd_set, &exc_fd_set, &max_fd); + for (int i = 0; i <= max_fd; i++) { + if (FD_ISSET(i, &read_fd_set)) { + GPollFD *fd = malloc(sizeof *fd); + fd->fd = i; + fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; + g_main_context_add_poll(0, fd, 0); + fd_list[fd_count++] = fd; + LOG(("Want to read %d", i)); + } + if (FD_ISSET(i, &write_fd_set)) { + GPollFD *fd = malloc(sizeof *fd); + fd->fd = i; + fd->events = G_IO_OUT | G_IO_ERR; + g_main_context_add_poll(0, fd, 0); + fd_list[fd_count++] = fd; + LOG(("Want to write %d", i)); + } + if (FD_ISSET(i, &exc_fd_set)) { + GPollFD *fd = malloc(sizeof *fd); + fd->fd = i; + fd->events = G_IO_ERR; + g_main_context_add_poll(0, fd, 0); + fd_list[fd_count++] = fd; + LOG(("Want to check %d", i)); + } + } + schedule_run(); - if (browser_reformat_pending) + if (browser_reformat_pending) { + monkey_window_process_reformats(); block = false; - - if (active) { - FD_ZERO(&read_fd_set); - FD_ZERO(&write_fd_set); - FD_ZERO(&exc_fd_set); - code = curl_multi_fdset(fetch_curl_multi, - &read_fd_set, - &write_fd_set, - &exc_fd_set, - &max_fd); - assert(code == CURLM_OK); - LOG(("maxfd from curl is %d", max_fd)); - for (int i = 0; i <= max_fd; i++) { - if (FD_ISSET(i, &read_fd_set)) { - GPollFD *fd = malloc(sizeof *fd); - fd->fd = i; - fd->events = G_IO_IN | G_IO_HUP | G_IO_ERR; - g_main_context_add_poll(0, fd, 0); - fd_list[fd_count++] = fd; - LOG(("Want to read %d", i)); - } - if (FD_ISSET(i, &write_fd_set)) { - GPollFD *fd = malloc(sizeof *fd); - fd->fd = i; - fd->events = G_IO_OUT | G_IO_ERR; - g_main_context_add_poll(0, fd, 0); - fd_list[fd_count++] = fd; - LOG(("Want to write %d", i)); - } - if (FD_ISSET(i, &exc_fd_set)) { - GPollFD *fd = malloc(sizeof *fd); - fd->fd = i; - fd->events = G_IO_ERR; - g_main_context_add_poll(0, fd, 0); - fd_list[fd_count++] = fd; - LOG(("Want to check %d", i)); - } - } } - - LOG(("Iterate %sactive %sblocking", active?"":"in", block?"":"non-")); + + LOG(("Iterate %sblocking", block?"":"non-")); if (block) { fprintf(stdout, "GENERIC POLL BLOCKING\n"); } @@ -152,9 +142,5 @@ monkey_poll(bool active) free(fd_list[i]); } - schedule_run(); - - if (browser_reformat_pending) - monkey_window_process_reformats(); } -- cgit v1.2.3