13
13
*
14
14
*/
15
15
16
- #include < unistd.h>
17
-
18
16
#include < string>
19
17
#include < memory>
18
+ #include < thread>
19
+ #include < chrono>
20
+ #include < pthread.h>
20
21
21
22
22
23
#define NUM_THREADS 100
@@ -72,6 +73,11 @@ struct data_ms {
72
73
modsecurity::RulesSet *rules;
73
74
};
74
75
76
+ #if defined _MSC_VER
77
+ #pragma warning(push)
78
+ #pragma warning(disable:4716) // avoid error C4716: 'process_request': must return a value, as MSVC C++ compiler doesn't support [[noreturn]]
79
+ #pragma warning(disable:4715) // avoid warning c4715: 'process_request' : not all control paths return a value
80
+ #endif
75
81
76
82
[[noreturn]] static void *process_request (void *data) {
77
83
struct data_ms *a = (struct data_ms *)data;
@@ -85,7 +91,7 @@ struct data_ms {
85
91
modsecTransaction->processConnection (ip, 12345 , " 127.0.0.1" , 80 );
86
92
modsecTransaction->processURI (request_uri, " GET" , " 1.1" );
87
93
88
- usleep ( 10 );
94
+ std::this_thread::sleep_for ( std::chrono::microseconds ( 10 ) );
89
95
modsecTransaction->addRequestHeader (" Host" ,
90
96
" net.tutsplus.com" );
91
97
modsecTransaction->processRequestHeaders ();
@@ -105,6 +111,9 @@ struct data_ms {
105
111
pthread_exit (nullptr );
106
112
}
107
113
114
+ #if defined _MSC_VER
115
+ #pragma warning(pop)
116
+ #endif
108
117
109
118
class ReadingLogsViaRuleMessage {
110
119
public:
@@ -151,7 +160,7 @@ class ReadingLogsViaRuleMessage {
151
160
reinterpret_cast <void *>(&dms));
152
161
}
153
162
154
- usleep ( 10000 );
163
+ std::this_thread::sleep_for ( std::chrono::microseconds ( 10000 ) );
155
164
156
165
for (i=0 ; i < NUM_THREADS; i++) {
157
166
pthread_join (threads[i], &status);
0 commit comments