1
0
Fork 0
forked from External/ergo

Merge pull request #218 from slingamn/socketwriter.1

refactor irc.Socket
This commit is contained in:
Shivaram Lingamneni 2018-03-28 13:26:03 -04:00 committed by GitHub
commit 7cfa75a59e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 90 additions and 125 deletions

View file

@ -87,7 +87,9 @@ type Client struct {
// NewClient returns a client with all the appropriate info setup.
func NewClient(server *Server, conn net.Conn, isTLS bool) *Client {
now := time.Now()
socket := NewSocket(conn, server.MaxSendQBytes)
limits := server.Limits()
fullLineLenLimit := limits.LineLen.Tags + limits.LineLen.Rest
socket := NewSocket(conn, fullLineLenLimit*2, server.MaxSendQBytes())
go socket.RunSocketWriter()
client := &Client{
atime: now,
@ -253,7 +255,11 @@ func (client *Client) run() {
line, err = client.socket.Read()
if err != nil {
client.Quit("connection closed")
quitMessage := "connection closed"
if err == errReadQ {
quitMessage = "readQ exceeded"
}
client.Quit(quitMessage)
break
}