fix race condition for sniffing
This commit is contained in:
+14
-16
@@ -681,7 +681,7 @@ func (h *httpHandler) sniffingWebsocketFrame(ctx context.Context, rw, cc io.Read
|
|||||||
go func() {
|
go func() {
|
||||||
ro2 := &xrecorder.HandlerRecorderObject{}
|
ro2 := &xrecorder.HandlerRecorderObject{}
|
||||||
*ro2 = *ro
|
*ro2 = *ro
|
||||||
ro = ro2
|
ro := ro2
|
||||||
|
|
||||||
ticker := &time.Ticker{}
|
ticker := &time.Ticker{}
|
||||||
if d > 0 {
|
if d > 0 {
|
||||||
@@ -700,13 +700,12 @@ func (h *httpHandler) sniffingWebsocketFrame(ctx context.Context, rw, cc io.Read
|
|||||||
err := h.copyWebsocketFrame(cc, rw, buf, "client", ro)
|
err := h.copyWebsocketFrame(cc, rw, buf, "client", ro)
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if err != nil {
|
if err == nil {
|
||||||
ro.Err = err.Error()
|
ro.Duration = time.Since(start)
|
||||||
}
|
ro.Time = time.Now()
|
||||||
ro.Duration = time.Since(start)
|
if err := ro.Record(ctx, h.recorder.Recorder); err != nil {
|
||||||
ro.Time = time.Now()
|
log.Errorf("record: %v", err)
|
||||||
if err := ro.Record(ctx, h.recorder.Recorder); err != nil {
|
}
|
||||||
log.Errorf("record: %v", err)
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@@ -721,7 +720,7 @@ func (h *httpHandler) sniffingWebsocketFrame(ctx context.Context, rw, cc io.Read
|
|||||||
go func() {
|
go func() {
|
||||||
ro2 := &xrecorder.HandlerRecorderObject{}
|
ro2 := &xrecorder.HandlerRecorderObject{}
|
||||||
*ro2 = *ro
|
*ro2 = *ro
|
||||||
ro = ro2
|
ro := ro2
|
||||||
|
|
||||||
ticker := &time.Ticker{}
|
ticker := &time.Ticker{}
|
||||||
if d > 0 {
|
if d > 0 {
|
||||||
@@ -740,13 +739,12 @@ func (h *httpHandler) sniffingWebsocketFrame(ctx context.Context, rw, cc io.Read
|
|||||||
err := h.copyWebsocketFrame(rw, cc, buf, "server", ro)
|
err := h.copyWebsocketFrame(rw, cc, buf, "server", ro)
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if err != nil {
|
if err == nil {
|
||||||
ro.Err = err.Error()
|
ro.Duration = time.Since(start)
|
||||||
}
|
ro.Time = time.Now()
|
||||||
ro.Duration = time.Since(start)
|
if err := ro.Record(ctx, h.recorder.Recorder); err != nil {
|
||||||
ro.Time = time.Now()
|
log.Errorf("record: %v", err)
|
||||||
if err := ro.Record(ctx, h.recorder.Recorder); err != nil {
|
}
|
||||||
log.Errorf("record: %v", err)
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ func (ep *entrypoint) sniffingWebsocketFrame(ctx context.Context, rw, cc io.Read
|
|||||||
go func() {
|
go func() {
|
||||||
ro2 := &xrecorder.HandlerRecorderObject{}
|
ro2 := &xrecorder.HandlerRecorderObject{}
|
||||||
*ro2 = *ro
|
*ro2 = *ro
|
||||||
ro = ro2
|
ro := ro2
|
||||||
|
|
||||||
ticker := &time.Ticker{}
|
ticker := &time.Ticker{}
|
||||||
if d > 0 {
|
if d > 0 {
|
||||||
@@ -440,13 +440,12 @@ func (ep *entrypoint) sniffingWebsocketFrame(ctx context.Context, rw, cc io.Read
|
|||||||
err := ep.copyWebsocketFrame(cc, rw, buf, "client", ro)
|
err := ep.copyWebsocketFrame(cc, rw, buf, "client", ro)
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if err != nil {
|
if err == nil {
|
||||||
ro.Err = err.Error()
|
ro.Duration = time.Since(start)
|
||||||
}
|
ro.Time = time.Now()
|
||||||
ro.Duration = time.Since(start)
|
if err := ro.Record(ctx, ep.recorder.Recorder); err != nil {
|
||||||
ro.Time = time.Now()
|
log.Errorf("record: %v", err)
|
||||||
if err := ro.Record(ctx, ep.recorder.Recorder); err != nil {
|
}
|
||||||
log.Errorf("record: %v", err)
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@@ -461,7 +460,7 @@ func (ep *entrypoint) sniffingWebsocketFrame(ctx context.Context, rw, cc io.Read
|
|||||||
go func() {
|
go func() {
|
||||||
ro2 := &xrecorder.HandlerRecorderObject{}
|
ro2 := &xrecorder.HandlerRecorderObject{}
|
||||||
*ro2 = *ro
|
*ro2 = *ro
|
||||||
ro = ro2
|
ro := ro2
|
||||||
|
|
||||||
ticker := &time.Ticker{}
|
ticker := &time.Ticker{}
|
||||||
if d > 0 {
|
if d > 0 {
|
||||||
@@ -480,13 +479,12 @@ func (ep *entrypoint) sniffingWebsocketFrame(ctx context.Context, rw, cc io.Read
|
|||||||
err := ep.copyWebsocketFrame(rw, cc, buf, "server", ro)
|
err := ep.copyWebsocketFrame(rw, cc, buf, "server", ro)
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if err != nil {
|
if err == nil {
|
||||||
ro.Err = err.Error()
|
ro.Duration = time.Since(start)
|
||||||
}
|
ro.Time = time.Now()
|
||||||
ro.Duration = time.Since(start)
|
if err := ro.Record(ctx, ep.recorder.Recorder); err != nil {
|
||||||
ro.Time = time.Now()
|
log.Errorf("record: %v", err)
|
||||||
if err := ro.Record(ctx, ep.recorder.Recorder); err != nil {
|
}
|
||||||
log.Errorf("record: %v", err)
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -565,7 +565,7 @@ func (h *Sniffer) sniffingWebsocketFrame(ctx context.Context, rw, cc io.ReadWrit
|
|||||||
go func() {
|
go func() {
|
||||||
ro2 := &xrecorder.HandlerRecorderObject{}
|
ro2 := &xrecorder.HandlerRecorderObject{}
|
||||||
*ro2 = *ro
|
*ro2 = *ro
|
||||||
ro = ro2
|
ro := ro2
|
||||||
|
|
||||||
ticker := &time.Ticker{}
|
ticker := &time.Ticker{}
|
||||||
if d > 0 {
|
if d > 0 {
|
||||||
@@ -584,13 +584,12 @@ func (h *Sniffer) sniffingWebsocketFrame(ctx context.Context, rw, cc io.ReadWrit
|
|||||||
err := h.copyWebsocketFrame(cc, rw, buf, "client", ro)
|
err := h.copyWebsocketFrame(cc, rw, buf, "client", ro)
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if err != nil {
|
if err == nil {
|
||||||
ro.Err = err.Error()
|
ro.Duration = time.Since(start)
|
||||||
}
|
ro.Time = time.Now()
|
||||||
ro.Duration = time.Since(start)
|
if err := ro.Record(ctx, h.Recorder); err != nil {
|
||||||
ro.Time = time.Now()
|
log.Errorf("record: %v", err)
|
||||||
if err := ro.Record(ctx, h.Recorder); err != nil {
|
}
|
||||||
log.Errorf("record: %v", err)
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@@ -605,7 +604,7 @@ func (h *Sniffer) sniffingWebsocketFrame(ctx context.Context, rw, cc io.ReadWrit
|
|||||||
go func() {
|
go func() {
|
||||||
ro2 := &xrecorder.HandlerRecorderObject{}
|
ro2 := &xrecorder.HandlerRecorderObject{}
|
||||||
*ro2 = *ro
|
*ro2 = *ro
|
||||||
ro = ro2
|
ro := ro2
|
||||||
|
|
||||||
ticker := &time.Ticker{}
|
ticker := &time.Ticker{}
|
||||||
if d > 0 {
|
if d > 0 {
|
||||||
@@ -624,13 +623,12 @@ func (h *Sniffer) sniffingWebsocketFrame(ctx context.Context, rw, cc io.ReadWrit
|
|||||||
err := h.copyWebsocketFrame(rw, cc, buf, "server", ro)
|
err := h.copyWebsocketFrame(rw, cc, buf, "server", ro)
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if err != nil {
|
if err == nil {
|
||||||
ro.Err = err.Error()
|
ro.Duration = time.Since(start)
|
||||||
}
|
ro.Time = time.Now()
|
||||||
ro.Duration = time.Since(start)
|
if err := ro.Record(ctx, h.Recorder); err != nil {
|
||||||
ro.Time = time.Now()
|
log.Errorf("record: %v", err)
|
||||||
if err := ro.Record(ctx, h.Recorder); err != nil {
|
}
|
||||||
log.Errorf("record: %v", err)
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ func (h *Sniffer) sniffingWebsocketFrame(ctx context.Context, rw, cc io.ReadWrit
|
|||||||
go func() {
|
go func() {
|
||||||
ro2 := &xrecorder.HandlerRecorderObject{}
|
ro2 := &xrecorder.HandlerRecorderObject{}
|
||||||
*ro2 = *ro
|
*ro2 = *ro
|
||||||
ro = ro2
|
ro := ro2
|
||||||
|
|
||||||
ticker := &time.Ticker{}
|
ticker := &time.Ticker{}
|
||||||
if d > 0 {
|
if d > 0 {
|
||||||
@@ -447,13 +447,12 @@ func (h *Sniffer) sniffingWebsocketFrame(ctx context.Context, rw, cc io.ReadWrit
|
|||||||
err := h.copyWebsocketFrame(cc, rw, buf, "client", ro)
|
err := h.copyWebsocketFrame(cc, rw, buf, "client", ro)
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if err != nil {
|
if err == nil {
|
||||||
ro.Err = err.Error()
|
ro.Duration = time.Since(start)
|
||||||
}
|
ro.Time = time.Now()
|
||||||
ro.Duration = time.Since(start)
|
if err := ro.Record(ctx, h.Recorder); err != nil {
|
||||||
ro.Time = time.Now()
|
log.Errorf("record: %v", err)
|
||||||
if err := ro.Record(ctx, h.Recorder); err != nil {
|
}
|
||||||
log.Errorf("record: %v", err)
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@@ -468,7 +467,7 @@ func (h *Sniffer) sniffingWebsocketFrame(ctx context.Context, rw, cc io.ReadWrit
|
|||||||
go func() {
|
go func() {
|
||||||
ro2 := &xrecorder.HandlerRecorderObject{}
|
ro2 := &xrecorder.HandlerRecorderObject{}
|
||||||
*ro2 = *ro
|
*ro2 = *ro
|
||||||
ro = ro2
|
ro := ro2
|
||||||
|
|
||||||
ticker := &time.Ticker{}
|
ticker := &time.Ticker{}
|
||||||
if d > 0 {
|
if d > 0 {
|
||||||
@@ -487,13 +486,12 @@ func (h *Sniffer) sniffingWebsocketFrame(ctx context.Context, rw, cc io.ReadWrit
|
|||||||
err := h.copyWebsocketFrame(rw, cc, buf, "server", ro)
|
err := h.copyWebsocketFrame(rw, cc, buf, "server", ro)
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if err != nil {
|
if err == nil {
|
||||||
ro.Err = err.Error()
|
ro.Duration = time.Since(start)
|
||||||
}
|
ro.Time = time.Now()
|
||||||
ro.Duration = time.Since(start)
|
if err := ro.Record(ctx, h.Recorder); err != nil {
|
||||||
ro.Time = time.Now()
|
log.Errorf("record: %v", err)
|
||||||
if err := ro.Record(ctx, h.Recorder); err != nil {
|
}
|
||||||
log.Errorf("record: %v", err)
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user