
cherokee at cherokee-project
Jul 4, 2011, 6:20 AM
Post #1 of 1
(159 views)
Permalink
|
|
[6767] cherokee/trunk/cherokee: The QA bench stopped working on environments where Cherokee
|
|
Revision: 6767 http://svn.cherokee-project.com/changeset/6767 Author: alo Date: 2011-07-04 15:20:24 +0200 (Mon, 04 Jul 2011) Log Message: ----------- The QA bench stopped working on environments where Cherokee was not properly installed. For instance on a system where Cherokee was not "make install"ed. The problem laid on the way Cherokee tries to create Front-Line Cache's base dir. This patch improves the process so if the directory cannot be create, the server tries to create it a second under the system's temporal directory. Modified Paths: -------------- cherokee/trunk/cherokee/error_list.py cherokee/trunk/cherokee/flcache.c Modified: cherokee/trunk/cherokee/error_list.py =================================================================== --- cherokee/trunk/cherokee/error_list.py 2011-06-30 07:24:09 UTC (rev 6766) +++ cherokee/trunk/cherokee/error_list.py 2011-07-04 13:20:24 UTC (rev 6767) @@ -1348,6 +1348,10 @@ title = "Could not create the '%s' directory, or it doesn't have %s permissions", desc = SYSTEM_ISSUE) +e('FLCACHE_MKDIRS', + title = "Could not create the FLCache temporal directy neither under %s nor under %s, or it doesn't have %s permissions", + desc = SYSTEM_ISSUE) + e('FLCACHE_CREATE_FILE', title = "Could not create the '%s' cache object file: ${errno}", desc = SYSTEM_ISSUE) Modified: cherokee/trunk/cherokee/flcache.c =================================================================== --- cherokee/trunk/cherokee/flcache.c 2011-06-30 07:24:09 UTC (rev 6766) +++ cherokee/trunk/cherokee/flcache.c 2011-07-04 13:20:24 UTC (rev 6767) @@ -31,6 +31,7 @@ #include "util.h" #include "avl_flcache.h" #include "dtm.h" +#include "init.h" #define ENTRIES "flcache" @@ -110,6 +111,26 @@ return ret_ok; } +static ret_t +mkdir_flcache_directory (cherokee_flcache_t *flcache, + cherokee_virtual_server_t *vserver, + const char *basedir) +{ + /* Build the fullpath + */ + cherokee_buffer_clean (&flcache->local_directory); + cherokee_buffer_add_str (&flcache->local_directory, basedir); + cherokee_buffer_add_str (&flcache->local_directory, "/"); + cherokee_buffer_add_long10 (&flcache->local_directory, getpid()); + cherokee_buffer_add_str (&flcache->local_directory, "/"); + cherokee_buffer_add_buffer (&flcache->local_directory, &vserver->name); + + /* Create directory + */ + return cherokee_mkdir_p_perm (&flcache->local_directory, 0755, W_OK); +} + + ret_t cherokee_flcache_configure (cherokee_flcache_t *flcache, cherokee_config_node_t *conf, @@ -121,18 +142,23 @@ /* Beware: conf might be NULL */ UNUSED (conf); - cherokee_buffer_add_str (&flcache->local_directory, CHEROKEE_FLCACHE); - cherokee_buffer_add_str (&flcache->local_directory, "/"); - cherokee_buffer_add_long10 (&flcache->local_directory, getpid()); - cherokee_buffer_add_str (&flcache->local_directory, "/"); - cherokee_buffer_add_buffer (&flcache->local_directory, &vserver->name); + ret = mkdir_flcache_directory (flcache, vserver, CHEROKEE_FLCACHE); + if (ret != ret_ok) { + cherokee_buffer_t tmp = CHEROKEE_BUF_INIT; + + cherokee_buffer_add_buffer (&tmp, &cherokee_tmp_dir); + cherokee_buffer_add_str (&tmp, "/flcache"); - /* Create directory - */ - ret = cherokee_mkdir_p_perm (&flcache->local_directory, 0755, W_OK); - if (ret != ret_ok) { - LOG_CRITICAL (CHEROKEE_ERROR_FLCACHE_MKDIR, flcache->local_directory.buf, "write"); - return ret; + ret = mkdir_flcache_directory (flcache, vserver, tmp.buf); + if (ret != ret_ok) { + LOG_CRITICAL (CHEROKEE_ERROR_FLCACHE_MKDIRS, + CHEROKEE_FLCACHE, cherokee_tmp_dir.buf, "write"); + } + + cherokee_buffer_mrproper (&tmp); + if (ret != ret_ok) { + return ret; + } } /* Set the directory permissions @@ -568,7 +594,7 @@ static ret_t create_flconn_file (cherokee_flcache_t *flcache, - cherokee_connection_t *conn) + cherokee_connection_t *conn) { ret_t ret; cherokee_buffer_t tmp = CHEROKEE_BUF_INIT;
|