Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Graceful and disgraceful disconnect #28

Closed
piscisaureus opened this issue Apr 21, 2011 · 2 comments
Closed

Graceful and disgraceful disconnect #28

piscisaureus opened this issue Apr 21, 2011 · 2 comments
Labels

Comments

@piscisaureus
Copy link

Thinking about it makes my head hurt. But here's what:

Disgraceful disconnect

Currently, calling oio_close(handle) before the write queue is empty thrashes all data in the write queue. However the kernel will try to do a do a graceful disconnect anyway, so the client thinks he's received all data. This may be undesirable; an incomplete transfer should be recognizable as such by the other end. I think we need to set SO_LINGER with l_onoff=1 and l_linger=0 to achieve this.

Graceful disconnect

A socket can be closed after graceful shutdown when:

  • A oio_read call has reported a zero byte read once
  • The user has called oio_shutdown once, and
    oio_shutdown_cb has been called to indicate that the write queue was drained and a FIN has been sent.

Questions:

  • Should we track which ends of the stream have been closed or should the user do that?
  • Should oio_close be called automatically when a socket has been shut down at both ends?
  • What if the user isn't reading the socket after shutting it down?
@ry
Copy link
Contributor

ry commented Apr 22, 2011

  • Should we track which ends of the stream have been closed or should the user do that?

I think we should, yes. This is a bit higher level than the systems interfaces - but we get to know more.

  • Should oio_close be called automatically when a socket has been shut down at both ends?

Well - close() should be called automatically and the on_close callback fired.

  • What if the user isn't reading the socket after shutting it down?

Then it remains open

@piscisaureus
Copy link
Author

Landed in 7de6861 and b87f07d.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants