diff --git a/src/uvw/work.cpp b/src/uvw/work.cpp index be95385a..2a27f467 100644 --- a/src/uvw/work.cpp +++ b/src/uvw/work.cpp @@ -15,7 +15,7 @@ UVW_INLINE void work_req::work_callback(uv_work_t *req) { static_cast(req->data)->func(); } -UVW_INLINE void work_req::after_work_callback(uv_work_t *req, int status) { +UVW_INLINE void work_req::after_work_callback(uv_work_t* req, int status) { if(auto ptr = reserve(req); status) { ptr->publish(error_event{status}); } else { @@ -24,8 +24,9 @@ UVW_INLINE void work_req::after_work_callback(uv_work_t *req, int status) { } UVW_INLINE void work_req::queue() { - // uv_queue_work only returns an error if the callback is null which is not the case here - this->leak_if(uv_queue_work(parent().raw(), raw(), &work_callback, &after_work_callback)); + if(auto err = this->leak_if(uv_queue_work(parent().raw(), raw(), &work_callback, &after_work_callback)); err != 0) { + publish(error_event{err}); + } } } // namespace uvw