Giter Site home page Giter Site logo

hprose / hprose-pecl Goto Github PK

View Code? Open in Web Editor NEW
55.0 8.0 20.0 451 KB

Hprose is a cross-language RPC. This project is Hprose serialize/unserialize extension for PHP

License: MIT License

PHP 6.23% Shell 0.02% C 78.81% JavaScript 0.14% M4 0.22% C++ 14.58%
serialization serializer serialization-library serialize hprose-extension cross-platform cross-language c php hprose

hprose-pecl's Introduction

HPROSE is short for High Performance Remote Object Service Engine.

It is a modern, lightweight, cross-language, cross-platform, object-oriented, high performance, remote dynamic communication middleware. It is not only easy to use, but powerful. You just need a little time to learn, then you can use it to easily construct cross language cross platform distributed application system.

It contains a semi-text serialization format, an RPC protocol and its implementation. The meaning of semi-text is all the data are represented as text, except the original binary data. The serialization format is very compact. It takes up very little space, and can be parsed very quickly in programming language. You can use this serialization format without hprose RPC protocol in other communications protocols, data storage, and more. If you want to know more, please read Hprose Specification.

Join the chat at https://gitter.im/hprose/hprose

hprose-pecl's People

Contributors

andot avatar gitter-badger avatar lao-liu avatar remicollet avatar tinkoliu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hprose-pecl's Issues

Build against 7.0.0alpha2

API change breaks the build...

Build time

hprose_service.c:1720:9: warning: implicit declaration of function 'zend_exception_get_base' [-Wimplicit-function-declaration]

Run time

 PHP Warning:  PHP Startup: Unable to load dynamic library '/builddir/build/BUILDROOT/php70-php-pecl-hprose-1.5.4-2.fc21.remi.x86_64/opt/remi/php70/root/usr/lib64/php/modules/hprose.so' - /builddir/build/BUILDROOT/php70-php-pecl-hprose-1.5.4-2.fc21.remi.x86_64/opt/remi/php70/root/usr/lib64/php/modules/hprose.so: undefined symbol: zend_exception_get_base in Unknown on line 0

php7.3 版本中pecl install hprose 报错

