Browse Source

stop using CloseRead() until I figure out linger/flush issues

Alan Shreve 12 years ago
parent
commit
d0c3f9cd03
2 changed files with 5 additions and 6 deletions
  1. 5 1
      src/ngrok/conn/conn.go
  2. 0 5
      src/ngrok/server/control.go

+ 5 - 1
src/ngrok/conn/conn.go

@@ -163,7 +163,7 @@ func (c *loggedConn) StartTLS(tlsCfg *tls.Config) {
 }
 
 func (c *loggedConn) Close() (err error) {
-	if err := c.Conn.Close(); err != nil {
+	if err := c.Conn.Close(); err == nil {
 		c.Debug("Closing")
 	}
 	return
@@ -182,6 +182,10 @@ func (c *loggedConn) SetType(typ string) {
 }
 
 func (c *loggedConn) CloseRead() error {
+	// XXX: use CloseRead() in Conn.Join() and in Control.shutdown() for cleaner
+	// connection termination. Unfortunately, when I've tried that, I've observed
+	// failures where the connection was closed *before* flushing its write buffer,
+	// set with SetLinger() set properly (which it is by default).
 	return c.tcp.CloseRead()
 }
 

+ 0 - 5
src/ngrok/server/control.go

@@ -262,11 +262,6 @@ func (c *Control) stopper() {
 	// remove ourself from the control registry
 	controlRegistry.Del(c.id)
 
-	// close the connection's read side so that reader() stops
-	// XXX: disabled since this doesn't seem to play nicely with SO_LINGER
-	// c.conn.CloseRead()
-	// c.readerShutdown.WaitComplete()
-
 	// shutdown manager() so that we have no more work to do
 	close(c.in)
 	c.managerShutdown.WaitComplete()