forked from Loures/objstore_sol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
os_server.h
64 lines (46 loc) · 1.2 KB
/
os_server.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
#ifndef OS_SERVER_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <myhash.h>
#include <errormacros.h>
extern volatile sig_atomic_t OS_RUNNING;
extern int os_serverfd;
extern int os_signalfd[];
extern int VERBOSE;
extern size_t SO_READ_BUFFSIZE;
extern volatile int worker_num;
extern pthread_mutex_t worker_num_mtx;
extern pthread_cond_t worker_num_cond;
typedef struct client_t {
char *name;
int socketfd;
int running;
pthread_t worker;
} client_t;
extern ht_t *client_list;
#define HASHTABLE_SIZE 2048
#define HASHTABLE_LOCKS 256
#define SOCKET_ADDR "/tmp/objstore.sock"
#define discardsignals(sgn) \
{ \
int err = sigfillset(&sgn); \
if (err < 0) fprintf(stderr, "OBJSTORE: Error emptying sigset\n"); \
} \
#define free_os_msg(msg) \
{ \
free(msg->data); \
free(msg->name); \
free(msg->cmd); \
free(msg); \
} \
#define setnonblocking(fd) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK)
#define setblocking(fd) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK)
#define OS_SERVER_H
#endif