-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.h
51 lines (41 loc) · 999 Bytes
/
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
/*
* Copyright 2015, Liyinlong. All rights reserved.
* https://github.com/Jacklli/Action
*
* Use of this source code is governed by GPL v2 license
* that can be found in the License file.
*
* Author: Liyinlong (yinlong.lee at hotmail.com)
*/
#ifndef __SERVER_H__
#define __SERVER_H__
#include <pthread.h>
#include "event.h"
#include "buffer.h"
#include "conn.h"
#include "dict.h"
#include "object.h"
/* refers to your CPU count */
#define THREADCNT 15
#define PORT 33060
#define READABLE 1
extern int serverport;
extern int listenfd;
extern dict *db[THREADCNT];
extern eventLoop *globalEloop[THREADCNT];
extern connTree *globalconnTree[THREADCNT];
extern pthread_mutex_t lock[THREADCNT];
extern pthread_mutex_t eloopidLock;
extern int eloopid;
extern pthread_mutex_t connLock;
typedef struct Server {
int listenfd;
int port;
char *bindaddr;
char *neterr;
int tcp_backlog;
connTree *tree;
eventLoop *eLoop;
} Server;
int initServer(Server *server);
#endif