Compare commits

...

No commits in common. "540c64a421d8ec16d03dde2583a523ac86a95be0" and "5e885a0bd30b18628d27b3bcf63181cd6b32749e" have entirely different histories.

3 changed files with 26 additions and 18 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module git.tebibyte.media/sashakoshka/hopp
go 1.23.0 go 1.23.0
require ( require (
git.tebibyte.media/sashakoshka/go-util v0.9.0 git.tebibyte.media/sashakoshka/go-util v0.9.1
github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62 github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62
github.com/quic-go/quic-go v0.48.2 github.com/quic-go/quic-go v0.48.2
) )

4
go.sum
View File

@ -1,5 +1,5 @@
git.tebibyte.media/sashakoshka/go-util v0.9.0 h1:s4u6USI1yRqTFNv52qJlEy1qO9pfF2+U6IklxkSLckY= git.tebibyte.media/sashakoshka/go-util v0.9.1 h1:eGAbLwYhOlh4aq/0w+YnJcxT83yPhXtxnYMzz6K7xGo=
git.tebibyte.media/sashakoshka/go-util v0.9.0/go.mod h1:0Q1t+PePdx6tFYkRuJNcpM1Mru7wE6X+it1kwuOH+6Y= git.tebibyte.media/sashakoshka/go-util v0.9.1/go.mod h1:0Q1t+PePdx6tFYkRuJNcpM1Mru7wE6X+it1kwuOH+6Y=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=

View File

@ -102,7 +102,7 @@ func (this *a) receive() {
defer func() { defer func() {
this.underlying.Close() this.underlying.Close()
this.transLock.Lock() this.transLock.Lock()
defer this.transLock.Lock() defer this.transLock.Unlock()
for _, trans := range this.transMap { for _, trans := range this.transMap {
trans.Close() trans.Close()
} }
@ -124,22 +124,30 @@ func (this *a) receive() {
} }
func (this *a) receiveMultiplex(transID int64, method uint16, payload []byte) error { func (this *a) receiveMultiplex(transID int64, method uint16, payload []byte) error {
if transID == 0 || this.party == partyFromTransID(transID) { if transID == 0 { return ErrMessageMalformed }
return ErrMessageMalformed
}
trans, err := func() (*transA, error) {
this.transLock.Lock() this.transLock.Lock()
defer this.transLock.Unlock() defer this.transLock.Unlock()
trans, ok := this.transMap[transID] trans, ok := this.transMap[transID]
if !ok { if !ok {
// it is forbidden for the other party to initiate a transaction
// with an ID from this party
if this.party == partyFromTransID(transID) {
return nil, ErrMessageMalformed
}
trans = &transA { trans = &transA {
parent: this, parent: this,
id: transID, id: transID,
incoming: usync.NewGate[incomingMessage](), incoming: usync.NewGate[incomingMessage](),
} }
this.transMap[transID] = trans
this.transChan <- trans this.transChan <- trans
} }
return trans, nil
}()
if err != nil { return err }
trans.incoming.Send(incomingMessage { trans.incoming.Send(incomingMessage {
method: method, method: method,