Permalink
Browse files

Improves how the 'cherokee' temporal directory was being created.

It fixes bug #1213: http://bugs.cherokee-project.com/1213

git-svn-id: svn://cherokee-project.com/cherokee/trunk@6739 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
alobbs committed Jun 1, 2011
1 parent 7b455e4 commit b226fc856f880eed317035cb0bc27fce31f726b4
Showing with 27 additions and 7 deletions.
  1. +21 −2 cherokee/init.c
  2. +3 −3 cherokee/main_admin.c
  3. +3 −2 cherokee/rrd_tools.c
View
@@ -43,6 +43,23 @@ cherokee_null_bool_t cherokee_readable_errors;
static cherokee_boolean_t _cherokee_init = false;
+static ret_t
+init_tmp_dir (void)
+{
+ ret_t ret;
+
+ cherokee_buffer_init (&cherokee_tmp_dir);
+ cherokee_tmp_dir_copy (&cherokee_tmp_dir);
+ cherokee_buffer_add_str (&cherokee_tmp_dir, "/cherokee.XXXXXXXXXXX");
+
+ ret = cherokee_mkdtemp (cherokee_tmp_dir.buf);
+ if (unlikely (ret != ret_ok)) {
+ return ret_error;
+ }
+
+ return ret_ok;
+}
+
ret_t
cherokee_init (void)
{
@@ -90,8 +107,10 @@ cherokee_init (void)
/* Temp directory
*/
- cherokee_buffer_init (&cherokee_tmp_dir);
- cherokee_tmp_dir_copy (&cherokee_tmp_dir);
+ ret = init_tmp_dir();
+ if (ret != ret_ok) {
+ return ret;
+ }
cherokee_admin_child = false;
cherokee_readable_errors = NULLB_NULL;
View
@@ -404,9 +404,9 @@ config_server (cherokee_server_t *srv)
RULE_PRE "20!expiration!caching = no-cache\n"
RULE_PRE "20!expiration!caching!no-store = 1\n");
- cherokee_buffer_add_str (&buf, RULE_PRE "20!document_root = ");
- cherokee_tmp_dir_copy (&buf);
- cherokee_buffer_add_va (&buf, "/cherokee/rrd-cache\n");
+ cherokee_buffer_add_str (&buf, RULE_PRE "20!document_root = ");
+ cherokee_buffer_add_buffer (&buf, &cherokee_tmp_dir);
+ cherokee_buffer_add_va (&buf, "/rrd-cache\n");
/* MIME types
*/
View
@@ -32,6 +32,7 @@
#include <sys/wait.h>
#include "rrd_tools.h"
+#include "init.h"
#include "virtual_server.h"
#include "util.h"
@@ -136,8 +137,8 @@ cherokee_rrd_connection_configure (cherokee_rrd_connection_t *rrd_conn,
/* Build the image cache directory
*/
if (cherokee_buffer_is_empty (&rrd_conn->path_img_cache)) {
- cherokee_tmp_dir_copy (&rrd_conn->path_img_cache);
- cherokee_buffer_add_va (&rrd_conn->path_img_cache, "/cherokee/rrd-cache");
+ cherokee_buffer_add_buffer (&rrd_conn->path_img_cache, &cherokee_tmp_dir);
+ cherokee_buffer_add_str (&rrd_conn->path_img_cache, "/rrd-cache");
}
return ret_ok;

0 comments on commit b226fc8

Please sign in to comment.