/
disk.h
85 lines (71 loc) · 1.55 KB
/
disk.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef _H_DISK
#define _H_DISK
#include <zmq.h>
#include "config.h"
/*
typedef enum {
RE_NOTCHECKED,
RE_OK,
RE_NOTFOUND,
RE_DENY
} result_t;
typedef struct cache_entry_s {
UT_hash_handle hh;
pthread_rwlock_t lock;
zmq_msg_t data;
zmq_msg_t gzipped;
struct stat filestat;
double check_time;
char last_modified[30];
char etag[22];
int pathlen;
char realpath[];
} cache_entry_t;
typedef struct cached_url_s {
UT_hash_handle hh;
pthread_rwlock_t lock;
size_t hash;
double last_access;
double access_freq;
int result;
char *uri;
char *realpath;
} cached_url_t;
typedef struct disk_cache_s {
cache_entry_t *table;
} disk_cache_t;
typedef struct url_cache_s {
cached_url_t *table;
} url_cache_s;
*/
typedef struct disk_request_s {
config_Route_t *route;
bool gzipped;
char if_modified[32];
char *path;
} disk_request_t;
typedef struct mime_entry_s {
LIST_ENTRY(mime_entry_s) lst;
char *mime;
char name[];
} mime_entry_t;
typedef struct mime_table_s {
int size;
struct obstack pieces;
LIST_HEAD(mime_table_head_s, mime_entry_s) entries[];
} mime_table_t;
typedef struct disk_global_s {
void *socket;
struct ev_io watch;
struct ev_async async;
pthread_t *threads;
int IF_MODIFIED;
int ACCEPT_ENCODING;
mime_table_t *mime_table;
} disk_global_t;
#include "main.h"
void *disk_loop(void *);
int disk_request(request_t *req);
int prepare_disk(config_main_t *config);
int release_disk(config_main_t *config);
#endif // _H_DISK