sustrik / libdill

Structured concurrency in C
MIT License
1.68k stars 156 forks source link

BSD Socket Rewrite: How does close of overlay protocol (detach) but continuing to use underlying protocol work? #151

Closed david-bakin closed 6 years ago

david-bakin commented 6 years ago

I'm confused: There's a recommendation that when attaching an overlay protocol the handle passed as the underlying protocol is invalidated, and there's a suggestion that you can close (detach) the overlay protocol and continue to use the underlying protocol.

Don't see how that works ... unless for this pattern the user is expected to duplicate the underlying handle himself and pass that (duplicate) to the attach API, leaving him holding a valid handle to the underlying protocol.

sustrik commented 6 years ago

Here's an example how it's done.

1.) Attach: https://github.com/sustrik/libdill/blob/master/suffix.c#L74 2.) Detach: https://github.com/sustrik/libdill/blob/master/suffix.c#L123