Fixup the event loop so network activity still runs when there is no UI events.

This commit is contained in:
Adrien Destugues
2012-11-08 21:25:16 +00:00
parent 5421dc0f05
commit f399b7e4b0

View File

@@ -100,7 +100,7 @@ index 79dea4e..563f431 100644
return false;
}
diff --git a/beos/gui.cpp b/beos/gui.cpp
index b275616..d951c6c 100644
index b275616..c8ff5c2 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -450,7 +450,6 @@ static void gui_init2(int argc, char** argv)
@@ -186,7 +186,47 @@ index b275616..d951c6c 100644
#endif
#endif
@@ -751,31 +749,6 @@ void gui_quit(void)
@@ -689,14 +687,16 @@ void gui_poll(bool active)
unsigned int fd_count = 0;
bool block = true;
+ schedule_run();
+
if (browser_reformat_pending)
block = false;
- FD_ZERO(&read_fd_set);
- FD_ZERO(&write_fd_set);
- FD_ZERO(&exc_fd_set);
-
if (active) {
+ block = false; // there is network activity going on
+ 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,
@@ -709,7 +709,8 @@ void gui_poll(bool active)
FD_SET(sEventPipe[0], &read_fd_set);
max_fd = MAX(max_fd, sEventPipe[0] + 1);
-
+ // earliest_callback_timeout is set by the scheduler and tells us when the
+ // next UI event should happen.
bigtime_t next_schedule = earliest_callback_timeout - system_time();
if (!block)
next_schedule = 0LL; // now
@@ -730,8 +731,6 @@ void gui_poll(bool active)
nsbeos_dispatch_event(message);
}
- schedule_run();
-
if (browser_reformat_pending)
nsbeos_window_process_reformats();
}
@@ -751,31 +750,6 @@ void gui_quit(void)
}
@@ -679,6 +719,24 @@ index ae78391..bd13230 100644
};
diff --git a/beos/schedule.cpp b/beos/schedule.cpp
index 3f82235..2499159 100644
--- a/beos/schedule.cpp
+++ b/beos/schedule.cpp
@@ -104,11 +104,12 @@ bool
schedule_run(void)
{
LOG(("schedule_run()"));
+
+ earliest_callback_timeout = B_INFINITE_TIMEOUT;
if (callbacks == NULL)
return false; /* Nothing to do */
bigtime_t now = system_time();
- earliest_callback_timeout = B_INFINITE_TIMEOUT;
int32 i;
LOG(("Checking %ld callbacks to for deadline.", this_run->CountItems()));
diff --git a/beos/window.cpp b/beos/window.cpp
index 253b5d1..729d7b1 100644
--- a/beos/window.cpp