summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2014-07-03 20:53:28 +0100
committerChris Young <chris@unsatisfactorysoftware.co.uk>2014-07-03 20:53:28 +0100
commiteccfdec27ac1f59c18374edfec517749b47bfff6 (patch)
treee5947a868643875ed9fe448bbc19217a2baadbac /amiga
parent074e6f3ec6f048a1861efec84bd91136761492fa (diff)
downloadnetsurf-eccfdec27ac1f59c18374edfec517749b47bfff6.tar.gz
netsurf-eccfdec27ac1f59c18374edfec517749b47bfff6.tar.bz2
Wait for network activity instead of polling.
Diffstat (limited to 'amiga')
-rw-r--r--amiga/gui.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/amiga/gui.c b/amiga/gui.c
index 6b02cac4f..f41ac5305 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -18,6 +18,7 @@
/* NetSurf core includes */
#include "content/backing_store.h"
+#include "content/fetchers.h"
#include "content/fetchers/resource.h"
#include "content/urldb.h"
#include "css/utils.h"
@@ -2462,15 +2463,36 @@ void ami_get_msg(void)
ULONG appsig = 1L << appport->mp_SigBit;
ULONG schedulesig = 1L << msgport->mp_SigBit;
ULONG ctrlcsig = SIGBREAKF_CTRL_C;
- ULONG signal;
+ uint32 signal = 0;
+ fd_set read_fd_set, write_fd_set, except_fd_set;
+ int max_fd = -1;
struct TimerRequest *timermsg = NULL;
struct MsgPort *printmsgport = ami_print_get_msgport();
ULONG printsig = 0;
ULONG helpsignal = ami_help_signal();
if(printmsgport) printsig = 1L << printmsgport->mp_SigBit;
- ULONG signalmask = winsignal | appsig | schedulesig | rxsig | printsig | applibsig | ctrlcsig | helpsignal;
-
- signal = Wait(signalmask);
+ uint32 signalmask = winsignal | appsig | schedulesig | rxsig |
+ printsig | applibsig | helpsignal;
+
+ if ((fetcher_fdset(&read_fd_set, &write_fd_set, &except_fd_set, &max_fd) == NSERROR_OK) &&
+ (max_fd != -1)) {
+ /* max_fd is the highest fd in use, but waitselect() needs to know how many
+ * are in use, so we add 1. */
+ int ws = waitselect(max_fd + 1, &read_fd_set, &write_fd_set, &except_fd_set,
+ NULL, (unsigned int *)&signalmask);
+ signal = signalmask;
+
+ /* \todo Fix Ctrl-C handling.
+ * WaitSelect() from bsdsocket.library returns -1 if the task was signalled
+ * with a Ctrl-C. waitselect() from newlib.library does not - instead
+ * the task terminates (rather than be signalled) when it receives a Ctrl-C.
+ * Adding the Ctrl-C signal to our user signal mask causes a Ctrl-C to occur
+ * immediately. */
+ } else {
+ /* If fetcher_fdset fails or no network activity, do it the old fashioned way. */
+ signalmask |= ctrlcsig;
+ signal = Wait(signalmask);
+ }
if(signal & winsignal)
ami_handle_msg();