-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclipboard.txt
134 lines (98 loc) · 4.2 KB
/
clipboard.txt
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
watch cat /proc/$(ps a|grep xiinux|head -n1|awk '{print $1}')/status
cppcheck --enable=all src/main.cpp
# watch open sockets count
XID=$(ps a|grep xiinux|head -n1|awk '{print $1}') watch -n 1 "lsof -a -p $XID -i | grep TCP | wc -l"
TAG=$(date "+%Y-%m-%d--%H-%M") && git tag $TAG && git push origin $TAG
git reset --hard HEAD
ulimit -n
ulimit -n 4000
./test-coverage.sh | tee test-coverage.log
# coverage
llvm-profdata merge -sparse default.profraw -o default.profdata
llvm-cov export --format=lcov --instr-profile default.profdata --object xiinux > lcov.info
llvm-cov show xiinux -instr-profile=default.profdata
sudo tcpdump -A -i lo -n port 8088
sudo sysctl net.ipv4.ip_local_port_range='1024 65000'
sudo sysctl net.core.somaxconn=40000
# to allow more concurrent connections
sudo sysctl fs.file-max=70000
# allow connection flood
sudo sh -c "echo 0 >/proc/sys/net/ipv4/tcp_syncookies"
sudo sh -c 'echo 30000>/proc/sys/net/ipv4/tcp_max_syn_backlog'
# recycles connections after 5 seconds of wait mode
sudo sysctl net.ipv4.tcp_tw_reuse=1
sudo sysctl net.ipv4.tcp_fin_timeout=5
# increase maximum number of open files (relogin)
#vi /etc/security/limits.conf
#c soft nofile 20000
#c hard nofile 40000
hey -n 10000 -c 1 http://localhost:8088/qa/files/far_side_dog_ok.jpg
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
// Create epoll instance
int epoll_fd = epoll_create1(0);
// Add socket to epoll
struct epoll_event event;
event.events = EPOLLIN;
event.data.fd = socket_fd;
epoll_ctl(epoll_fd, EPOLL_CTL_ADD, socket_fd, &event);
// Create timer file descriptor
int timer_fd = timerfd_create(CLOCK_MONOTONIC, 0);
// Add timer to epoll
event.events = EPOLLIN;
event.data.fd = timer_fd;
epoll_ctl(epoll_fd, EPOLL_CTL_ADD, timer_fd, &event);
// Main event loop
while (true) {
struct epoll_event events[2];
int num_events = epoll_wait(epoll_fd, events, 2, -1);
for (int i = 0; i < num_events; ++i) {
int fd = events[i].data.fd;
if (fd == socket_fd) {
// Handle socket event
// Process incoming data
// Reset the timer when there is activity on the socket
struct itimerspec timer_spec;
timer_spec.it_value.tv_sec = 60; // 1 minute
timer_spec.it_value.tv_nsec = 0;
timer_spec.it_interval.tv_sec = 0;
timer_spec.it_interval.tv_nsec = 0;
timerfd_settime(timer_fd, 0, &timer_spec, NULL);
} else if (fd == timer_fd) {
// Handle timer event
// Close the inactive socket and remove from epoll
close(socket_fd);
epoll_ctl(epoll_fd, EPOLL_CTL_DEL, socket_fd, NULL);
}
}
}
// Cleanup
close(socket_fd);
close(epoll_fd);
close(timer_fd);
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Retrieve the lastModified value from the File object, which represents the number of milliseconds since January 1, 1970 (Unix timestamp).
#include <iostream>
#include <sys/stat.h>
void setModifiedTime(const std::string& filePath, time_t modifiedTime) {
struct utimbuf timeBuf;
timeBuf.actime = modifiedTime; // access time (not modified)
timeBuf.modtime = modifiedTime; // modified time
// Set the modified time of the file
if (utime(filePath.c_str(), &timeBuf) != 0) {
std::cerr << "Failed to set the modified time of the file." << std::endl;
}
}
int main() {
// Example usage
std::string filePath = "/path/to/file.txt";
time_t lastModified = selectedFiles[i].lastModified / 1000; // Convert to seconds
setModifiedTime(filePath, lastModified);
return 0;
}
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------