summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2014-06-26 18:56:42 +0100
committerVincent Sanders <vince@kyllikki.org>2014-06-26 19:05:59 +0100
commit8944edd649e74e4864f36d7293921385ba5ca2c7 (patch)
tree1a901e8323944bcee35b972328812ed559b87950 /monkey
parent1b7aa7ffe53843f072e3de5e28bdf06faa7980b9 (diff)
downloadnetsurf-8944edd649e74e4864f36d7293921385ba5ca2c7.tar.gz
netsurf-8944edd649e74e4864f36d7293921385ba5ca2c7.tar.bz2
convert all frontends to scheduled fetch operation
Diffstat (limited to 'monkey')
-rw-r--r--monkey/poll.c82
1 files changed, 34 insertions, 48 deletions
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();
}