summaryrefslogtreecommitdiff
path: root/src/cache/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache/handlers')
-rw-r--r--src/cache/handlers/http.c11
-rw-r--r--src/cache/handlers/http.h1
2 files changed, 8 insertions, 4 deletions
diff --git a/src/cache/handlers/http.c b/src/cache/handlers/http.c
index 97abf79..789b247 100644
--- a/src/cache/handlers/http.c
+++ b/src/cache/handlers/http.c
@@ -6,7 +6,7 @@
#include "http.h"
-#define USER_AGENT al_str_c("Mozilla/5.0 (X11; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0")
+#define USER_AGENT al_str_c("Mozilla/5.0 (Windows NT 10.0; rv:122.0) Gecko/20100101 Firefox/122.0")
static bool handler_http_can_seek(struct cch_handler *handler)
{
@@ -17,6 +17,8 @@ static bool handler_http_can_seek(struct cch_handler *handler)
static void disable_waiters_internal(struct cch_handler_http *http)
{
aki_mutex_lock(&http->mutex);
+ // Don't allow any further waits.
+ http->disabled = true;
struct cch_handler_wait *wait;
al_array_foreach(http->handler.waits, i, wait) {
aki_mutex_lock(&wait->mutex);
@@ -37,8 +39,8 @@ static size_t http_callback(void *userdata, u8 op, u8 *buf, s64 int0)
break;
}
case AKI_HTTP_ERROR: {
- disable_waiters_internal(http); // TODO: Untested.
al_log_debug("cache_handler_http", "Error.");
+ disable_waiters_internal(http);
break;
}
case AKI_HTTP_RESPONSE_CODE: {
@@ -123,8 +125,8 @@ static bool handler_http_wait_for_range(struct cch_handler *handler, struct cch_
{
struct cch_handler_http *http = (struct cch_handler_http *)handler;
aki_mutex_lock(&http->mutex);
- bool canceled = false;
- if (cch_entry_get_size(http->handler.entry) < 0 || http->pointer < wait->end) {
+ bool canceled = http->disabled;
+ if (!canceled && (cch_entry_get_size(http->handler.entry) < 0 || http->pointer < wait->end)) {
aki_mutex_lock(&wait->mutex);
if (!wait->disabled) {
al_array_push(http->handler.waits, wait);
@@ -201,6 +203,7 @@ struct cch_entry *cch_handler_http_create(str *url)
struct cch_handler_http *http = (struct cch_handler_http *)entry->handler;
al_str_clone(&http->url, url);
http->pointer = 0;
+ http->disabled = false;
al_array_init(http->requests);
camu_queue_init(http->queue);
aki_event_loop_init(&http->loop);
diff --git a/src/cache/handlers/http.h b/src/cache/handlers/http.h
index f79a39a..e8fb2e0 100644
--- a/src/cache/handlers/http.h
+++ b/src/cache/handlers/http.h
@@ -13,6 +13,7 @@ struct cch_handler_http {
struct cch_handler handler;
off_t pointer;
str url;
+ bool disabled;
array(struct aki_http) requests;
queue(s32) queue;
struct aki_event_loop loop;