Skip to content
This repository was archived by the owner on Jul 8, 2020. It is now read-only.

Commit d28b0f6

Browse files
committed
Merge pull request #10 from notorca/master
Fixed wrong detection of the closed connection
2 parents 649fd3a + c989abb commit d28b0f6

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

conn.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type Conn struct {
3333
renameFrom string
3434
lastFilePos int64
3535
appendData bool
36+
closed bool
3637
}
3738

3839
func (conn *Conn) LoginUser() string {
@@ -78,7 +79,7 @@ func (conn *Conn) Serve() {
7879
conn.receiveLine(line)
7980
// QUIT command closes connection, break to avoid error on reading from
8081
// closed socket
81-
if conn.dataConn == nil {
82+
if conn.closed == true {
8283
break
8384
}
8485
}
@@ -89,6 +90,7 @@ func (conn *Conn) Serve() {
8990
// Close will manually close this connection, even if the client isn't ready.
9091
func (conn *Conn) Close() {
9192
conn.conn.Close()
93+
conn.closed = true
9294
if conn.dataConn != nil {
9395
conn.dataConn.Close()
9496
conn.dataConn = nil

server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ func (Server *Server) ListenAndServe() error {
172172
var err error
173173

174174
if Server.ServerOpts.TLS {
175-
config, err := simpleTLSConfig(Server.CertFile, Server.KeyFile)
175+
var config *tls.Config
176+
config, err = simpleTLSConfig(Server.CertFile, Server.KeyFile)
176177
if err != nil {
177178
return err
178179
}

0 commit comments

Comments
 (0)