summaryrefslogtreecommitdiff
path: root/src/cache/handlers
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2024-01-27 20:39:25 -0500
committerAndrew Opalach <andrew@akon.city> 2024-01-27 20:39:25 -0500
commitb100eb175e0cfa59a15c4125f26ab5474c2347ec (patch)
treef1ee4f8bed5d3490ba5d70a6fc194f3206df8df4 /src/cache/handlers
parentfb1cbf546300d9f8efdf21c6ac66f7c2f1dfd4f3 (diff)
downloadcamu-b100eb175e0cfa59a15c4125f26ab5474c2347ec.tar.gz
camu-b100eb175e0cfa59a15c4125f26ab5474c2347ec.tar.bz2
camu-b100eb175e0cfa59a15c4125f26ab5474c2347ec.zip
wip
- Mostly work in the client Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/cache/handlers')
-rw-r--r--src/cache/handlers/http.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/cache/handlers/http.c b/src/cache/handlers/http.c
index dd3c8ac..97abf79 100644
--- a/src/cache/handlers/http.c
+++ b/src/cache/handlers/http.c
@@ -14,6 +14,19 @@ static bool handler_http_can_seek(struct cch_handler *handler)
return false;
}
+static void disable_waiters_internal(struct cch_handler_http *http)
+{
+ aki_mutex_lock(&http->mutex);
+ struct cch_handler_wait *wait;
+ al_array_foreach(http->handler.waits, i, wait) {
+ aki_mutex_lock(&wait->mutex);
+ wait->disabled = true;
+ aki_cond_signal(&wait->cond);
+ aki_mutex_unlock(&wait->mutex);
+ }
+ aki_mutex_unlock(&http->mutex);
+}
+
static size_t http_callback(void *userdata, u8 op, u8 *buf, s64 int0)
{
struct cch_handler_http *http = (struct cch_handler_http *)userdata;
@@ -24,8 +37,9 @@ 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.");
- break; // Unhandled.
+ break;
}
case AKI_HTTP_RESPONSE_CODE: {
al_log_debug("cache_handler_http", "HTTP %ld.", int0);
@@ -141,15 +155,7 @@ static bool handler_http_wait_for_range(struct cch_handler *handler, struct cch_
static void handler_http_free(struct cch_handler **handler)
{
struct cch_handler_http *http = (struct cch_handler_http *)*handler;
- aki_mutex_lock(&http->mutex);
- struct cch_handler_wait *wait;
- al_array_foreach(http->handler.waits, i, wait) {
- aki_mutex_lock(&wait->mutex);
- wait->disabled = true;
- aki_cond_signal(&wait->cond);
- aki_mutex_unlock(&wait->mutex);
- }
- aki_mutex_unlock(&http->mutex);
+ disable_waiters_internal(http);
camu_queue_push(http->queue, -1);
aki_signal_send(&http->signal);
aki_thread_join(&http->thread);