1
0
mirror of https://github.com/ohwgiles/laminar.git synced 2026-09-24 12:56:42 +00:00

resolves #19: laminard crashes under load

reading into a static buffer is a race condition that is only
manifested under load. There's no guarantee the clause in then()
will run before another task overwrites the buffer. Allocating
a local string is the only correct solution
This commit is contained in:
Oliver Giles
2017-12-04 20:29:19 +02:00
parent 7dce535264
commit d91816097a
3 changed files with 11 additions and 10 deletions

View File

@@ -41,12 +41,12 @@ public:
// add a file descriptor to be monitored for output. The callback will be
// invoked with the read data
void addDescriptor(int fd, std::function<void(char*,size_t)> cb);
void addDescriptor(int fd, std::function<void(const char*,size_t)> cb);
private:
void acceptHttpClient(kj::Own<kj::ConnectionReceiver>&& listener);
void acceptRpcClient(kj::Own<kj::ConnectionReceiver>&& listener);
kj::Promise<void> handleFdRead(kj::AsyncInputStream* stream, std::function<void(char*,size_t)> cb);
kj::Promise<void> handleFdRead(kj::AsyncInputStream* stream, std::function<void(const char*,size_t)> cb);
void taskFailed(kj::Exception&& exception) override {
kj::throwFatalException(kj::mv(exception));