Skip to content

Commit

Permalink
Fix memory leak in linuxaio: Posted requests were moved into (unneces…
Browse files Browse the repository at this point in the history
…sary) queue and freed only on programme termination
  • Loading branch information
manpen committed Jul 10, 2018
1 parent 263df0c commit 97bf99d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
2 changes: 1 addition & 1 deletion include/stxxl/bits/io/linuxaio_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class linuxaio_queue : public request_queue_impl_worker
// "waiting" request have submitted to this queue, but not yet to the OS,
// those are "posted"
mutex waiting_mtx, posted_mtx;
queue_type waiting_requests, posted_requests;
queue_type waiting_requests;

//! max number of OS requests
int max_events;
Expand Down
29 changes: 1 addition & 28 deletions lib/io/linuxaio_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,28 +118,6 @@ bool linuxaio_queue::cancel_request(request_ptr& req)

scoped_mutex_lock lock(posted_mtx);

pos = std::find(posted_requests.begin(), posted_requests.end(),
req _STXXL_FORCE_SEQUENTIAL);
if (pos != posted_requests.end())
{
// polymorphic_downcast to linuxaio_request,
bool canceled_io_operation = (dynamic_cast<linuxaio_request*>(req.get()))->cancel_aio();

if (canceled_io_operation)
{
posted_requests.erase(pos);

// polymorphic_downcast to linuxaio_request,

// request is canceled, already posted
dynamic_cast<linuxaio_request*>(req.get())->completed(true, true);

num_free_events++;
num_posted_requests--; // will never block
return true;
}
}

return false;
}

Expand Down Expand Up @@ -184,12 +162,7 @@ void linuxaio_queue::post_requests()
}

// request is finally posted

{
scoped_mutex_lock lock(posted_mtx);
posted_requests.push_back(req);
num_posted_requests++;
}
num_posted_requests++;
}
else
{
Expand Down

0 comments on commit 97bf99d

Please sign in to comment.