mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
tcp.message uuid fix (#855)
the current UUID generator runs at: ``` BenchmarkMessageUUID 13599342 87.7 ns/op 16 B/op 0 allocs/op ``` with the former version that was running on ``` BenchmarkMessageUUID 2818203 427 ns/op 96 B/op 2 allocs/op ``` it fixes #842 #851
This commit is contained in:
+5
-7
@@ -149,8 +149,10 @@ func (i *RAWInput) listen(address string) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
pool := tcp.NewMessagePool(i.CopyBufferSize, i.Expire, Debug, i.handler)
|
||||
pool.End = endHint
|
||||
pool.Start = startHint
|
||||
pool.MatchUUID(i.TrackResponse)
|
||||
if i.Protocol == ProtocolHTTP {
|
||||
pool.Start = http1StartHint
|
||||
}
|
||||
var ctx context.Context
|
||||
ctx, i.cancelListener = context.WithCancel(context.Background())
|
||||
errCh := i.listener.ListenBackground(ctx, pool.Handler)
|
||||
@@ -196,14 +198,10 @@ func (i *RAWInput) addStats(mStats tcp.Stats) {
|
||||
i.Unlock()
|
||||
}
|
||||
|
||||
func startHint(pckt *tcp.Packet) (isIncoming, isOutgoing bool) {
|
||||
func http1StartHint(pckt *tcp.Packet) (isIncoming, isOutgoing bool) {
|
||||
isIncoming = proto.HasRequestTitle(pckt.Payload)
|
||||
if isIncoming {
|
||||
return
|
||||
}
|
||||
return false, proto.HasResponseTitle(pckt.Payload)
|
||||
}
|
||||
|
||||
func endHint(m *tcp.Message) bool {
|
||||
return proto.HasFullPayload(m.Data())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user