This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 325879d71 fix(xds): handle removed symbol in apisix-base (#7160)
325879d71 is described below
commit 325879d7179202341c65897ca261fbb30b72de32
Author: 罗泽轩 <[email protected]>
AuthorDate: Mon May 30 08:59:10 2022 +0800
fix(xds): handle removed symbol in apisix-base (#7160)
It causes the CI error:
https: //github.com/apache/apisix/runs/6643228643?check_suite_focus=true
Signed-off-by: spacewander <[email protected]>
---
.github/workflows/build.yml | 2 +-
.github/workflows/centos7-ci.yml | 2 +-
.gitignore | 1 +
apisix/core/config_xds.lua | 12 +++++++--
t/xds-library/export.go | 26 +++++++++++++++++++
t/xds-library/main.go | 12 +++------
t/xds-library/xds.h | 55 ++++++++++++++++++++++++++++++++++++++++
7 files changed, 98 insertions(+), 12 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index a2191c640..bd199672e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -93,7 +93,7 @@ jobs:
- name: Build xDS library
run: |
cd t/xds-library
- go build -o libxds.so -buildmode=c-shared main.go
+ go build -o libxds.so -buildmode=c-shared main.go export.go
- name: Linux Before install
run: sudo ./ci/${{ matrix.os_name }}_runner.sh before_install
diff --git a/.github/workflows/centos7-ci.yml b/.github/workflows/centos7-ci.yml
index ee56e03bc..9b2f8fc81 100644
--- a/.github/workflows/centos7-ci.yml
+++ b/.github/workflows/centos7-ci.yml
@@ -68,7 +68,7 @@ jobs:
- name: Build xDS library
run: |
cd t/xds-library
- go build -o libxds.so -buildmode=c-shared main.go
+ go build -o libxds.so -buildmode=c-shared main.go export.go
- name: Run centos7 docker and mapping apisix into container
env:
diff --git a/.gitignore b/.gitignore
index 20dad9147..33afe64aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,6 +45,7 @@ luac.out
*.orig
*.rej
t/servroot
+t/xds-library/libxds.h
conf/apisix.uid
conf/nginx.conf
deps
diff --git a/apisix/core/config_xds.lua b/apisix/core/config_xds.lua
index 05f97f5c0..e5e452f7e 100644
--- a/apisix/core/config_xds.lua
+++ b/apisix/core/config_xds.lua
@@ -58,6 +58,14 @@ if is_http then
process = require("ngx.process")
end
+local shdict_udata_to_zone
+if not pcall(function() return C.ngx_http_lua_ffi_shdict_udata_to_zone end)
then
+ shdict_udata_to_zone = C.ngx_meta_lua_ffi_shdict_udata_to_zone
+else
+ shdict_udata_to_zone = C.ngx_http_lua_ffi_shdict_udata_to_zone
+end
+
+
ffi.cdef[[
typedef unsigned int useconds_t;
@@ -127,10 +135,10 @@ local function load_libxds(lib_name)
table.concat(tried_paths, '\r\n', 1, #tried_paths))
end
- local config_zone = C.ngx_http_lua_ffi_shdict_udata_to_zone(config[1])
+ local config_zone = shdict_udata_to_zone(config[1])
local config_shd_cdata = ffi.cast("void*", config_zone)
- local conf_ver_zone = C.ngx_http_lua_ffi_shdict_udata_to_zone(conf_ver[1])
+ local conf_ver_zone = shdict_udata_to_zone(conf_ver[1])
local conf_ver_shd_cdata = ffi.cast("void*", conf_ver_zone)
xdsagent.initial(config_shd_cdata, conf_ver_shd_cdata)
diff --git a/t/xds-library/export.go b/t/xds-library/export.go
new file mode 100644
index 000000000..afb4680e1
--- /dev/null
+++ b/t/xds-library/export.go
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package main
+
+import "C"
+import "unsafe"
+
+//export initial
+func initial(config_zone unsafe.Pointer, version_zone unsafe.Pointer) {
+ write_config(config_zone, version_zone)
+}
diff --git a/t/xds-library/main.go b/t/xds-library/main.go
index b682d1358..4327d8305 100644
--- a/t/xds-library/main.go
+++ b/t/xds-library/main.go
@@ -18,10 +18,11 @@
package main
/*
-#cgo LDFLAGS: -shared
+#cgo LDFLAGS: -shared -ldl
+#include "xds.h"
#include <stdlib.h>
-extern void ngx_http_lua_ffi_shdict_store(void *zone, int op,
+extern void ngx_lua_ffi_shdict_store(void *zone, int op,
const unsigned char *key, size_t key_len,
int value_type,
const unsigned char *str_value_buf, size_t str_value_len,
@@ -42,11 +43,6 @@ import (
func main() {
}
-//export initial
-func initial(config_zone unsafe.Pointer, version_zone unsafe.Pointer) {
- write_config(config_zone, version_zone)
-}
-
func write_config(config_zone unsafe.Pointer, version_zone unsafe.Pointer) {
route_key := "/routes/1"
route_value := fmt.Sprintf(`{
@@ -127,7 +123,7 @@ func write_shdict(key string, value string, zone
unsafe.Pointer) {
errMsgBuf := make([]*C.char, 1)
var forcible = 0
- C.ngx_http_lua_ffi_shdict_store(zone, 0x0004,
+ C.ngx_lua_ffi_shdict_store(zone, 0x0004,
(*C.uchar)(unsafe.Pointer(keyCStr)), keyLen,
4,
(*C.uchar)(unsafe.Pointer(valueCStr)), valueLen,
diff --git a/t/xds-library/xds.h b/t/xds-library/xds.h
new file mode 100644
index 000000000..48a8735f9
--- /dev/null
+++ b/t/xds-library/xds.h
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+#ifndef XDS_H
+#define XDS_H
+#include <dlfcn.h>
+#include <stdlib.h>
+
+
+void ngx_lua_ffi_shdict_store(void *zone, int op,
+ const unsigned char *key, size_t key_len,
+ int value_type,
+ const unsigned char *str_value_buf, size_t str_value_len,
+ double num_value, long exptime, int user_flags, char **errmsg,
+ int *forcible)
+{
+ static void* dlhandle;
+ static void (*fp)(void *zone, int op,
+ const unsigned char *key, size_t key_len,
+ int value_type,
+ const unsigned char *str_value_buf, size_t str_value_len,
+ double num_value, long exptime, int user_flags, char
**errmsg,
+ int *forcible);
+
+ if (!dlhandle) {
+ dlhandle = dlopen(NULL, RTLD_NOW);
+ }
+ if (!dlhandle) {
+ return;
+ }
+
+ fp = dlsym(dlhandle, "ngx_http_lua_ffi_shdict_store");
+ if (!fp) {
+ fp = dlsym(dlhandle, "ngx_meta_lua_ffi_shdict_store");
+ }
+
+ fp(zone, op, key, key_len, value_type, str_value_buf, str_value_len,
+ num_value, exptime, user_flags, errmsg, forcible);
+}
+
+
+#endif // XDS_H