@@ -29,35 +29,35 @@ import "sync/atomic"
29
29
// checkBuf checks current buffer for overflow, and flushes buffer up to lastLen bytes on overflow
30
30
//
31
31
// overflow part is preserved in flushBuf
32
- func (c * Client ) checkBuf (lastLen int ) {
33
- if len (c .buf ) > c . options . MaxPacketSize {
34
- c .flushBuf (lastLen )
32
+ func (t * transport ) checkBuf (lastLen int ) {
33
+ if len (t .buf ) > t . maxPacketSize {
34
+ t .flushBuf (lastLen )
35
35
}
36
36
}
37
37
38
38
// flushBuf sends buffer to the queue and initializes new buffer
39
- func (c * Client ) flushBuf (length int ) {
40
- sendBuf := c .buf [0 :length ]
41
- tail := c .buf [length :len (c .buf )]
39
+ func (t * transport ) flushBuf (length int ) {
40
+ sendBuf := t .buf [0 :length ]
41
+ tail := t .buf [length :len (t .buf )]
42
42
43
43
// get new buffer
44
44
select {
45
- case c .buf = <- c .bufPool :
46
- c .buf = c .buf [0 :0 ]
45
+ case t .buf = <- t .bufPool :
46
+ t .buf = t .buf [0 :0 ]
47
47
default :
48
- c .buf = make ([]byte , 0 , c .bufSize )
48
+ t .buf = make ([]byte , 0 , t .bufSize )
49
49
}
50
50
51
51
// copy tail to the new buffer
52
- c .buf = append (c .buf , tail ... )
52
+ t .buf = append (t .buf , tail ... )
53
53
54
54
// flush current buffer
55
55
select {
56
- case c .sendQueue <- sendBuf :
56
+ case t .sendQueue <- sendBuf :
57
57
default :
58
58
// flush failed, we lost some data
59
- atomic .AddInt64 (& c .lostPacketsPeriod , 1 )
60
- atomic .AddInt64 (& c .lostPacketsOverall , 1 )
59
+ atomic .AddInt64 (& t .lostPacketsPeriod , 1 )
60
+ atomic .AddInt64 (& t .lostPacketsOverall , 1 )
61
61
}
62
62
63
63
}
0 commit comments