Makefile:196: recipe for target 'hprose_common.lo' failed
make: *** [hprose_common.lo] Error 1
ERROR: `make' failed

使用github上面的源码安装则没有这个问题

php7在安装了opcache扩展下运行的问题

env:php7 + opcache + fpm
location:hprose_writer.h function _hprose_writer_write_array

    HashTable *ht = Z_ARRVAL_P(val); // 这个val多进程共享
    int32_t i = zend_hash_num_elements(ht);
    if (refer) {
        hprose_writer_refer_set(refer, val);
    }
    hprose_bytes_io_putc(stream, HPROSE_TAG_LIST);
    if (i) {
        hprose_bytes_io_write_int(stream, i);
    }
    hprose_bytes_io_putc(stream, HPROSE_TAG_OPENBRACE);
    if (i) {
        zend_hash_internal_pointer_reset(ht);
        for (; i > 0; --i) {
#if PHP_MAJOR_VERSION < 7
            zval **e;
            zend_hash_get_current_data(ht, (void **)&e);
            _hprose_writer_serialize(_this, refer, stream, *e TSRMLS_CC);
#else
            zval *e = zend_hash_get_current_data(ht);
            _hprose_writer_serialize(_this, refer, stream, e TSRMLS_CC);
#endif
            zend_hash_move_forward(ht);
        }
    }

zval没有做分离,fpm下两个进程并发执行,会造成数组循环的数据缺失问题

Line termination inconsistency

Can you please check for line termination in generated tarball.

 $ file *.c *.h src/*.c include/*.h
 hprose.c:                       C source, ASCII text, with CRLF line terminators
 php_hprose.h:                   C source, ASCII text, with CRLF line terminators
 include/hprose.h:               C source, ASCII text, with CRLF line terminators
 ...

All others files are "C source, ASCII text"

1.6.2: Broken build PHP 5.x

Build ok (lot of warnigns), but:

 PHP Warning:  PHP Startup: Unable to load dynamic library '/dev/shm/BUILDROOT/php-pecl-hprose-1.6.2-1.fc23.remi.5.6.x86_64/usr/lib64/php/modules/hprose.so' - /dev/shm/BUILDROOT/php-pecl-hprose-1.6.2-1.fc23.remi.5.6.x86_64/usr/lib64/php/modules/hprose.so: undefined symbol: zend_error_noreturn in Unknown on line 0

PHP 7.1 build

In file included from /builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/php_hprose.c:31:0:
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_reader.h: In function 'hprose_reader_read_object_without_tag':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_reader.h:660:49: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_reader.h:661:19: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
  EG(scope) = scope;
                   ^
In file included from /builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/php_hprose.c:31:0:
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_reader.h:712:19: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
  EG(scope) = old_scope;
                   ^
In file included from /builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/php_hprose.c:29:0:
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/php_hprose.c: At top level:
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_writer.h:376:13: warning: '_hprose_writer_write_array' defined but not used [-Wunused-function]
 static void _hprose_writer_write_array(hprose_writer *_this, hprose_writer_refer *refer, hprose_bytes_io *stream, zval *val TSRMLS_DC) {
             ^
In file included from /builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/php_hprose.c:29:0:
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_writer.h:538:13: warning: '_hprose_writer_write_list' defined but not used [-Wunused-function]
 static void _hprose_writer_write_list(hprose_writer *_this, hprose_writer_refer *refer, hprose_bytes_io *stream, zval *val TSRMLS_DC) {
             ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_writer.h:552:13: warning: '_hprose_writer_write_list_with_ref' defined but not used [-Wunused-function]
 static void _hprose_writer_write_list_with_ref(hprose_writer *_this, hprose_writer_refer *refer, hprose_bytes_io *stream, zval *val TSRMLS_DC) {
             ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c: In function '__get_fcall_info_cache':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:65:46: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:83:46: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c: In function '__function_invoke_args':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:232:8: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'function_table'
     fci.function_table = NULL;
        ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:240:8: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'symbol_table'
     fci.symbol_table = NULL;
        ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c: In function '__function_invoke':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:446:8: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'function_table'
     fci.function_table = NULL;
        ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:454:8: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'symbol_table'
     fci.symbol_table = NULL;
        ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c: In function '__create_php_object':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:739:12: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'function_table'
         fci.function_table = EG(function_table);
            ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:741:12: error: 'zend_fcall_info {aka struct _zend_fcall_info}' has no member named 'symbol_table'
         fci.symbol_table = NULL;
            ^
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_common.c:750:46: error: 'zend_executor_globals {aka struct _zend_executor_globals}' has no member named 'scope'
Makefile:196: recipe for target 'hprose_common.lo' failed
make: *** [hprose_common.lo] Error 1
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_bytes_io.c: In function 'zim_hprose_bytes_io_readString':
/builddir/build/BUILD/php71-php-pecl-hprose-1.6.4/NTS/hprose_bytes_io.c:132:18: warning: unused variable 's' [-Wunused-variable]
     zend_string *s;
                  ^

Failed test in 32bits build

 + /usr/bin/php -n run-tests.php --show-diff
 =====================================================================
 PHP         : /usr/bin/php 
 PHP_SAPI    : cli
 PHP_VERSION : 5.4.39
 ZEND_VERSION: 2.4.0
 PHP_OS      : Linux - Linux schrodingerscat.famillecollet.com 3.19.3-200.fc21.x86_64 #1 SMP Thu Mar 26 21:39:42 UTC 2015 i686
 INI actual  : /builddir/build/BUILD/php-pecl-hprose-1.0.0/NTS
 More .INIs  :  
 CWD         : /builddir/build/BUILD/php-pecl-hprose-1.0.0/NTS
 Extra dirs  : 
 VALGRIND    : Not used
 =====================================================================
 TIME START 2015-04-02 07:44:22
 =====================================================================
 TEST 1/8 [tests/bytes_io.phpt]
 PASS Test that the Hprose\BytesIO class works. [tests/bytes_io.phpt] 
 TEST 2/8 [tests/class_manager.phpt]
 PASS Test that the Hprose\ClassManager class works. [tests/class_manager.phpt] 
 TEST 3/8 [tests/formatter.phpt]
 PASS Test that the Hprose\Formatter class works. [tests/formatter.phpt] 
 TEST 4/8 [tests/raw_reader.phpt]
 ========DIFF========
 011+ d-2147483648;
 011- i-2147483648;
 013+ d2147483648;
 013- l2147483648;
 ========DONE========
 FAIL Test that the Hprose\RawReader class works. [tests/raw_reader.phpt] 
 TEST 5/8 [tests/reader.phpt]
 ========DIFF========
 011+ float(-2147483648)
 011- int(-2147483648)
 013+ float(2147483648)
 013- string(10) "2147483648"
 ========DONE========
 FAIL Test that the Hprose\Reader class works. [tests/reader.phpt] 
 TEST 6/8 [tests/result_mode.phpt]
 PASS Test that the Hprose\ResultMode class works. [tests/result_mode.phpt] 
 TEST 7/8 [tests/tags.phpt]
 PASS Test that the Hprose\Tags class works. [tests/tags.phpt] 
 TEST 8/8 [tests/writer.phpt]
 ========DIFF========
 001+ 0123456789d-2147483648;i2147483647;d2147483648;d3.1415926535898;NI-I+tfenu我s2"🆚"
 001- 0123456789i-2147483648;i2147483647;l2147483648;d3.1415926535898;NI-I+tfenu我s2"🆚"
 ========DONE========
 FAIL Test that the Hprose\Writer class works. [tests/writer.phpt] 
 =====================================================================
 TIME END 2015-04-02 07:44:22
 =====================================================================
 TEST RESULT SUMMARY
 ---------------------------------------------------------------------
 Exts skipped    :    0
 Exts tested     :   29
 ---------------------------------------------------------------------
 Number of tests :    8                 8
 Tests skipped   :    0 (  0.0%) --------
 Tests warned    :    0 (  0.0%) (  0.0%)
 Tests failed    :    3 ( 37.5%) ( 37.5%)
 Expected fail   :    0 (  0.0%) (  0.0%)
 Tests passed    :    5 ( 62.5%) ( 62.5%)
 ---------------------------------------------------------------------
 Time taken      :    0 seconds
 =====================================================================
 =====================================================================
 FAILED TEST SUMMARY
 ---------------------------------------------------------------------
 Test that the Hprose\RawReader class works. [tests/raw_reader.phpt]
 Test that the Hprose\Reader class works. [tests/reader.phpt]
 Test that the Hprose\Writer class works. [tests/writer.phpt]
 =====================================================================

Segmentation fault

类定义:

class Foo
{
    protected $relations = [];

    protected $name = 2;

    /**
     * Set the specific relationship in the model.
     *
     * @param  string  $relation
     * @param  mixed  $value
     * @return $this
     */
    public function setRelation($relation, $value)
    {
        $this->relations[$relation] = $value;

        return $this;
    }
}

序列化方法

function encode($result)
{
      $stream = new BytesIO();
      $writer = new Writer($stream, false);
      $stream->write(Tags::TagResult);
      if (0 === ResultMode::Serialized) {
          $stream->write($result);
      }
      else {
          $writer->reset();
          $writer->serialize($result);
       }

      $data = $stream->toString();

      return $data;
}

调用:

$foo = new Foo();
$foo_2 = new Foo();
$foo->setRelation('sublabel', [$foo_2]);
var_dump(encode($foo));

会触发Segmentation fault, 调试了一下,里面的循环会影响到外面循环的nInternalPointer, 没再继续研究, 求助大佬帮忙看一下……^_^
(环境: php: 7.1.6, hprose: master版本也可以复现)

Failed tests with PHP 7.0

 + /opt/remi/php70/root/usr/bin/php -n run-tests.php --show-diff
 =====================================================================
 PHP         : /opt/remi/php70/root/usr/bin/php 
 PHP_SAPI    : cli
 PHP_VERSION : 7.0.0-dev
 ZEND_VERSION: 3.0.0-dev
 PHP_OS      : Linux - Linux schrodingerscat.famillecollet.com 3.19.3-200.fc21.x86_64 #1 SMP Thu Mar 26 21:39:42 UTC 2015 x86_64
 INI actual  : /builddir/build/BUILD/php70-php-pecl-hprose-1.0.0/NTS
 More .INIs  :  
 CWD         : /builddir/build/BUILD/php70-php-pecl-hprose-1.0.0/NTS
 Extra dirs  : 
 VALGRIND    : Not used
 =====================================================================
 TIME START 2015-04-02 07:41:03
 =====================================================================
 TEST 1/8 [tests/bytes_io.phpt]
 PASS Test that the Hprose\BytesIO class works. [tests/bytes_io.phpt] 
 TEST 2/8 [tests/class_manager.phpt]
 PASS Test that the Hprose\ClassManager class works. [tests/class_manager.phpt] 
 TEST 3/8 [tests/formatter.phpt]
 ========DIFF========
 014+ 
 015+ Termsig=11
 ========DONE========
 FAIL Test that the Hprose\Formatter class works. [tests/formatter.phpt] 
 TEST 4/8 [tests/raw_reader.phpt]
 ========DIFF========
 036+ 
 037+ Termsig=6
 ========DONE========
 FAIL Test that the Hprose\RawReader class works. [tests/raw_reader.phpt] 
 TEST 5/8 [tests/reader.phpt]
 ========DIFF========
 096+ Termsig=11
 ========DONE========
 FAIL Test that the Hprose\Reader class works. [tests/reader.phpt] 
 TEST 6/8 [tests/result_mode.phpt]
 PASS Test that the Hprose\ResultMode class works. [tests/result_mode.phpt] 
 TEST 7/8 [tests/tags.phpt]
 PASS Test that the Hprose\Tags class works. [tests/tags.phpt] 
 TEST 8/8 [tests/writer.phpt]
 ========DIFF========
 004+ 
 005+ Termsig=11
 ========DONE========
 FAIL Test that the Hprose\Writer class works. [tests/writer.phpt] 
 =====================================================================
 TIME END 2015-04-02 07:41:05
 =====================================================================
 TEST RESULT SUMMARY
 ---------------------------------------------------------------------
 Exts skipped    :    0
 Exts tested     :   17
 ---------------------------------------------------------------------
 Number of tests :    8                 8
 Tests skipped   :    0 (  0.0%) --------
 Tests warned    :    0 (  0.0%) (  0.0%)
 Tests failed    :    4 ( 50.0%) ( 50.0%)
 Expected fail   :    0 (  0.0%) (  0.0%)
 Tests passed    :    4 ( 50.0%) ( 50.0%)
 ---------------------------------------------------------------------
 Time taken      :    2 seconds
 =====================================================================
 =====================================================================
 FAILED TEST SUMMARY
 ---------------------------------------------------------------------
 Test that the Hprose\Formatter class works. [tests/formatter.phpt]
 Test that the Hprose\RawReader class works. [tests/raw_reader.phpt]
 Test that the Hprose\Reader class works. [tests/reader.phpt]
 Test that the Hprose\Writer class works. [tests/writer.phpt]
 =====================================================================

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.