static void readdir_callback(void *arg, struct nfs_client *client, READDIR3res *result) { READDIR3resok *resok = &result->READDIR3res_u.resok; struct http_cache_entry *ce; entry3 *last = NULL; err_t r; DEBUGPRINT ("readdir_callback came in\n"); assert(result != NULL && result->status == NFS3_OK); // FIXME: start here the measurement of file loading time last_ts = rdtsc(); // lwip_benchmark_control(1, BMS_START_REQUEST, 0, 0); // initiate a lookup for every entry for (entry3 *e = resok->reply.entries; e != NULL; e = e->nextentry) { ++cache_lookups_started; printf("Loading the file %s\n", e->name); ce = find_cacheline(e->name); ce->loading = 1; async_load_cache_entry(ce); e->name = NULL; // prevent freeing by XDR last = e; } /* more in the directory: repeat call */ if (!resok->reply.eof) { assert(last != NULL); r = nfs_readdir(client, nfs_root_fh, last->cookie, resok->cookieverf, readdir_callback, NULL); assert(r == ERR_OK); } else { readdir_complete = true; handle_cache_load_done(); } // free arguments xdr_READDIR3res(&xdr_free, result); }
READDIR3res * xdr_to_READDIR3res(char *msg, int len) { READDIR3res *res = NULL; XDR xdr; if(msg == NULL) return NULL; res = (READDIR3res *)mem_alloc(sizeof(READDIR3res)); if(res == NULL) return NULL; xdrmem_create(&xdr, msg, len, XDR_DECODE); res->READDIR3res_u.resok.reply.entries = NULL; if(!xdr_READDIR3res(&xdr, res)) { mem_free(res, sizeof(READDIR3res)); return NULL; } return res; }