Commit Graph

165 Commits

Author SHA1 Message Date
Daniel Silverstone
d196dee05b llcache: Use last_modified instead of date
When sending an If-Modified-Since header we should use the
`last_modified` rather than the `date` property of the cached
object in order to not incorrectly assume things have a modification
date when they do not.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2019-08-02 12:22:30 +01:00
Daniel Silverstone
659c9161ee llcache: Abort cleanly if called back during shutdown
In order to help us debug shutting down with active fetches, this
will abort the process cleanly if we get a callback to an "active"
llcache handle after the abort process has actually killed them
all.  This can happen with deferred fetcher aborts in the cURL
fetcher.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
2019-06-15 21:13:09 +01:00
John-Mark Bell
c1dc4e61bd LLCache: validate max-age before use 2019-06-10 21:36:52 +00:00
John-Mark Bell
047c82cfce LLCache: use Cache-Control parser 2019-06-10 21:02:26 +00:00
Vincent Sanders
9893b05b08 use jmb suggested fix to cache-control header parse error 2019-06-10 21:58:46 +01:00
Vincent Sanders
e598dcd139 fix parsing of invalid syntax max-age value Cache-control header 2019-06-10 20:53:12 +01:00
Vincent Sanders
5f1defd4a7 fix size_t format specifiers 2018-08-18 23:44:15 +01:00
Vincent Sanders
92424b6946 refactor llcache header processing
refactor the header processing in the low level object cache to make
 cache control header processing more explicit.
2018-08-12 12:50:57 +01:00
John-Mark Bell
103c015784 HSTS: make llcache update policy on 3xx responses 2018-04-22 11:39:12 +00:00
John-Mark Bell
ec1936cc93 HSTS: prevent llcache being nice
If the server has defined a HSTS policy, then the user no longer
gets to click-through a garbage certificate. Additionally, if
the server has provided a HSTS policy, it should do TLS properly,
so don't permit client-driven TLS version downgrades in that case,
either.
2018-04-22 11:39:12 +00:00
John-Mark Bell
83f5332708 HSTS: teach llcache to update and enforce policy. 2018-04-22 11:39:12 +00:00
John-Mark Bell
badc0d437a LLCache: correct typos/grammar/etc. 2018-04-22 11:16:26 +00:00
Michael Drake
e418416c77 Squash remaining GCC7 -Wimplicit-fallthrough warnings. 2017-10-23 09:46:02 +01:00
Vincent Sanders
8b88e44090 fix time_t logging 2017-09-08 20:47:22 +01:00
Daniel Silverstone
50cbb98941 Hopefully quash warning about time_t formatting on openbsd 2017-09-08 19:38:11 +01:00
Vincent Sanders
72e6050eb3 add low level cache category and use it 2017-09-06 18:45:35 +01:00
Vincent Sanders
75018632a9 Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done

@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 18:45:27 +01:00
Vincent Sanders
6075feb487 create netsurf inttypes header to have portable integer formatting macros 2017-01-21 14:20:55 +00:00
Vincent Sanders
b3042f6c1f fix spelling in low level cache code 2016-11-20 15:38:14 +00:00
Vincent Sanders
b939afe3fc Allow certificate verification user prompt creation to return errors 2016-07-31 13:25:20 +01:00
Vincent Sanders
fe7eb85614 move misc header into public API 2016-05-30 11:23:32 +01:00
Vincent Sanders
0bc5d2ca4c create date and time to seconds since epoch processing utility function
currently NetSurf uses curl_getdate to convert textural date and time
strings into seconds since epoch. It is betetr to move this
functionality to a utility function so curl_getdate can easily be
replaced if required.
2016-04-16 23:50:22 +01:00
Vincent Sanders
33c7df0c40 complete the rename of the gui browser table
When the operations tables were created the browser table was renamed
to miscellaneous except the actual rename patch was never applied,
this fixes that situation.
2016-04-16 23:50:21 +01:00
Vincent Sanders
d15ab96a51 Fix size_t printf formatting
The printf formatting for size_t is set in c99 as %zu but in windows
it is %Iu this is solved by adding and inttypes style PRI macro for size_t

