swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.42k stars 3.16k forks source link

BIO_meth_set_callback_ctrl(_bio_methods, (long (*)(BIO *, int, BIO_info_cb *)) BIO_callback_ctrl); #5111

Closed sxin0 closed 1 year ago

sxin0 commented 1 year ago

Please answer these questions before submitting your issue.

  1. What did you do? If possible, provide a simple script for reproducing the error.

    make
    /bin/sh /home/jsx/swoole-4.5.11/libtool --mode=compile g++  -I. -I/home/jsx/swoole-4.5.11 -DPHP_ATOM_INC -I/home/jsx/swoole-4.5.11/include -I/home/jsx/swoole-4.5.11/main -I/home/jsx/swoole-4.5.11 -I/usr/local/php74/include/php -I/usr/local/php74/include/php/main -I/usr/local/php74/include/php/TSRM -I/usr/local/php74/include/php/Zend -I/usr/local/php74/include/php/ext -I/usr/local/php74/include/php/ext/date/lib -I/usr/local/openssl/include -I/home/jsx/swoole-4.5.11 -I/home/jsx/swoole-4.5.11/include -I/home/jsx/swoole-4.5.11/ext-src -I/home/jsx/swoole-4.5.11/thirdparty/hiredis  -DHAVE_CONFIG_H  -g -O2 -Wall -Wno-unused-function -Wno-deprecated -Wno-deprecated-declarations -std=c++11   -c /home/jsx/swoole-4.5.11/src/protocol/dtls.cc -o src/protocol/dtls.lo 
    g++ -I. -I/home/jsx/swoole-4.5.11 -DPHP_ATOM_INC -I/home/jsx/swoole-4.5.11/include -I/home/jsx/swoole-4.5.11/main -I/home/jsx/swoole-4.5.11 -I/usr/local/php74/include/php -I/usr/local/php74/include/php/main -I/usr/local/php74/include/php/TSRM -I/usr/local/php74/include/php/Zend -I/usr/local/php74/include/php/ext -I/usr/local/php74/include/php/ext/date/lib -I/usr/local/openssl/include -I/home/jsx/swoole-4.5.11 -I/home/jsx/swoole-4.5.11/include -I/home/jsx/swoole-4.5.11/ext-src -I/home/jsx/swoole-4.5.11/thirdparty/hiredis -DHAVE_CONFIG_H -g -O2 -Wall -Wno-unused-function -Wno-deprecated -Wno-deprecated-declarations -std=c++11 -c /home/jsx/swoole-4.5.11/src/protocol/dtls.cc  -fPIC -DPIC -o src/protocol/.libs/dtls.o
    /home/jsx/swoole-4.5.11/src/protocol/dtls.cc: 在函数‘BIO_METHOD* swoole::dtls::BIO_get_methods()’中:
    /home/jsx/swoole-4.5.11/src/protocol/dtls.cc:124:47: 错误:expected primary-expression before ‘long’
     BIO_meth_set_callback_ctrl(_bio_methods, (long (*)(BIO *, int, BIO_info_cb *)) BIO_callback_ctrl);
                                               ^
    /home/jsx/swoole-4.5.11/src/protocol/dtls.cc:124:47: 错误:expected ‘)’ before ‘long’
    make: *** [src/protocol/dtls.lo] 错误 1
  2. What did you expect to see?

    Build complete.
    Don't forget to run 'make test'.
  3. What did you see instead?

    /home/jsx/swoole-4.5.11/src/protocol/dtls.cc: 在函数‘BIO_METHOD* swoole::dtls::BIO_get_methods()’中:
    /home/jsx/swoole-4.5.11/src/protocol/dtls.cc:124:47: 错误:expected primary-expression before ‘long’
     BIO_meth_set_callback_ctrl(_bio_methods, (long (*)(BIO *, int, BIO_info_cb *)) BIO_callback_ctrl);
                                               ^
    /home/jsx/swoole-4.5.11/src/protocol/dtls.cc:124:47: 错误:expected ‘)’ before ‘long’
    make: *** [src/protocol/dtls.lo] 错误 1
  4. What version of Swoole are you using (show your php --ri swoole)?

    
    swoole

Swoole => enabled Author => Swoole Team team@swoole.com Version => 4.5.11 Built => Jul 28 2023 18:07:09 coroutine => enabled epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled openssl => OpenSSL 1.1.0d 26 Jan 2017 http2 => enabled pcre => enabled zlib => 1.2.7 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled async_redis => enabled

Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_preemptive_scheduler => Off => Off swoole.display_errors => On => On swoole.use_shortname => Off => Off swoole.unixsock_buffer_size => 8388608 => 8388608


5. What is your machine environment used (show your `uname -a` & `php -v` & `gcc -v`) ?
```bash
uname -a
Linux mjq-xiaoneng-xingzheng-test.test.xesv5.com 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

php74 -v
PHP 7.4.33 (cli) (built: Jul 28 2023 11:50:59) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

/usr/local/openssl/bin/openssl version
OpenSSL 1.1.0d  26 Jan 2017 (Library: OpenSSL 1.1.1-pre5 (beta) 17 Apr 2018)

# 我一开始用的这个版本的openssl编译的,发现在 hyperf/guzzle 中请求HTTPS时没有任何响应,没有错误,也没有输出。后面就手动编译使用了 OpenSSL 1.1.0d  26
# !!! 注意,这应该是一个bug,最好验证一下
openssl version
OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021)

怎么修复它?

make

# OpenSSL 1.1.0d  26 编译通过
Build complete.
Don't forget to run 'make test'.
NathanFreeman commented 1 year ago

这个已经在4.8以上的版本修复了https://github.com/swoole/swoole-src/pull/4835

NathanFreeman commented 1 year ago

openssl版本号小于1.1.0h的版本,只存在bio_info_cb这个结构体,不存在BIO_info_cb这个结构体,所以在编译的时候会报错

NathanFreeman commented 1 year ago

替换成这样就可以编译成功。

#if OPENSSL_VERSION_NUMBER > 0x1010007fL
    BIO_meth_set_callback_ctrl(_bio_methods, (long (*)(BIO *, int, BIO_info_cb *)) BIO_callback_ctrl);
#else
    BIO_meth_set_callback_ctrl(_bio_methods, (long (*)(BIO *, int, bio_info_cb *)) BIO_callback_ctrl);
#endif