Commit 5d2b2752 authored by Noah Orensa's avatar Noah Orensa
Browse files

fix runaway allocations dur to messaging in workers in distributed unit tests

parent 964dcebb
......@@ -710,26 +710,26 @@ void WorkerContext::_waitForEvent() {
}
Message WorkerContext::createUserMessage() {
sandbox().exit();
sandbox().lock();
Message m;
m << OpCode::USER_MESSAGE << _id;
sandbox().enter();
sandbox().unlock();
return m;
}
void WorkerContext::sendUserMessage(Message &message) {
sandbox().exit();
sandbox().lock();
message.send(_driverSocket);
sandbox().enter();
sandbox().unlock();
}
Message WorkerContext::getUserMessage() {
sandbox().exit();
sandbox().lock();
while (_userMessages.empty()) {
_waitForEvent();
......@@ -737,23 +737,23 @@ Message WorkerContext::getUserMessage() {
Message m = _userMessages.front();
_userMessages.pop_front();
sandbox().enter();
sandbox().unlock();
return m;
}
void WorkerContext::notify() {
sandbox().exit();
sandbox().lock();
Message m;
m << OpCode::NOTIFY << _id;
m.send(_driverSocket);
sandbox().enter();
sandbox().unlock();
}
void WorkerContext::wait(uint32_t n) {
sandbox().exit();
sandbox().lock();
if (n == -1u) n = 1;
......@@ -763,7 +763,7 @@ void WorkerContext::wait(uint32_t n) {
_notifyCount -= n;
sandbox().enter();
sandbox().unlock();
}
Lazy<WorkerContext> WorkerContext::instance([] { return new WorkerContext(); });
......@@ -287,8 +287,19 @@ dunit("distributed-unit-test", "runaway-allocations-during-message")
t.join();
})
.worker([] {
volatile bool run = true;
auto t = std::thread([&run] {
while (run) {
void *ptr = malloc(1);
free(ptr);
}
});
int x;
for (auto i = 0; i < 1000; ++i) {
dtest_recvMsg() >> x;
}
run = false;
t.join();
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment