Commit dc302393 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Ensure that the current fiber is recycled in discardAndResume()

parent 1a0ced03
......@@ -64,5 +64,17 @@ void ContextManager::discardAndResume(Context* context) {
LOGD("Freeing context " << contextToFree);
// Since we are going to discard this context, it will never reach
// the end of its dispatch loop, and hence we need to ensure that
// the fiber is recycled.
const Fiber* currentFiber = Dispatcher::currentFiber;
if (currentFiber) {
// Set currentFiber to nullptr to avoid double frees here.
Dispatcher::currentFiber = nullptr;
#pragma once
#include "Common.hpp"
#include "Dispatcher.hpp"
#include "WsClQueue.hpp"
#include "Runtime.hpp"
#include "Context.hpp"
......@@ -17,6 +18,8 @@ private:
friend Context;
friend Dispatcher;
ContextManager(Runtime& runtime);
......@@ -35,7 +35,7 @@ protected:
return fiber->doAtomicDecrRefCount();
inline void recycle(const Fiber* fiber) {
static inline void recycle(const Fiber* fiber) {
delete fiber;
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