MCPcopy Create free account
hub / github.com/dillo-browser/dillo / Cache_process_queue

Function Cache_process_queue

src/cache.c:1175–1357  ·  view source on GitHub ↗

* Update cache clients for a single cache-entry * Tasks: * - Set the client function (if not already set) * - Look if new data is available and pass it to client functions * - Remove clients when done * - Call redirect handler * * @return Cache entry, which may be NULL if it has been removed. * * TODO: Implement CA_Abort Op in client callback */

Source from the content-addressed store, hash-verified

1173 * TODO: Implement CA_Abort Op in client callback
1174 */
1175static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry)
1176{
1177 uint_t i;
1178 int st;
1179 const char *Type;
1180 Dstr *data;
1181 CacheClient_t *Client;
1182 DilloWeb *ClientWeb;
1183 BrowserWindow *Client_bw = NULL;
1184 static bool_t Busy = FALSE;
1185 bool_t AbortEntry = FALSE;
1186 bool_t OfferDownload = FALSE;
1187 bool_t TypeMismatch = FALSE;
1188
1189 if (Busy)
1190 MSG_ERR("FATAL!: >>>> Cache_process_queue Caught busy!!! <<<<\n");
1191 if (!(entry->Flags & CA_GotHeader))
1192 return entry;
1193 if (!(entry->Flags & CA_GotContentType)) {
1194 st = a_Misc_get_content_type_from_data(
1195 entry->Data->str, entry->Data->len, &Type);
1196 _MSG("Cache: detected Content-Type '%s'\n", Type);
1197 if (st == 0 || !(entry->Flags & CA_InProgress)) {
1198 if (a_Misc_content_type_check(entry->TypeHdr, Type) < 0) {
1199 MSG_HTTP("Content-Type '%s' doesn't match the real data.\n",
1200 entry->TypeHdr);
1201 TypeMismatch = TRUE;
1202 }
1203 entry->TypeDet = dStrdup(Type);
1204 entry->Flags |= CA_GotContentType;
1205 } else
1206 return entry; /* i.e., wait for more data */
1207 }
1208
1209 Busy = TRUE;
1210 for (i = 0; (Client = dList_nth_data(ClientQueue, i)); ++i) {
1211 if (Client->Url == entry->Url) {
1212 ClientWeb = Client->Web; /* It was a (void*) */
1213 Client_bw = ClientWeb->bw; /* 'bw' in a local var */
1214
1215 if (ClientWeb->flags & WEB_RootUrl) {
1216 if (!(entry->Flags & CA_MsgErased)) {
1217 /* clear the "expecting for reply..." message */
1218 a_UIcmd_set_msg(Client_bw, "");
1219 entry->Flags |= CA_MsgErased;
1220 }
1221 if (TypeMismatch) {
1222 a_UIcmd_set_msg(Client_bw,"HTTP warning: Content-Type '%s' "
1223 "doesn't match the real data.", entry->TypeHdr);
1224 OfferDownload = TRUE;
1225 }
1226 if (entry->Flags & CA_Redirect) {
1227 if (!Client->Callback) {
1228 Client->Callback = Cache_null_client;
1229 Client_bw->redirect_level++;
1230 }
1231 } else {
1232 Client_bw->redirect_level = 0;

Callers 3

Cache_finish_msgFunction · 0.85
a_Cache_process_dbufFunction · 0.85

Calls 15

dStrdupFunction · 0.85
dList_nth_dataFunction · 0.85
a_UIcmd_set_msgFunction · 0.85
a_Web_dispatch_by_typeFunction · 0.85
a_Bw_remove_clientFunction · 0.85
Cache_client_dequeueFunction · 0.85
Cache_dataFunction · 0.85
a_UIcmd_set_page_progFunction · 0.85

Tested by

no test coverage detected