Bug #11301 » 0002-Fix-Server-class-to-avoid-race-at-destruction.patch
test/http/HttpClientServerTest.C | ||
---|---|---|
138 | 138 |
} |
139 | 139 |
}; |
140 | 140 | |
141 |
class Server : public WServer
|
|
141 |
class Server |
|
142 | 142 |
{ |
143 | 143 |
public: |
144 | 144 |
Server() { |
... | ... | |
149 | 149 |
"--http-port", "0", |
150 | 150 |
"--docroot", "." |
151 | 151 |
}; |
152 |
setServerConfiguration(argc, (char **)argv); |
|
153 |
addResource(&resource_, "/test"); |
|
152 |
impl_.setServerConfiguration(argc, (char **)argv);
|
|
153 |
impl_.addResource(&resource_, "/test");
|
|
154 | 154 |
} |
155 | 155 | |
156 | 156 |
std::string address() |
157 | 157 |
{ |
158 |
return "127.0.0.1:" + std::to_string(httpPort()); |
|
158 |
return "127.0.0.1:" + std::to_string(impl_.httpPort()); |
|
159 |
} |
|
160 | ||
161 |
bool start() |
|
162 |
{ |
|
163 |
return impl_.start(); |
|
164 |
} |
|
165 | ||
166 |
Configuration& configuration() |
|
167 |
{ |
|
168 |
return impl_.configuration(); |
|
169 |
} |
|
170 | ||
171 |
template<typename ... Args> |
|
172 |
void addEntryPoint(Args&& ... args) |
|
173 |
{ |
|
174 |
return impl_.addEntryPoint(std::forward<Args>(args)...); |
|
159 | 175 |
} |
160 | 176 | |
161 | 177 |
TestResource& resource() { return resource_; } |
162 | 178 | |
163 | 179 |
private: |
180 |
/* |
|
181 |
* Note: The order of the resource and server is important. The server must |
|
182 |
* be shutdown/destructed before the resource to avoid a use after free for |
|
183 |
* requests that are still being handled by the resource on threads. |
|
184 |
*/ |
|
164 | 185 |
TestResource resource_; |
186 |
WServer impl_; |
|
165 | 187 |
}; |
166 | 188 | |
167 | 189 |
class Client : public Wt::WObject { |
168 |
- |