Opened 6 years ago

Last modified 8 days ago

#198 new enhancement

xcache with streams on ZEND_ENGINE_2

Reported by: lang@… Owned by: moo
Priority: major Milestone: 4.0.0
Component: cacher Version: 1.3.0
Keywords: Cc:
Application: PHP Version:
Other Exts: SAPI: Irrelevant
Probability: Blocked By:
Blocking:

Description (last modified by moo)

Hi xcache developers,
this patch permits to process streams from xcache on ZEND_ENGINE_2. It is very helpfully when a php module use streams.

  • xcache-1.2.

    diff -u -r -N xcache-1.2.2/xcache.c xcache-1.2.2-patch/xcache.c
    old new  
    727727       php = xce->data.php; 
    728728 
    729729       if (XG(stat)) { 
     730 
     731#ifdef ZEND_ENGINE_2 
     732               php_stream_statbuf ssb; 
     733               php_stream_wrapper *wrapper = NULL; 
     734               char *path_for_open = NULL; 
     735 
     736               wrapper = php_stream_locate_url_wrapper(filename, &path_for_open, 0 TSRMLS_CC); 
     737               if ((wrapper) && (wrapper->wops) && (wrapper->wops->url_stat) && 
     738                   (wrapper != &php_plain_files_wrapper) && 
     739                   (SUCCESS == wrapper->wops->url_stat(wrapper, path_for_open, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL TSRMLS_CC))) { 
     740                       pbuf = &ssb.sb; 
     741                       goto stat_done; 
     742               } 
     743#endif 
     744 
    730745               if (strcmp(SG(request_info).path_translated, filename) == 0) { 
    731746                       /* sapi has already done this stat() for us */ 
    732747                       pbuf = sapi_get_stat(TSRMLS_C); 

Attachments (5)

xcache-2.0.1-stream-patch (2.1 KB) - added by hlang 2 years ago.
patch cache php modul streams in xcache version 2.0.x
xcache-1.3.2-stream-patch (1.1 KB) - added by hlang 2 years ago.
patch cache php modul streams in xcache version 1.3.x
xcache-1.2.2-stream-patch (909 bytes) - added by hlang 2 years ago.
patch cache php modul streams in xcache version 1.2.x
xcache-trunk-stream-patch (2.1 KB) - added by hlang 2 years ago.
patch cache php modul streams in xcache version 3.0.0
phpmodulstream.tgz (19.5 KB) - added by hlang 2 years ago.
modul code for test case phpmodulstream

Download all attachments as: .zip

Change History (21)

comment:1 Changed 6 years ago by moo

  • Description modified (diff)
  • Status changed from new to accepted

comment:2 Changed 6 years ago by judas_iscariote

This patch looks fine, moo what you think ?

comment:3 in reply to: ↑ description Changed 5 years ago by hlang

  • Milestone changed from 1.3.1 to 1.4.0
  • Version changed from 1.2.2 to 1.3.0

Hi xcache developers, this is the new patch of the xcache version 1.3.0 for the feature to cache streams by xcache.
I think still always this is very helpfully.

  • xcache-1.3.

    old new  
    800800        return FAILURE; 
    801801    } 
    802802 
     803    /* 
    803804    if (strstr(filename, "://") != NULL) { 
    804805        return FAILURE; 
    805806    } 
     807    */ 
    806808 
    807809    php = xce->data.php; 
    808810 
    809811    if (XG(stat)) { 
     812 
     813#ifdef ZEND_ENGINE_2 
     814        php_stream_statbuf ssb; 
     815        php_stream_wrapper *wrapper = NULL; 
     816        char *path_for_open = NULL; 
     817 
     818        wrapper = php_stream_locate_url_wrapper(filename, &path_for_open, 0 TSRMLS_CC); 
     819        if ((wrapper) && (wrapper->wops) && (wrapper->wops->url_stat) && 
     820            (wrapper != &php_plain_files_wrapper) &&  
     821            (SUCCESS == wrapper->wops->url_stat(wrapper, path_for_open, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL TSRMLS_CC))) { 
     822            pbuf = &ssb.sb; 
     823            goto stat_done; 
     824        } 
     825#endif 
     826 
    810827        if (strcmp(SG(request_info).path_translated, filename) == 0) { 
    811828            /* sapi has already done this stat() for us */ 
    812829            pbuf = sapi_get_stat(TSRMLS_C); 

comment:4 Changed 2 years ago by moo

  • Status changed from accepted to new

comment:5 Changed 2 years ago by moo

  • Resolution set to fixed
  • Status changed from new to closed

already in 2.0. reopen bug if there's problem with streams

comment:6 Changed 2 years ago by moo

  • Milestone changed from 3.0.0 to 2.0.0

Changed 2 years ago by hlang

patch cache php modul streams in xcache version 2.0.x

Changed 2 years ago by hlang

patch cache php modul streams in xcache version 1.3.x

Changed 2 years ago by hlang

patch cache php modul streams in xcache version 1.2.x

comment:7 Changed 2 years ago by hlang

  • Resolution fixed deleted
  • Status changed from closed to reopened

hello,

php modul streams does always not work with xcache.
the function xc_compile_file() excludes the posibility.
xcache could also accelerate php modul streams.

i attached the patch to cache php modul streams in xcache version 2.0.x

comment:8 Changed 2 years ago by moo

please also provide your test case

comment:9 Changed 2 years ago by hlang

the test case is attached as phpmodulstream.tgz

# to create phpmodulstream.so
phpize
./configure
make

# find the php modul phpmodulstream.so in subdir modules

# add the phpmodulstream.so to your php configuration
# in extension path
extension=phpmodulstream.so
# or absolute path
extension=/<your>/<current>/<make>/<path>/modules/phpmodulstream.so

# restart apache

# correct installation shows part phpmodulstream in phpinfo()

# move test.php to htdocs and call it from browser
# access for stream is phpmodulstream://whatever...
# example
require_once 'phpmodulstream://blafasel.php';

# xcache work correct when reload from test.php shown always same time

comment:10 Changed 2 years ago by moo

  • Milestone changed from 2.0.0 to 3.0.0

Changed 2 years ago by hlang

patch cache php modul streams in xcache version 3.0.0

Changed 2 years ago by hlang

modul code for test case phpmodulstream

comment:11 Changed 2 years ago by hlang

i attach the patch for xcache-trunc

comment:12 Changed 2 years ago by moo

thanks. The logic of that part in XCache need to be rechecked for both optimize and feature

comment:13 Changed 2 years ago by moo

  • Resolution set to fixed
  • Status changed from reopened to closed

the patch is rewrite carefully, committed as [1140] for trunk (3.0.0-dev). please try it out

i thought the test case was simply *.php code. i wonder if user defined stream protocol can be include()'d and cached correctly. i'd like there be some *.phpt code for this under xcache/tests/

thanks for your time making patch. but XCache dev has stopped adding features to 2.0.x 1.3.x 1.2.x. not new release for 1.3.x 1.2.x critical security problem

comment:14 Changed 2 years ago by hlang

i'm so happy.
i test your commit and it run perfect.
we use this stream access over 10 years and only xcache can cache streams really stable.

thank you for that implemention.

comment:15 Changed 8 days ago by moo

  • Resolution fixed deleted
  • Status changed from closed to new

unfortunately when url_stat is not implemented it will always raise error: "%s::" USERSTREAM_STATURL " is not implemented!"

I'm looking to see a solution to this problem.

comment:16 Changed 8 days ago by moo

  • Milestone changed from 3.0.0 to 4.0.0
Note: See TracTickets for help on using tickets.