Skip to content

Commit

Permalink
chore: really bad fix for packets not sending
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredallard committed Sep 26, 2020
1 parent 33a2360 commit 577c274
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
4 changes: 1 addition & 3 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ type Session struct {
Conn net.Conn
Buf bytes.Buffer
Open bool
Lock sync.RWMutex
Lock sync.Mutex
}

func (s *Session) Close() {
if s.Conn != nil {
s.Lock.Lock()
_ = s.Conn.Close()
s.Open = false
s.Lock.Unlock()
}
openSessions.Delete(s.Id)
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"net"
"strings"

"io"

"github.com/google/uuid"
"github.com/omrikiei/ktunnel/pkg/common"
pb "github.com/omrikiei/ktunnel/tunnel_pb"
Expand Down Expand Up @@ -117,15 +115,14 @@ func readConn(session *common.Session, sessions chan<- *common.Session) {

session.Lock.Lock()
if err != nil {
if err == io.EOF {
return
}
log.WithError(err).WithField("session", session.Id).Infof("failed to read from conn")

// setting Open to false triggers SendData() to
// send ShouldClose
session.Open = false
}

// write the data to the session buffer, if we have data
if br > 0 {
session.Buf.Write(buff[0:br])
}
Expand Down

0 comments on commit 577c274

Please sign in to comment.