File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 11package czar
22
33import (
4+ "cmp"
45 "encoding/binary"
56 "io"
67 "sync"
@@ -12,7 +13,7 @@ import (
1213
1314// A Stream managed by the multiplexer.
1415type Stream struct {
15- fwu time.Time
16+ cat time.Time
1617 idx uint8
1718 mux * Mux
1819 rbf []byte
@@ -87,7 +88,7 @@ func (s *Stream) Write(p []byte) (int, error) {
8788 buf []byte
8889 l = 0
8990 n = 0
90- z = 1
91+ z = 0
9192 )
9293 for {
9394 switch {
@@ -105,9 +106,9 @@ func (s *Stream) Write(p []byte) (int, error) {
105106 binary .BigEndian .PutUint16 (buf [2 :4 ], uint16 (l ))
106107 copy (buf [4 :], p [:l ])
107108 p = p [l :]
108- if time . Now (). After (s .fwu ) {
109- z = 2
110- }
109+ z = 2 - max ( cmp . Compare ( Conf . FastWriteDuration - time . Since (s .cat ), 0 ), 0 )
110+ doa . Doa ( z >= 1 )
111+ doa . Doa ( z <= 2 )
111112 err := s .mux .pri .Pri (z , func () error {
112113 if err := s .wer .Get (); err != nil {
113114 return err
@@ -129,7 +130,7 @@ func (s *Stream) Write(p []byte) (int, error) {
129130// NewStream returns a new Stream.
130131func NewStream (idx uint8 , mux * Mux ) * Stream {
131132 return & Stream {
132- fwu : time .Now (). Add ( Conf . FastWriteDuration ),
133+ cat : time .Now (),
133134 idx : idx ,
134135 mux : mux ,
135136 rbf : make ([]byte , 0 ),
You can’t perform that action at this time.
0 commit comments