-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
86 lines (79 loc) · 3.63 KB
/
Copy pathmain.cpp
File metadata and controls
86 lines (79 loc) · 3.63 KB
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
86
// main.cpp
// ./imdragonfly
// valgrind ./imdragonfly , 与mimalloc, glog冲突
#include <glog/logging.h>
// cd programs/ImDragonfly
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <cstdio>
#include <memory>
#include "src/network/redis_server.hpp"
using namespace dfly;
/*
mimalloc: warning: mi_usable_size: pointer might not point to a valid heap
region: 0x7aacbc020000 (this may still be a valid very large allocation (over
64MiB)) mimalloc: warning: (yes, the previous pointer 0x7aacbc020000 was valid
after all) mimalloc: warning: mi_usable_size: pointer might not point to a valid
heap region: 0x7aacbc020000 (this may still be a valid very large allocation
(over 64MiB)) mimalloc: warning: mimalloc: warning: mi_usable_size: pointer
might not point to a valid heap region: 0x7aacb8020000 (this may still be a
valid very large allocation (over 64MiB)) mimalloc: warning: (yes, the previous
pointer 0x7aacb8020000 was valid after all) mimalloc: warning: mi_usable_size:
pointer might not point to a valid heap region: 0x7aacb8020000 (this may still
be a valid very large allocation (over 64MiB)) mimalloc: warning: (yes, the
previous pointer 0x7aacb8020000 was valid after all) mimalloc: warning:
mi_usable_size: pointer might not point to a valid heap region: 0x7aacb8030080
(this may still be a valid very large allocation (over 64MiB))
mimalloc: warning: (yes, the previous pointer 0x7aacb8030080 was valid after
all) mimalloc: warning: mi_usable_size: pointer might not point to a valid heap
region: 0x7aacb8030080 (this may still be a valid very large allocation (over
64MiB)) mimalloc: warning: (yes, the previous pointer 0x7aacb8030080 was valid
after all) (yes, the previous pointer 0x7aacbc020000 was valid after all)
mimalloc: warning: mi_usable_size: pointer might not point to a valid heap
region: 0x7aacbc030080 (this may still be a valid very large allocation (over
64MiB)) mimalloc: warning: (yes, the previous pointer 0x7aacbc030080 was valid
after all) mimalloc: warning: mi_usable_size: pointer might not point to a valid
heap region: 0x7aacbc030080 (this may still be a valid very large allocation
(over 64MiB)) mimalloc: warning: (yes, the previous pointer 0x7aacbc030080 was
valid after all) mimalloc: warning: mi_usable_size: pointer might not point to a
valid heap region: 0x7aacb4020000 (this may still be a valid very large
allocation (over 64MiB)) mimalloc和ASAN冲突
*/
/*
程序结束时ASAN会报内存泄漏的错误,但是这实际上不是错误,是堆内存操作没有执行完时,程序被终止时的正常情况,ASAN无法区分这种情况和真正的内存泄漏,所以会误报内存泄漏错误。
*/
// export
// ASAN_OPTIONS="detect_leaks=1:leak_check_at_exit=0:leak_check_interval=1024:halt_on_error=0:log_path=/home/yy/programs/ImDragonfly/build/asan.log"
// ./imdragonfly
int main(int argc, char *argv[]) {
int ret = mkdir("./logs", 0755);
if (ret != 0 && errno != EEXIST) {
fprintf(stderr, "Failed to create logs directory: %s\n", strerror(errno));
return 1;
}
FLAGS_log_dir = "./logs";
FLAGS_logtostderr = false;
FLAGS_alsologtostderr = false;
FLAGS_minloglevel = 0;
FLAGS_v = 2;
#ifndef NDEBUG
FLAGS_logbufsecs = 0;
#endif
google::InitGoogleLogging(argv[0]);
LOG(INFO) << "ImDragonfly server starting...";
int num = 4;
if (argc > 1) {
num = std::atoi(argv[1]);
}
yy::net::EventLoop loop;
RedisServer server(6379, &loop, num);
std::string str =
"RedisServer initialized with " + std::to_string(num) + " shards";
LOG(INFO) << str;
server.Start();
loop.loop();
LOG(INFO) << "ImDragonfly server shutting down...";
google::ShutdownGoogleLogging();
return 0;
}