Skip to content

Commit

Permalink
Merge pull request #61 from singchia/feat/readme
Browse files Browse the repository at this point in the history
optimize: for conn layer sync write and session management
  • Loading branch information
singchia authored Nov 29, 2023
2 parents 47e92aa + cf4a699 commit 5d1a6da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
8 changes: 5 additions & 3 deletions multiplexer/dialogue.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,12 @@ func (dg *dialogue) handleInDimssAckPacket(pkt *packet.DismissAckPacket) iodefin
}

func (dg *dialogue) handleInDataPacket(pkt packet.Packet) iodefine.IORet {
ok := dg.fsm.InStates(SESSIONED)
// we regard statuses which include sessioned, dismiss_half, dismiss_sent as normal statuses
// and status dismiss_recv should be optimized from client side.
ok := dg.fsm.InStates(SESSIONED, DISMISS_HALF, DISMISS_SENT, DISMISS_RECV)
if !ok {
dg.log.Debugf("data at non SESSIONED, clientID: %d, dialogueID: %d, packetID: %d",
dg.cn.ClientID(), dg.dialogueID, pkt.ID())
dg.log.Debugf("data at non normal status, clientID: %d, dialogueID: %d, packetID: %d, status: %s",
dg.cn.ClientID(), dg.dialogueID, pkt.ID(), dg.fsm.State())
if dg.failedCh != nil {
dg.failedCh <- pkt
}
Expand Down
14 changes: 9 additions & 5 deletions multiplexer/dialogue_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,16 @@ func (dm *dialogueMgr) handlePkt(pkt packet.Packet) {
dm.mtx.RLock()
dg, ok := dm.dialogues[dialogueID]
if !ok {
dm.log.Errorf("clientID: %d, unable to find dialogueID: %d, packetID: %d, packetType: %s",
dm.cn.ClientID(), dialogueID, pkt.ID(), pkt.Type().String())
dm.mtx.RUnlock()
return
// maybe the dialogue is in negotiating
dg, ok = dm.negotiatingDialogues[dialogueID]
if !ok {
dm.log.Errorf("clientID: %d, unable to find dialogueID: %d, packetID: %d, packetType: %s",
dm.cn.ClientID(), dialogueID, pkt.ID(), pkt.Type().String())
dm.mtx.RUnlock()
return
}
}
dm.log.Tracef("write to dialogue, clientID: %d, dialogueID: %d, packetID: %d, packetType %s",
dm.log.Tracef("read to dialogue, clientID: %d, dialogueID: %d, packetID: %d, packetType %s",
dm.cn.ClientID(), dialogueID, pkt.ID(), pkt.Type().String())
dg.readInCh <- pkt
dm.mtx.RUnlock()
Expand Down
3 changes: 2 additions & 1 deletion pkg/iodefine/iodefine.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const (
)

var (
ErrIOTimeout = errors.New("io time out")
ErrIOTimeout = errors.New("io time out")
ErrIOBufferFull = errors.New("io buffer full")
)

func ErrUseOfClosedNetwork(err error) bool {
Expand Down

0 comments on commit 5d1a6da

Please sign in to comment.