Changeset 337 in svn for trunk/xcache.c


Ignore:
Timestamp:
2006-12-17T03:20:43Z (9 years ago)
Author:
Xuefer
Message:

1.2->trunk: [334] robust error handling on shm init

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/xcache.c

    r329 r337  
    15411541        xc_php_caches = NULL;
    15421542    }
     1543    xc_php_hcache.size = 0;
     1544
    15431545    if (xc_var_caches) {
    15441546        shm = xc_cache_destroy(xc_var_caches, &xc_var_hcache);
    15451547        xc_var_caches = NULL;
    15461548    }
     1549    xc_var_hcache.size = 0;
     1550    fprintf(stderr, "set 0\n");
     1551
    15471552    if (shm) {
    15481553        xc_shm_destroy(shm);
    15491554    }
     1555
     1556    xc_initized = 0;
    15501557}
    15511558/* }}} */
     
    15531560{
    15541561    xc_shm_t *shm;
     1562    xc_shmsize_t shmsize = ALIGN(xc_php_size) + ALIGN(xc_var_size);
    15551563
    15561564    xc_php_caches = xc_var_caches = NULL;
     1565    shm = NULL;
     1566
     1567    if (shmsize < (size_t) xc_php_size || shmsize < (size_t) xc_var_size) {
     1568        zend_error(E_ERROR, "XCache: neither xcache.size nor xcache.var_size can be negative");
     1569        goto err;
     1570    }
    15571571
    15581572    if (xc_php_size || xc_var_size) {
    1559         CHECK(shm = xc_shm_init(xc_shm_scheme, ALIGN(xc_php_size) + ALIGN(xc_var_size), xc_readonly_protection, xc_mmap_path, NULL), "Cannot create shm");
     1573        CHECK(shm = xc_shm_init(xc_shm_scheme, shmsize, xc_readonly_protection, xc_mmap_path, NULL), "Cannot create shm");
    15601574        if (!shm->handlers->can_readonly(shm)) {
    15611575            xc_readonly_protection = 0;
     
    15731587        }
    15741588    }
    1575     return 1;
     1589    return SUCCESS;
    15761590
    15771591err:
     1592    xc_destroy();
    15781593    if (xc_php_caches || xc_var_caches) {
    1579         xc_destroy();
    1580         /* shm destroied */
     1594        /* shm destroied in xc_destroy() */
    15811595    }
    15821596    else if (shm) {
     
    26782692
    26792693    if ((xc_php_size || xc_var_size) && xc_mmap_path && xc_mmap_path[0]) {
    2680         if (!xc_init(module_number TSRMLS_CC)) {
     2694        if (xc_init(module_number TSRMLS_CC) != SUCCESS) {
    26812695            zend_error(E_ERROR, "XCache: Cannot init");
    26822696            goto err_init;
     
    27002714    if (xc_initized) {
    27012715        xc_destroy();
    2702         xc_initized = 0;
    27032716    }
    27042717    if (xc_mmap_path) {
Note: See TracChangeset for help on using the changeset viewer.