This also uses this macro everywhere size_t is formatted.
2016-03-17 22:00:54 +00:00
Michael Drake
255361a885 Log the cache limit along side size, after clean. 2016-02-08 11:48:33 +00:00
Michael Drake
fc2d766bff Style: Wrap some long lines. 2016-02-08 11:38:41 +00:00
Michael Drake
63fb2cbdc1 Add URL to llcache object destruction logging. 2016-02-08 11:27:04 +00:00
Michael Drake
e5ddbd3934 Remove unused variable. 2015-12-20 12:12:36 +00:00
Daniel Silverstone
4d1ef3bac4 Add support for retrying timed-out cURL fetches.
This is an attempt to amelioriate the situation found in #2384 where
we see the cURL connect() failing to complete.  Based on the pcap
from the bug log, we believe that RISC OS is likely failing to signal
the completion of the connection to cURL.  As such, cURL times out.

This change permits retries of timed out connections in the hope that
a fresh socket FD might subsequently function correctly.  The defaults
chosen mean that the previous behaviour of 30 seconds before timeout
is reported will remain the same, but in that time we will make 3 separate
attempts to connect the socket.
2015-11-10 21:51:54 +00:00
Vincent Sanders
73e45ff024 Fix error reporting from fetch_start
Any fetch start error was being reported as "out of memory" which was
clearly insufficient. Foe example bad urls (reported was file:// with
a missing /) were causing a warn_user with out of memory. This change
now at least causes a "bad url" message.
2015-06-24 10:31:13 +01:00
Vincent Sanders
0d811963c1 fixup all the remaining logging macro callsites
The semantic patch tool appears to have missed some difficult to
reason about callsites which have now been manually cleaned up
2015-05-28 17:06:18 +01:00
Vincent Sanders
c105738fa3 Change LOG() macro to be varadic
This changes the LOG macro to be varadic removing the need for all
callsites to have double bracketing and allows for future improvement
on how we use the logging macros.

The callsites were changed with coccinelle and the changes checked by
hand. Compile tested for several frontends but not all.

A formatting annotation has also been added which allows the compiler
to check the parameters and types passed to the logging.
2015-05-28 16:08:46 +01:00
Michael Drake
8f1c9673d7 Fix format string type missmatches on 32-bit systems.
Use C99 inttypes header for format string macros.
2015-05-12 10:19:38 +01:00
Michael Drake
82237d7070 Avoid generating confusing warning.
Now the disc cache will be disabled silently if its too slow.
2015-05-12 10:01:06 +01:00
Vincent Sanders
37aad9c749 Improve the logge dinformation about written cache data 2015-05-08 15:42:49 +01:00
Vincent Sanders
2aef095f27 Ensure bandwidth minimum check is only performed when enough data has
been written.
2015-04-30 14:28:18 +01:00
Vincent Sanders
9927232a2d Improve metadata deserialisation to only update object on success
The low level cache deserialisation was leaving bad data in an low
level cache object in the error case. This fixes it so the object
state only gets modified on successful deserialisation of all the
metadata.
2015-01-28 22:39:39 +00:00
Vincent Sanders
5464dc7778 Ensure no division by zero occours if no time has ever been spent writing llcache 2015-01-03 15:13:40 +00:00
Vincent Sanders
6b645664fe add missing includes 2014-12-27 22:48:37 +00:00
Vincent Sanders
45f98ffd6e improve comments in low level cache and remove completed todo 2014-12-04 21:09:42 +00:00
Vincent Sanders
5bf4b3ff2b move the low bandwidth check to allow for an average over a much longer time 2014-12-03 20:13:10 +00:00
Vincent Sanders
57cd5c77b2 Use translated messgae for low bandwidth error 2014-12-02 10:03:27 +00:00
Vincent Sanders
c9ee49baa8 cope with backing store writeout making no progress 2014-12-01 11:32:33 +00:00
Vincent Sanders
ba5ade87b2 ensure the backing store write reports at least a minimal amount of time 2014-12-01 09:18:31 +00:00
Vincent Sanders
61ab2777da Improve writeout rescheduling if list of objects is completed quickly 2014-11-30 00:27:05 +00:00
Vincent Sanders
d08acbc5ae correctly calculate writeout bandwidth and properly impose limits 2014-11-29 23:57:15 +00:00
Vincent Sanders
6b2676d33f Improve llcache writeout stratagy 2014-11-28 19:17:42 +00:00
Vincent Sanders
8d51dd4879 update the backing store to allow for invalidating entries which have an allocation 2014-11-27 13:31:43 +00:00
Vincent Sanders
79d5b1bf3b stop using gettimeofday and use the monotonic time interface fron nsutils 2014-11-26 21:29:13 +00:00
Vincent Sanders
81417ae4a5 caclulate the total amount of time spent writing an object out
In order to calculate the writeout bandwidth we need to know how long
it took to write the data to peristant storage in addition to how much
was written.
2014-11-25 23:11:41 +00:00