From c6c4747a28816b3d8b9b4271b7cdb2ec84bc3715 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 15 Apr 2013 19:49:36 +0100 Subject: [PATCH 01/10] Schedule fetches so the frontend can wait for a scheduled event, rather than busy-looping. --- desktop/netsurf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 0b1cffe0a..5945b31a1 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -239,6 +239,10 @@ nserror netsurf_init(int *pargc, return ret; } +static void netsurf_fetch_callback(void *p) +{ + hlcache_poll(); +} /** * Gui NetSurf main loop. @@ -246,8 +250,9 @@ nserror netsurf_init(int *pargc, int netsurf_main_loop(void) { while (!netsurf_quit) { + if(fetch_active) + schedule(0, netsurf_fetch_callback, NULL); gui_poll(fetch_active); - hlcache_poll(); } return 0; From 6dcccd50517c7c62b9b6de9de4f3d3ec3fb09405 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 15 Apr 2013 19:51:40 +0100 Subject: [PATCH 02/10] test using amiga frontend --- amiga/gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amiga/gui.c b/amiga/gui.c index 998b169b0..d77bdfa48 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -2468,7 +2468,7 @@ void gui_poll(bool active) schedule_run checks every event, really they need to be sorted so only the first event needs to be run on each signal. */ - if(active) + if(0) { ami_handle_msg(); ami_handle_appmsg(); From 09af7a92aa12e3efa9646480566aac4a3aff6225 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 15 Apr 2013 19:52:44 +0100 Subject: [PATCH 03/10] fix warning --- desktop/netsurf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 5945b31a1..dd4000bc0 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -27,6 +27,7 @@ #include #include "utils/config.h" +#include "utils/schedule.h" #include "utils/utsname.h" #include "content/content_factory.h" #include "content/fetch.h" From 4b9fcb1ad0c250d4afe648ddf0219da692b013d9 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 15 Apr 2013 22:53:26 +0100 Subject: [PATCH 04/10] NetSurf appears to need to call hlcache_poll even if no fetches are active otherwise it sometimes gets stuck when fetching --- desktop/netsurf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/desktop/netsurf.c b/desktop/netsurf.c index dd4000bc0..120bda9e3 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -254,6 +254,7 @@ int netsurf_main_loop(void) if(fetch_active) schedule(0, netsurf_fetch_callback, NULL); gui_poll(fetch_active); + hlcache_poll(); } return 0; From 3b53d22260fd44ba69acacc61b2e1737ab6cc733 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 15 Apr 2013 23:02:32 +0100 Subject: [PATCH 05/10] Remove no-longer-needed code --- amiga/download.c | 13 ------------- amiga/gui.c | 20 +------------------- amiga/options.h | 3 --- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/amiga/download.c b/amiga/download.c index 16a50d8ff..b9b27ab9f 100644 --- a/amiga/download.c +++ b/amiga/download.c @@ -85,7 +85,6 @@ enum { }; int downloads_in_progress = 0; -BYTE original_task_priority = 0; struct gui_download_window *gui_download_window_create(download_context *ctx, struct gui_window *gui) @@ -186,13 +185,6 @@ struct gui_download_window *gui_download_window_create(download_context *ctx, dw->node = AddObject(window_list,AMINS_DLWINDOW); dw->node->objstruct = dw; - /* Set task priority to -1. - * NetSurf loops without Wait()ing when downloading, - * so this gives other tasks a bit more CPU time. */ - if(downloads_in_progress == 0) { - original_task_priority = SetTaskPri(FindTask(0), (BYTE)nsoption_int(download_task_pri)); - LOG(("Now running at priority %d (was %d)", nsoption_int(download_task_pri), original_task_priority)); - } downloads_in_progress++; return dw; @@ -282,12 +274,7 @@ void gui_download_window_done(struct gui_download_window *dw) SetComment(dw->fname, dw->url); if(dw->url) free(dw->url); - /* Set task priority back to what it was originally */ downloads_in_progress--; - if(downloads_in_progress == 0) { - BYTE taskpri = SetTaskPri(FindTask(0), original_task_priority); - LOG(("Now running at priority %d (was %d)", original_task_priority, taskpri)); - } DisposeObject(dw->objects[OID_MAIN]); DelObject(dw->node); diff --git a/amiga/gui.c b/amiga/gui.c index d77bdfa48..b6de46df9 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -2461,25 +2461,7 @@ printf("sig recvd %ld (%ld %ld %ld %ld %ld %ld)\n", signal, winsignal , appsig , void gui_poll(bool active) { - /* However, down here we are waiting for the user to do something or for a - scheduled event to kick in (the active variable seems to have no real - bearing on reality, but is supposed to indicate that NetSurf wants - control back ASAP, so we poll in that case). - schedule_run checks every event, really they need to be sorted so only - the first event needs to be run on each signal. */ - - if(0) - { - ami_handle_msg(); - ami_handle_appmsg(); - ami_handle_applib(); - ami_arexx_handle(); - schedule_run(TRUE); - } - else - { - ami_get_msg(); - } + ami_get_msg(); } void ami_change_tab(struct gui_window_2 *gwin, int direction) diff --git a/amiga/options.h b/amiga/options.h index de65c3ee0..822a7a3aa 100644 --- a/amiga/options.h +++ b/amiga/options.h @@ -48,7 +48,6 @@ char *arexx_shutdown; \ char *download_dir; \ bool download_notify; \ - int download_task_pri; \ bool faster_scroll; \ bool scale_quality; \ int dither_quality; \ @@ -115,7 +114,6 @@ .arexx_shutdown = NULL, \ .download_dir = NULL, \ .download_notify = false, \ - .download_task_pri = -1, \ .faster_scroll = true, \ .scale_quality = false, \ .dither_quality = 1, \ @@ -181,7 +179,6 @@ { "arexx_shutdown", OPTION_STRING, &nsoptions.arexx_shutdown }, \ { "download_dir", OPTION_STRING, &nsoptions.download_dir }, \ { "download_notify", OPTION_BOOL, &nsoptions.download_notify}, \ -{ "download_task_pri", OPTION_INTEGER, &nsoptions.download_task_pri}, \ { "faster_scroll", OPTION_BOOL, &nsoptions.faster_scroll}, \ { "scale_quality", OPTION_BOOL, &nsoptions.scale_quality}, \ { "dither_quality", OPTION_INTEGER, &nsoptions.dither_quality}, \ From 6090e36da2b659357ed1ac39b61dd2ba24c313f8 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 15 Apr 2013 23:40:08 +0100 Subject: [PATCH 06/10] Revert changes to netsurf.c --- desktop/netsurf.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 120bda9e3..0b1cffe0a 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -27,7 +27,6 @@ #include #include "utils/config.h" -#include "utils/schedule.h" #include "utils/utsname.h" #include "content/content_factory.h" #include "content/fetch.h" @@ -240,10 +239,6 @@ nserror netsurf_init(int *pargc, return ret; } -static void netsurf_fetch_callback(void *p) -{ - hlcache_poll(); -} /** * Gui NetSurf main loop. @@ -251,8 +246,6 @@ static void netsurf_fetch_callback(void *p) int netsurf_main_loop(void) { while (!netsurf_quit) { - if(fetch_active) - schedule(0, netsurf_fetch_callback, NULL); gui_poll(fetch_active); hlcache_poll(); } From dbebd4c1ce2aec767d9a2539cf185dcae2e147b8 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 15 Apr 2013 23:42:46 +0100 Subject: [PATCH 07/10] Schedule an immediate fetch poll if fetch is active --- amiga/gui.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/amiga/gui.c b/amiga/gui.c index b6de46df9..572a8d171 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -2459,8 +2459,14 @@ printf("sig recvd %ld (%ld %ld %ld %ld %ld %ld)\n", signal, winsignal , appsig , } } +static void ami_gui_fetch_callback(void *p) +{ + hlcache_poll(); +} + void gui_poll(bool active) { + if(active) schedule(0, ami_gui_fetch_callback, NULL); ami_get_msg(); } From 6557bae1a22a5522a363818a4808bf440e900014 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 15 Apr 2013 23:46:28 +0100 Subject: [PATCH 08/10] missing include --- amiga/gui.c | 1 + 1 file changed, 1 insertion(+) diff --git a/amiga/gui.c b/amiga/gui.c index 572a8d171..c3a163fe6 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -17,6 +17,7 @@ */ /* NetSurf core includes */ +#include "content/hlcache.h" #include "content/urldb.h" #include "css/utils.h" #include "desktop/browser_private.h" From bbb0f4c2b999d0f3730333f838a7df73e3775adc Mon Sep 17 00:00:00 2001 From: Chris Young Date: Mon, 15 Apr 2013 23:53:54 +0100 Subject: [PATCH 09/10] The scheduled callback function doesn't need to do anything, because NetSurf is going to call hlcache_poll anyway after it returns. --- amiga/gui.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/amiga/gui.c b/amiga/gui.c index c3a163fe6..fbe46d0b5 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -2462,7 +2462,11 @@ printf("sig recvd %ld (%ld %ld %ld %ld %ld %ld)\n", signal, winsignal , appsig , static void ami_gui_fetch_callback(void *p) { - hlcache_poll(); + /* This doesn't need to do anything - the scheduled event will + * send a message to trigger Wait() to return, thereby causing + * the event function to return, and NetSurf to call + * hlcache_poll() as part of the usual fetch/event loop. + */ } void gui_poll(bool active) From d167da308bd8e4b32f4c43de79161efa8d3b1435 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Tue, 16 Apr 2013 00:20:31 +0100 Subject: [PATCH 10/10] Use internal curl scheduled fetcher --- amiga/Makefile.target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amiga/Makefile.target b/amiga/Makefile.target index dc79479c5..29543c715 100644 --- a/amiga/Makefile.target +++ b/amiga/Makefile.target @@ -2,7 +2,7 @@ # Amiga target setup # ---------------------------------------------------------------------------- -CFLAGS += -std=c99 -Dnsamiga +CFLAGS += -std=c99 -Dnsamiga -DFETCHER_CURLL_SCHEDULED ifneq ($(SUBTARGET),os3) CFLAGS += -U__STRICT_ANSI__ -D__USE_INLINE__ -D__USE_BASETYPE__