Changeset 237


Ignore:
Timestamp:
07/24/06 14:49:43 (4 years ago)
Author:
bart
Message:
  • Make clean routine support dir hashing. Again, this should be tested on win32!
  • Use a define for the magic string in the eAccelerator file headers
  • Bump up version to 0.9.5-rc1
  • Put -O2 back on for -rc1
Location:
eaccelerator/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • eaccelerator/trunk/ChangeLog

    r236 r237  
     12006-07-24  Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
     2 
     3        * Make clean routine support dir hashing. Again, this should be tested 
     4          on win32! 
     5        * Use a define for the magic string in the eAccelerator file headers 
     6        * Bump up version to 0.9.5-rc1 
     7        * Put -O2 back on for -rc1 
     8 
    192006-07-23  Hans Rakers <hans at parse dot nl> 
    210        * Fix for ticket #47 and #63, related to problems restoring empty 
  • eaccelerator/trunk/Makefile.in

    r202 r237  
    33LTLIBRARY_SHARED_NAME = eaccelerator.la 
    44 
    5 EXTRA_CFLAGS = -O2  
     5EXTRA_CFLAGS = -O2 -g -Wall  
    66 
    77include $(top_srcdir)/build/dynlib.mk 
  • eaccelerator/trunk/cache.c

    r207 r237  
    270270                mm_file_header hdr; 
    271271                EACCELERATOR_FLOCK(f, LOCK_EX); 
    272                 strncpy(hdr.magic, "EACCELERATOR", 8); 
     272                strncpy(hdr.magic, EA_MAGIC, 8); 
    273273                hdr.eaccelerator_version = binary_eaccelerator_version; 
    274274                hdr.zend_version = binary_zend_version; 
     
    392392 
    393393            EACCELERATOR_FLOCK(f, LOCK_SH); 
    394             if (read(f, &hdr, sizeof(hdr)) != sizeof(hdr) || strncmp(hdr.magic, "EACCELERATOR", 8) != 0 ||  
     394            if (read(f, &hdr, sizeof(hdr)) != sizeof(hdr) || strncmp(hdr.magic, EA_MAGIC, 8) != 0 ||  
    395395                    hdr.eaccelerator_version != binary_eaccelerator_version || hdr.zend_version != binary_zend_version  
    396396                    || hdr.php_version != binary_php_version) { 
  • eaccelerator/trunk/ea_info.c

    r232 r237  
    107107                closedir (dp); 
    108108        } else { 
    109                 ea_debug_error("eAccelerator: Could not open cachedir %s\n", dir); 
     109                ea_debug_error("[%s] Could not open cachedir %s\n", EACCELERATOR_EXTENSION_NAME, dir); 
    110110        } 
    111111} 
     
    118118   
    119119    memcpy(path, dir, dirlen); 
    120     strcpy(path + dirlen++, "\\*"); 
     120    strcpy(path + dirlen++, "\\eaccelerator*"); 
    121121 
    122122    hFind = FindFirstFile(path, &wfd); 
     
    127127                                clear_filecache(path); 
    128128                        } else if (!DeleteFile(path)) { 
    129                                 zend_error(E_CORE_WARNING, "Can't delete file %s: error %d", path, GetLastError()); 
     129                                ea_debug_error("[%s] Can't delete file %s: error %d\n", EACCELERATOR_EXTENSION_NAME, path, GetLastError()); 
     130                        } 
     131                } while (FindNextFile(hFind, &wfd)); 
     132        } 
     133    FindClose (hFind); 
     134} 
     135#endif 
     136/* }}} */ 
     137 
     138/* {{{  clean_file: check if the given file is expired */ 
     139static inline void clean_file(char *file, time_t t)  
     140{ 
     141        int f; 
     142 
     143        if ((f = open(file, O_RDONLY | O_BINARY)) > 0) { 
     144                mm_file_header hdr; 
     145                EACCELERATOR_FLOCK (f, LOCK_SH); 
     146                if (read(f, &hdr, sizeof(hdr)) != sizeof(hdr)  
     147                                || strncmp (hdr.magic, EA_MAGIC,        8) != 0  
     148                                || (hdr.mtime != 0 && hdr.mtime < t)) { 
     149                        EACCELERATOR_FLOCK (f, LOCK_UN); 
     150                        close (f); 
     151                        unlink (file); 
     152                } else { 
     153                        EACCELERATOR_FLOCK (f, LOCK_UN); 
     154                        close (f); 
     155                } 
     156        } 
     157} 
     158/* }}} */ 
     159 
     160/* {{{ clean_filecache(): Helper function for eaccelerator_clean, it will remove all expired entries from the user cache */ 
     161static void clean_filecache(const char* dir, time_t t) 
     162#ifndef ZEND_WIN32 
     163{ 
     164        DIR *dp; 
     165        struct dirent *entry; 
     166        char s[MAXPATHLEN]; 
     167        struct stat dirstat; 
     168         
     169        if ((dp = opendir(dir)) != NULL) { 
     170                while ((entry = readdir(dp)) != NULL) { 
     171                        strncpy(s, dir, MAXPATHLEN - 1); 
     172                        strlcat(s, "/", MAXPATHLEN); 
     173                        strlcat(s, entry->d_name, MAXPATHLEN); 
     174                        if (strstr(entry->d_name, "eaccelerator-user") == entry->d_name) { 
     175                                clean_file(s, t); 
     176                        } 
     177                        if (stat(s, &dirstat) != -1) { 
     178                                if (strcmp(entry->d_name, ".") == 0) 
     179                                        continue; 
     180                                if (strcmp(entry->d_name, "..") == 0) 
     181                                        continue; 
     182                                if (S_ISDIR(dirstat.st_mode)) { 
     183                                        clean_filecache(s, t); 
     184                                } 
     185                        } 
     186                } 
     187                closedir (dp); 
     188        } else { 
     189                ea_debug_error("[%s] Could not open cachedir %s\n", EACCELERATOR_EXTENSION_NAME, dir); 
     190        } 
     191} 
     192#else 
     193{ 
     194        HANDLE  hFind; 
     195    WIN32_FIND_DATA wfd; 
     196    char path[MAXPATHLEN]; 
     197    size_t dirlen = strlen(dir); 
     198   
     199    memcpy(path, dir, dirlen); 
     200    strcpy(path + dirlen++, "\\eaccelerator-user*"); 
     201 
     202    hFind = FindFirstFile(path, &wfd); 
     203        if (hFind == INVALID_HANDLE_VALUE) { 
     204                do { 
     205                        strcpy(path + dirlen, wfd.cFileName); 
     206                        if (FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes) { 
     207                                clear_filecache(path); 
     208                        } else { 
     209                                clean_file(path, t); 
    130210                        } 
    131211                } while (FindNextFile(hFind, &wfd)); 
     
    202282 
    203283        /* Remove expired keys (session data, content) from disk cache */ 
    204 #ifndef ZEND_WIN32 
    205         /* clear file cache */ 
    206         { 
    207                 DIR *dp; 
    208                 struct dirent *entry; 
    209                 char s[MAXPATHLEN]; 
    210  
    211                 if ((dp = opendir (EAG (cache_dir))) != NULL) { 
    212                         while ((entry = readdir (dp)) != NULL) { 
    213                                 if (strstr(entry->d_name, "eaccelerator-user") == entry->d_name) { 
    214                                         int f; 
    215                                         strncpy (s, EAG (cache_dir), MAXPATHLEN - 1); 
    216                                         strlcat (s, "/", MAXPATHLEN); 
    217                                         strlcat (s, entry->d_name, MAXPATHLEN); 
    218                                         if ((f = open (s, O_RDONLY | O_BINARY)) > 0) { 
    219                                                 mm_file_header hdr; 
    220                                                 EACCELERATOR_FLOCK (f, LOCK_SH); 
    221                                                 if (read (f, &hdr, sizeof (hdr)) != sizeof (hdr)  
    222                                 || strncmp (hdr.magic, "EACCELERATOR",  8) != 0 || (hdr.mtime != 0 && hdr.mtime < t)) { 
    223                                                         EACCELERATOR_FLOCK (f, LOCK_UN); 
    224                                                         close (f); 
    225                                                         unlink (s); 
    226                                                 } else { 
    227                                                         EACCELERATOR_FLOCK (f, LOCK_UN); 
    228                                                         close (f); 
    229                                                 } 
    230                                         } 
    231                                 } 
    232                         } 
    233                         closedir (dp); 
    234                 } 
    235         } 
    236 #else 
    237         { 
    238                 HANDLE hList; 
    239                 TCHAR szDir[MAXPATHLEN]; 
    240                 WIN32_FIND_DATA FileData; 
    241                 char s[MAXPATHLEN]; 
    242  
    243                 snprintf (szDir, MAXPATHLEN, "%s\\eaccelerator-user*", EAG (cache_dir)); 
    244  
    245                 if ((hList = FindFirstFile (szDir, &FileData)) != INVALID_HANDLE_VALUE) { 
    246                         do { 
    247                                 int f; 
    248                                 strncpy (s, EAG (cache_dir), MAXPATHLEN - 1); 
    249                                 strlcat (s, "\\", MAXPATHLEN); 
    250                                 strlcat (s, FileData.cFileName, MAXPATHLEN); 
    251                                 if ((f = open (s, O_RDONLY | O_BINARY)) > 0) { 
    252                                         mm_file_header hdr; 
    253                                         EACCELERATOR_FLOCK (f, LOCK_SH); 
    254                                         if (read (f, &hdr, sizeof (hdr)) != sizeof (hdr)  
    255                             || strncmp (hdr.magic, "EACCELERATOR", 8) != 0 || (hdr.mtime != 0 && hdr.mtime < t)) { 
    256                                                 EACCELERATOR_FLOCK (f, LOCK_UN); 
    257                                                 close (f); 
    258                                                 unlink (s); 
    259                                         } else { 
    260                                                 EACCELERATOR_FLOCK (f, LOCK_UN); 
    261                                                 close (f); 
    262                                         } 
    263                                 } 
    264                         } 
    265                         while (FindNextFile (hList, &FileData)); 
    266                 } 
    267                 FindClose (hList); 
    268         } 
    269 #endif 
     284        clean_filecache(EAG(cache_dir), t); 
     285 
    270286        /* Remove expired keys (session data, content) from shared memory */ 
    271287        eaccelerator_gc (TSRMLS_C); 
  • eaccelerator/trunk/eaccelerator.c

    r228 r237  
    634634      return NULL; 
    635635    } 
    636     if (strncmp(hdr.magic,"EACCELERATOR",8) != 0 || 
     636    if (strncmp(hdr.magic, EA_MAGIC, 8) != 0 || 
    637637        hdr.eaccelerator_version != binary_eaccelerator_version || 
    638638        hdr.zend_version != binary_zend_version || 
     
    732732  if (f > 0) { 
    733733    EACCELERATOR_FLOCK(f, LOCK_EX); 
    734     strncpy(hdr.magic, "EACCELERATOR", 8); 
     734    strncpy(hdr.magic, EA_MAGIC, 8); 
    735735    hdr.eaccelerator_version = binary_eaccelerator_version; 
    736736    hdr.zend_version    = binary_zend_version; 
  • eaccelerator/trunk/eaccelerator.h

    r222 r237  
    486486#define EACCELERATOR_LOADER_EXTENSION_NAME "eLoader" 
    487487 
     488#define EA_MAGIC "EACCELERATOR" 
     489 
    488490#define EA_ENCODER_VERSION   0x00000004 
    489491#define EA_ENCODER_END       0x00 
  • eaccelerator/trunk/eaccelerator_version.h

    r197 r237  
    11#ifndef EACCELERATOR_VERSION 
    2 #define EACCELERATOR_VERSION "0.9.5-beta2" 
     2#define EACCELERATOR_VERSION "0.9.5-rc1" 
    33#endif 
Note: See TracChangeset for help on using the changeset viewer.