Changeset 334 in svn


Ignore:
Timestamp:
2006-12-17T04:11:44+01:00 (9 years ago)
Author:
Xuefer
Message:

fix #56, more robust error message/handling

Location:
branches/1.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.2/mmap.c

    r302 r334  
    184184        if (strncmp(shm->name, "/dev", 4) == 0) {
    185185            perror(shm->name);
    186             errstr = "Cannot open file set by xcache.mmap_path";
     186            errstr = "Cannot open file set by xcache.mmap_path, check the xcache.size/var_size against system limitation";
    187187            goto err;
    188188        }
     
    191191        if (fd == -1) {
    192192            perror(shm->name);
    193             errstr = "Cannot open or create file set by xcache.mmap_path";
     193            errstr = "Cannot open or create file set by xcache.mmap_path, check the path permission or check xcache.size/var_size against system limitation";
    194194            goto err;
    195195        }
  • branches/1.2/xcache.c

    r328 r334  
    13721372        xc_php_caches = NULL;
    13731373    }
     1374    xc_php_hcache.size = 0;
     1375
    13741376    if (xc_var_caches) {
    13751377        shm = xc_cache_destroy(xc_var_caches, &xc_var_hcache);
    13761378        xc_var_caches = NULL;
    13771379    }
     1380    xc_var_hcache.size = 0;
     1381    fprintf(stderr, "set 0\n");
     1382
    13781383    if (shm) {
    13791384        xc_shm_destroy(shm);
    13801385    }
     1386
     1387    xc_initized = 0;
    13811388}
    13821389/* }}} */
     
    13841391{
    13851392    xc_shm_t *shm;
     1393    xc_shmsize_t shmsize = ALIGN(xc_php_size) + ALIGN(xc_var_size);
    13861394
    13871395    xc_php_caches = xc_var_caches = NULL;
     1396    shm = NULL;
     1397
     1398    if (shmsize < (size_t) xc_php_size || shmsize < (size_t) xc_var_size) {
     1399        zend_error(E_ERROR, "XCache: neither xcache.size nor xcache.var_size can be negative");
     1400        goto err;
     1401    }
    13881402
    13891403    if (xc_php_size || xc_var_size) {
    1390         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");
     1404        CHECK(shm = xc_shm_init(xc_shm_scheme, shmsize, xc_readonly_protection, xc_mmap_path, NULL), "Cannot create shm");
    13911405        if (!shm->handlers->can_readonly(shm)) {
    13921406            xc_readonly_protection = 0;
     
    14041418        }
    14051419    }
    1406     return 1;
     1420    return SUCCESS;
    14071421
    14081422err:
     1423    xc_destroy();
    14091424    if (xc_php_caches || xc_var_caches) {
    1410         xc_destroy();
    1411         /* shm destroied */
     1425        /* shm destroied in xc_destroy() */
    14121426    }
    14131427    else if (shm) {
     
    25212535
    25222536    if ((xc_php_size || xc_var_size) && xc_mmap_path && xc_mmap_path[0]) {
    2523         if (!xc_init(module_number TSRMLS_CC)) {
     2537        if (xc_init(module_number TSRMLS_CC) != SUCCESS) {
    25242538            zend_error(E_ERROR, "XCache: Cannot init");
    25252539            goto err_init;
     
    25432557    if (xc_initized) {
    25442558        xc_destroy();
    2545         xc_initized = 0;
    25462559    }
    25472560    if (xc_mmap_path) {
Note: See TracChangeset for help on using the changeset viewer.