Show
Ignore:
Timestamp:
11/20/05 18:53:43 (3 years ago)
Author:
zoeloelip
Message:

* Removed executor hooks, they weren't used anyway.
* Check if eA has a valid cache directory.
* Make the init of php fail if the initialisation of the shared memory

or cache directory failes.

* set shared memory size in eaccelerator.ini to 0 so the default OS

size is used.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eaccelerator/trunk/eaccelerator.c

    r132 r134  
    111111static zend_op_array *(*mm_saved_zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); 
    112112 
    113 #if defined(DEBUG) || defined(WITH_EACCELERATOR_EXECUTOR) 
    114 static void (*mm_saved_zend_execute)(zend_op_array *op_array TSRMLS_DC); 
    115 #endif 
    116  
    117113/* external declarations */ 
    118114PHPAPI void php_stripslashes(char *str, int *len TSRMLS_DC); 
     
    253249} 
    254250 
     251/* check the cache dir */ 
     252static int check_cache_dir(char *cache_dir) { 
     253  struct stat buf; 
     254  int uid = 0; 
     255  int gid = 0; 
     256 
     257  if (stat(cache_dir, &buf) == -1) { 
     258    ea_debug_error("Cache dir does not exist (could not stat %s)\n", cache_dir); 
     259    return 0; 
     260  } 
     261  if (!(buf.st_mode & S_IFDIR)) { 
     262    ea_debug_error("%s is not a directory!\n", cache_dir); 
     263    return 0; 
     264  } 
     265#if 0 
     266  uid = getuid(); 
     267  gid = getgid(); 
     268  if (!((buf.st_uid == uid && (buf.st_mode & (S_IRUSR | S_IWUSR))) /* not root, owner and rw */ 
     269        || (buf.st_gid == gid && (buf.st_mode & (S_IRGRP | S_IWGRP))) /* not root, group and rw */ 
     270        || (buf.st_mode & (S_IROTH & S_IWOTH)))) { /* other and rw */ 
     271    ea_debug_error("%s hasn't got the right permissions!\n", cache_dir); 
     272    return 0; 
     273  } 
     274#endif 
     275  return 1; 
     276} 
     277 
    255278/* Initialise the shared memory */ 
    256279static int init_mm(TSRMLS_D) { 
     
    304327  eaccelerator_mm_instance->last_prune = time(0); 
    305328  EACCELERATOR_PROTECT(); 
     329 
     330  if (!check_cache_dir(EAG(cache_dir))) { 
     331    return FAILURE; 
     332  } 
     333   
    306334  return SUCCESS; 
    307335} 
     
    15421570  EAG(self_time)[EAG(profile_level)] = 0; 
    15431571  EAG(profile_level)++; 
    1544 #ifdef WITH_EACCELERATOR_EXECUTOR 
    1545   eaccelerator_execute(op_array TSRMLS_CC); 
    1546 #else 
    15471572  mm_saved_zend_execute(op_array TSRMLS_CC); 
    1548 #endif 
    15491573  usec = ea_debug_elapsed_time(&tv_start); 
    15501574  EAG(profile_level)--; 
     
    20002024    if (init_mm(TSRMLS_C) == FAILURE) { 
    20012025      zend_error(E_CORE_WARNING,"[%s] Can not create shared memory area", EACCELERATOR_EXTENSION_NAME); 
     2026      return FAILURE; 
    20022027    } 
    20032028 
     
    20102035#else 
    20112036    zend_compile_file = eaccelerator_compile_file; 
    2012 #ifdef WITH_EACCELERATOR_EXECUTOR 
    2013     mm_saved_zend_execute = zend_execute; 
    2014     zend_execute = eaccelerator_execute; 
    2015 #endif 
    20162037#endif 
    20172038  } 
     
    20392060  } 
    20402061  zend_compile_file = mm_saved_zend_compile_file; 
    2041 #if defined(DEBUG) || defined(WITH_EACCELERATOR_EXECUTOR) 
    2042   zend_execute = mm_saved_zend_execute; 
    2043 #endif 
    20442062#ifdef WITH_EACCELERATOR_CONTENT_CACHING 
    20452063  eaccelerator_content_cache_shutdown();