@@ -17,8 +17,6 @@ import (
17
17
)
18
18
19
19
const (
20
- // The size of the bufio reader/writer on top of the socket.
21
- defaultBufSize = 32768
22
20
// Scratch buffer size for the processMsg() calls.
23
21
msgScratchSize = 512
24
22
msgHeadProto = "MSG "
@@ -94,7 +92,7 @@ func init() {
94
92
func (c * client ) initClient () {
95
93
s := c .srv
96
94
c .cid = atomic .AddUint64 (& s .gcid , 1 )
97
- c .bw = bufio .NewWriterSize (c .nc , defaultBufSize )
95
+ c .bw = bufio .NewWriterSize (c .nc , s . opts . BufSize )
98
96
c .subs = hashmap .New ()
99
97
100
98
// This is a scratch buffer used for processMsg()
@@ -123,8 +121,8 @@ func (c *client) initClient() {
123
121
// No clue why, but this stalls and kills performance on Mac (Mavericks).
124
122
//
125
123
// if ip, ok := c.nc.(*net.TCPConn); ok {
126
- // ip.SetReadBuffer(defaultBufSize )
127
- // ip.SetWriteBuffer(2 * defaultBufSize )
124
+ // ip.SetReadBuffer(s.opts.BufSize )
125
+ // ip.SetWriteBuffer(2 * s.opts.BufSize )
128
126
// }
129
127
130
128
// Set the Ping timer
@@ -139,13 +137,14 @@ func (c *client) readLoop() {
139
137
// We check for that after the loop, but want to avoid a nil dereference
140
138
c .mu .Lock ()
141
139
nc := c .nc
140
+ s := c .srv
142
141
c .mu .Unlock ()
143
142
144
143
if nc == nil {
145
144
return
146
145
}
147
146
148
- b := make ([]byte , defaultBufSize )
147
+ b := make ([]byte , s . opts . BufSize )
149
148
150
149
for {
151
150
n , err := nc .Read (b )
0 commit comments