Added .gitignore so 'git status' will not show any *.so,*.o,Makefile and *~
[MonkeyD.git] / src / cache.c
blob8da099c28e6f6b89aa15123204dc431b89c3ba84
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
3 /* Monkey HTTP Daemon
4 * ------------------
5 * Copyright (C) 2001-2008, Eduardo Silva P.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Library General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include <pthread.h>
23 #include "iov.h"
24 #include "cache.h"
25 #include "request.h"
27 #include <stdio.h>
28 #include <stdlib.h>
30 /* This function is called when a thread is created */
31 void mk_cache_thread_init()
33 struct request_idx *cache_request_idx;
34 struct mk_iov *cache_iov_log;
35 struct mk_iov *cache_iov_header;
36 struct header_toc *cache_header_toc;
38 /* client request index */
39 cache_request_idx = mk_mem_malloc(sizeof(struct request_idx));
40 cache_request_idx->first = NULL;
41 cache_request_idx->last = NULL;
42 pthread_setspecific(request_index, (void *) cache_request_idx);
44 /* Cache iov log struct */
45 cache_iov_log = mk_iov_create(15, 0);
46 pthread_setspecific(mk_cache_iov_log, (void *) cache_iov_log);
48 /* Cache iov header struct */
49 cache_iov_header = mk_iov_create(45, 0);
50 pthread_setspecific(mk_cache_iov_header, (void *) cache_iov_header);
52 /* Cache header toc, monkey just search for MK_KNOWN_HEADERS
53 * in request
55 cache_header_toc = mk_mem_malloc_z(sizeof(struct header_toc) *
56 MK_KNOWN_HEADERS);
57 pthread_setspecific(mk_cache_header_toc, (void *) cache_header_toc);