Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 4fc6d67

Browse files
committed
fix e2e
Signed-off-by: mathetake <[email protected]>
1 parent e601de4 commit 4fc6d67

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

examples/http_auth_random/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ func (ctx *httpAuthRandom) OnHttpRequestHeaders(int, bool) types.Action {
4848
proxywasm.LogInfof("request header: %s: %s", h[0], h[1])
4949
}
5050

51-
if _, err := proxywasm.DispatchHttpCall(clusterName, hs, "", [][2]string{},
51+
if err := proxywasm.DispatchHttpCall(clusterName, hs, "", [][2]string{},
5252
50000, httpCallResponseCallback); err != nil {
5353
proxywasm.LogCriticalf("dipatch httpcall failed: %v", err)
54+
return types.ActionContinue
5455
}
5556

5657
proxywasm.LogInfof("http call dispatched to %s", clusterName)
57-
5858
return types.ActionPause
5959
}
6060

proxywasm/hostcall.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func GetCurrentTime() int64 {
5252

5353
func DispatchHttpCall(upstream string,
5454
headers [][2]string, body string, trailers [][2]string,
55-
timeoutMillisecond uint32, callBack HttpCalloutCallBack) (uint32, error) {
55+
timeoutMillisecond uint32, callBack HttpCalloutCallBack) error {
5656
shs := SerializeMap(headers)
5757
hp := &shs[0]
5858
hl := len(shs)
@@ -68,9 +68,9 @@ func DispatchHttpCall(upstream string,
6868
hp, hl, stringBytePtr(body), len(body), tp, tl, timeoutMillisecond, &calloutID); st {
6969
case types.StatusOK:
7070
currentState.registerHttpCallOut(calloutID, callBack)
71-
return calloutID, nil
71+
return nil
7272
default:
73-
return 0, types.StatusToError(st)
73+
return types.StatusToError(st)
7474
}
7575
}
7676

proxywasm/vmstate.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ type state struct {
3535
httpStreams map[uint32]HttpContext
3636

3737
contextIDToRooID map[uint32]uint32
38-
activeContextID uint32 // TODO: set anywhere
38+
activeContextID uint32
3939
}
4040

4141
var currentState = &state{
42-
rootContexts: make(map[uint32]*rootContextState),
43-
httpStreams: make(map[uint32]HttpContext),
44-
streams: make(map[uint32]StreamContext),
42+
rootContexts: make(map[uint32]*rootContextState),
43+
httpStreams: make(map[uint32]HttpContext),
44+
streams: make(map[uint32]StreamContext),
45+
contextIDToRooID: make(map[uint32]uint32),
4546
}
4647

4748
func SetNewRootContext(f func(contextID uint32) RootContext) {
@@ -65,13 +66,12 @@ func (s *state) createRootContext(contextID uint32) {
6566
ctx = s.newRootContext(contextID)
6667
}
6768

68-
LogInfof("createRootContext for contextID: %d", contextID)
6969
s.rootContexts[contextID] = &rootContextState{
7070
context: ctx,
71-
httpCallbacks: make(map[uint32]*struct {
71+
httpCallbacks: map[uint32]*struct {
7272
f HttpCalloutCallBack
7373
contextID uint32
74-
}),
74+
}{},
7575
}
7676
}
7777

@@ -85,6 +85,7 @@ func (s *state) createStreamContext(contextID uint32, rootContextID uint32) {
8585
}
8686

8787
ctx := s.newStreamContext(contextID)
88+
s.contextIDToRooID[contextID] = rootContextID
8889
s.streams[contextID] = ctx
8990
}
9091

@@ -98,6 +99,7 @@ func (s *state) createHttpContext(contextID uint32, rootContextID uint32) {
9899
}
99100

100101
ctx := s.newHttpContext(contextID)
102+
s.contextIDToRooID[contextID] = rootContextID
101103
s.httpStreams[contextID] = ctx
102104
}
103105

0 commit comments

Comments
 (0)