Comments (6)
I must admit that, although it actually makes sense, it would be probably a breaking change. I'm not sure it's the best choice.
On the other side, to solve the issue you pointed out it's enough to update the close
member function as follows:
void close() {
auto err = uv_loop_close(loop.get());
if(err) { publish(ErrorEvent{err}); }
else { loop.reset(); }
}
from uvw.
However uv_loop_close() is not idempotent (it will return UV_EBUSY if the loop has already been closed in DEBUG build, or crash straight away in Release build)
Interesting. Actually the documentation says something slightly different:
Call this function only when the loop has finished executing and all open handles and requests have been closed, or it will return UV_EBUSY.
It seems that UV_EBUSY
is due to pending handles or requests instead.
Are you sure you've none of them?
from uvw.
In terms of consistency, the best bet is to remove the destructor of the loop and let it be a no-op.
uvw
stays true to the behavior of libuv
and you've eg to close handles explicitly, it won't close them for you. I don't see why it should close the loop implicitly.
I'm tempted to say that you pointed out a design issue rather then a bug.
from uvw.
It seems that UV_EBUSY is due to pending handles or requests instead.
Are you sure you've none of them?
The issue happens in debug mode because of this.
BTW for Release build the code that can reproduce this issue is even simpler:
int main()
{
auto loop = uvw::Loop::create();
loop->close();
}
I'm tempted to say that you pointed out a design issue rather then a bug.
My understanding is that if the loop contains any active handles / requests then there will be references to the loop so the destruction won't be called automatically, so the Loop::close()
actually should not be called explicitly?
This seems quite reasonable since if the Loop
get destructed but uv_loop_close()
returns UV_EBUSY
then that means something is wrong with the reference counter. In this case is not the fault of this library.
However this makes the Loop::close()
function very confusing -- it's public but you are not supposed to call it.
from uvw.
Quite the opposite.
What I'm saying is that the Loop
class should not invoke uv_loop_close
. Actually, uvw::Loop
should not have an explicitly defined destructor at all.
Instead, you as an user must close explicitly the loop as you would do if you were working directly with libuv
. The same happens with the handles after all. This means staying true to the underlying library and that's why I think it's a design flaw rather than an issue.
from uvw.
Right that make sense.
from uvw.
Related Issues (20)
- ErrorCode EPIPE -4047 Broken Pipe HOT 2
- Error in .vtu Files with hexahedron type of elements HOT 1
- loop::run not marked inline HOT 1
- 48 error HOT 1
- Vcpkg uvw version 2.12.1 HOT 1
- Is there 2.x backward compatibility layer? HOT 15
- uvw_fs_event and uvw_loop fail on Darwin PPC HOT 5
- create v2 branch for bug fixes HOT 4
- Provide a way to specify buffer size HOT 5
- How to Handle a Broken Pipe (SIGPIPE) in UVW? HOT 2
- Segmentation fault on calling thread.join due to destructor also calling thread.join HOT 5
- Q: cpp http server based on libuv HOT 3
- suppress compiler warning HOT 8
- Build issues HOT 5
- Document suggested cleanup approach HOT 9
- Error when building on Windows - multiple rules generate _deps/libuv-build/uv.lib HOT 4
- Issuing multiple filesystem operations at a time with user supplied buffer HOT 2
- Question: Pipe process output HOT 1
- uvw_net available HOT 8
- Run a task on next event loop iteration HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uvw.