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
|
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
|
+
-
+
|
#include <time.h>
/* Default values */
#define MAX_FAILURE_COUNT 30
#define PORT 8080
#define THREAD_COUNT 10
#define BIND_ADDR "::"
#define CACHE_SIZE 8192
/* Arguments for worker threads */
struct filed_worker_thread_args {
int fd;
};
/* File information */
struct filed_fileinfo {
pthread_mutex_t mutex;
char *path;
int fd;
size_t len;
char *lastmod;
char lastmod_b[64];
char *type;
};
/* Global variables */
struct filed_fileinfo *filed_fileinfo_fdcache;
unsigned int filed_fileinfo_fdcache_size = 8192;
unsigned int filed_fileinfo_fdcache_size = CACHE_SIZE;
/* Initialize process */
static int filed_init(void) {
unsigned int idx;
int mutex_init_ret;
mlockall(MCL_CURRENT | MCL_FUTURE);
|