Skip to content

Commit

Permalink
fix.
Browse files Browse the repository at this point in the history
Signed-off-by: xuleiming <[email protected]>
  • Loading branch information
xuleiming committed Dec 3, 2024
1 parent 3a804a5 commit 5ed7898
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 164 deletions.
14 changes: 14 additions & 0 deletions bfe_modules/mod_wasmplug/conf_mod_wasmplug.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package mod_wasmplug

import (
Expand Down
14 changes: 14 additions & 0 deletions bfe_modules/mod_wasmplug/mod_wasmplug.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package mod_wasmplug

import (
Expand Down
29 changes: 13 additions & 16 deletions bfe_wasmplug/abi/proxywasm010/factory.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package proxywasm010

Expand Down
29 changes: 13 additions & 16 deletions bfe_wasmplug/abi/proxywasm010/imports.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package proxywasm010

Expand Down
29 changes: 13 additions & 16 deletions bfe_wasmplug/abi/proxywasm010/shim.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package proxywasm010

Expand Down
29 changes: 13 additions & 16 deletions bfe_wasmplug/abi/registry.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package abi

Expand Down
29 changes: 13 additions & 16 deletions bfe_wasmplug/adapter.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bfe_wasmplug

Expand Down
29 changes: 13 additions & 16 deletions bfe_wasmplug/engine.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bfe_wasmplug

Expand Down
29 changes: 13 additions & 16 deletions bfe_wasmplug/filter.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bfe_wasmplug

Expand Down
101 changes: 49 additions & 52 deletions bfe_wasmplug/plugin.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright (c) 2019 The BFE Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bfe_wasmplug

Expand Down Expand Up @@ -301,49 +298,49 @@ func (w *wasmPluginImpl) ReleaseInstance(instance common.WasmInstance) {
}

func (w *wasmPluginImpl) OnInstanceStart(instance common.WasmInstance) bool {
abi := wasmABI.GetABIList(instance)[0]
var exports v1Host.Exports
if abi != nil {
// v1
imports := &v1Imports{plugin: w}
imports.DefaultImportsHandler.Instance = instance
abi.SetImports(imports)
exports = abi.GetExports()
} else {
log.Logger.Error("[proxywasm][factory] unknown abi list: %v", abi)
return false
}

instance.Lock(abi)
defer instance.Unlock()
abi := wasmABI.GetABIList(instance)[0]
var exports v1Host.Exports
if abi != nil {
// v1
imports := &v1Imports{plugin: w}
imports.DefaultImportsHandler.Instance = instance
abi.SetImports(imports)
exports = abi.GetExports()
} else {
log.Logger.Error("[proxywasm][factory] unknown abi list: %v", abi)
return false
}

err := exports.ProxyOnContextCreate(w.rootContextID, 0)
if err != nil {
log.Logger.Error("[proxywasm][factory] OnPluginStart fail to create root context id, err: %v", err)
return true
}
instance.Lock(abi)
defer instance.Unlock()

vmConfigSize := 0
// no vm config
err := exports.ProxyOnContextCreate(w.rootContextID, 0)
if err != nil {
log.Logger.Error("[proxywasm][factory] OnPluginStart fail to create root context id, err: %v", err)
return true
}

_, err = exports.ProxyOnVmStart(w.rootContextID, int32(vmConfigSize))
if err != nil {
log.Logger.Error("[proxywasm][factory] OnPluginStart fail to create root context id, err: %v", err)
return true
}
vmConfigSize := 0
// no vm config

pluginConfigSize := 0
if pluginConfigBytes := w.GetPluginConfig(); pluginConfigBytes != nil {
pluginConfigSize = len(pluginConfigBytes)
}
_, err = exports.ProxyOnVmStart(w.rootContextID, int32(vmConfigSize))
if err != nil {
log.Logger.Error("[proxywasm][factory] OnPluginStart fail to create root context id, err: %v", err)
return true
}

_, err = exports.ProxyOnConfigure(w.rootContextID, int32(pluginConfigSize))
if err != nil {
log.Logger.Error("[proxywasm][factory] OnPluginStart fail to create root context id, err: %v", err)
return true
}
pluginConfigSize := 0
if pluginConfigBytes := w.GetPluginConfig(); pluginConfigBytes != nil {
pluginConfigSize = len(pluginConfigBytes)
}

_, err = exports.ProxyOnConfigure(w.rootContextID, int32(pluginConfigSize))
if err != nil {
log.Logger.Error("[proxywasm][factory] OnPluginStart fail to create root context id, err: %v", err)
return true
}

return true
}

func (w *wasmPluginImpl) OnPluginStart() {
Expand Down

0 comments on commit 5ed7898

Please sign in to comment.