You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm pulling comment from @helje5 from #28 over into this issue, because that issue is getting cluttered.
The worse aspect is that this calls the done-cb before the queued write has actually finished! This needs to be passed along the stream, that's the whole point.
My reason for not doing this was two-fold:
I was concerned about side-effects from passing the completion blocks into the Socket code, either in the form of memory leaks or in the form of deadlocks.
I don't see a case where it matters. The best this code can do is to hold onto the CB until after the socket write() completes. But, as the documentation for write(2) explicitly says "A successful return from write() does not make any guarantee that data has been committed," holding onto the CB that long doesn't provide any more reliability or information that if it was called where it is now.
There's no guarantee the connection won't be closed before the bytes that were queued will be written to the socket, but there's no guarantee they're going to make it to the far end of the TCP connection either.
So why does it matter whether the callback happens after the bytes are queued for write() or once write() had completed? The guarantee (or lack thereof) is the same either way. By Occam's Razor then, I think the simpler design is better.
I might well be missing something here. If so, I'd love to know what it is.
I'm pulling comment from @helje5 from #28 over into this issue, because that issue is getting cluttered.
My reason for not doing this was two-fold:
write()completes. But, as the documentation forwrite(2)explicitly says "A successful return fromwrite()does not make any guarantee that data has been committed," holding onto the CB that long doesn't provide any more reliability or information that if it was called where it is now.There's no guarantee the connection won't be closed before the bytes that were queued will be written to the socket, but there's no guarantee they're going to make it to the far end of the TCP connection either.
So why does it matter whether the callback happens after the bytes are queued for
write()or oncewrite()had completed? The guarantee (or lack thereof) is the same either way. By Occam's Razor then, I think the simpler design is better.I might well be missing something here. If so, I'd love to know what it is.
Thanks