Changeset 45 in code for trunk/downstream.go


Ignore:
Timestamp:
Feb 7, 2020, 11:42:24 AM (5 years ago)
Author:
contact
Message:

Close connection from writer goroutine

Connections were being closed from the reader goroutine, causing issues
when sending messages and immediately closing the connection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r43 r45  
    7171                        }
    7272                }
     73                if err := conn.net.Close(); err != nil {
     74                        conn.logger.Printf("failed to close connection: %v", err)
     75                } else {
     76                        conn.logger.Printf("connection closed")
     77                }
    7378        }()
    7479
     
    8691func (c *downstreamConn) readMessages() error {
    8792        c.logger.Printf("new connection")
    88         defer c.Close()
    8993
    9094        for {
     
    109113        }
    110114
    111         return c.Close()
     115        return nil
    112116}
    113117
     
    130134        c.closed = true
    131135
    132         return c.net.Close()
     136        return nil
    133137}
    134138
Note: See TracChangeset for help on using the changeset viewer.