Skip to content

Commit

Permalink
apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ainghazal committed Jan 30, 2024
1 parent 1fbbee5 commit 2a15f2d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
5 changes: 3 additions & 2 deletions internal/reliabletransport/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ type inFlighter interface {
// outgoingPacketHandler has methods to deal with the outgoing packets (going down).
type outgoingPacketHandler interface {
// TryInsertOutgoingPacket attempts to insert a packet into the
// inflight queue. If return value is false, insertion was not successful.
// inflight queue. If return value is false, insertion was not successful (e.g., too many
// packets in flight).
TryInsertOutgoingPacket(*model.Packet) bool

// MaybeEvictOrBumpPacketAfterACK removes a packet (that we received an ack for) from the in-flight packet queue.
MaybeEvictOrBumpPacketAfterACK(id model.PacketID) bool

// NextPacketIDsToACK returns an array of pending IDs to ACK to
// our remote. The lenght of this array SHOULD not be larger than CONTROL_SEND_ACK_MAX.
// our remote. The length of this array SHOULD not be larger than CONTROL_SEND_ACK_MAX.
// This is used to append it to the ACK array of the outgoing packet.
NextPacketIDsToACK() []model.PacketID

Expand Down
3 changes: 2 additions & 1 deletion internal/reliabletransport/packets.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ func (seq inflightSequence) readyToSend(t time.Time) inflightSequence {
fmt.Println("DEBUG: fast retransmit for", p.packet.ID)
expired = append(expired, p)
continue
} else if p.deadline.Before(t) {
}
if p.deadline.Before(t) {
expired = append(expired, p)
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/reliabletransport/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (ws *workersState) moveUpWorker() {
select {
case packet := <-ws.muxerToReliable:
if packet.Opcode != model.P_CONTROL_HARD_RESET_SERVER_V2 {
// the hard reset we logged in below
// the hard reset has already been logged by the layer below
packet.Log(ws.logger, model.DirectionIncoming)
}

Expand Down Expand Up @@ -130,7 +130,7 @@ func (r *reliableReceiver) NextIncomingSequence() incomingSequence {

// sort them so that we begin with lower model.PacketID
sort.Sort(r.incomingPackets)
keep := r.incomingPackets[:0]
var keep incomingSequence

for i, p := range r.incomingPackets {
if p.ID()-last == 1 {
Expand Down
2 changes: 1 addition & 1 deletion internal/reliabletransport/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (ws *workersState) moveDownWorker() {
select {
case packet := <-ws.controlToReliable:

// try to insert and schedule for inmediate wakeup
// try to insert and schedule for immediate wakeup
if inserted := sender.TryInsertOutgoingPacket(packet); inserted {
ticker.Reset(time.Nanosecond)
}
Expand Down
1 change: 0 additions & 1 deletion internal/reliabletransport/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func (s *Service) StartWorkers(
workersManager *workers.Manager,
sessionManager *session.Manager,
) {

ws := &workersState{
logger: logger,
incomingSeen: make(chan incomingPacketSeen, 20),
Expand Down
3 changes: 1 addition & 2 deletions internal/tun/tun.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ var (
// StartTUN initializes and starts the TUN device over the vpn.
// If the passed context expires before the TUN device is ready,
func StartTUN(ctx context.Context, conn networkio.FramingConn, options *model.Options, logger model.Logger) (*TUN, error) {
// be useful if passing an empty logger
if logger == nil {
logger = log.Log
return nil, errors.New("logger cannot be nil")
}

// create a session
Expand Down

0 comments on commit 2a15f2d

Please sign in to comment.