Skip to content

Commit

Permalink
git-svn-id: svn://cherokee-project.com/cherokee/trunk@1768 5dc97367-9…
Browse files Browse the repository at this point in the history
…7f1-0310-9951-d761b3857238
  • Loading branch information
alobbs committed Aug 7, 2008
1 parent 9ceefc8 commit 6af50a4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2008-08-07 Alvaro Lopez Ortega <alvaro@alobbs.com>

* cherokee/util.h, cherokee/util.c (cherokee_mkdir_p): Adds a new
function. We will need it eventually.

* cherokee/handler_error_nn.c, cherokee/handler_error_nn.h,
qa/049-NN-broken.py, qa/048-NN.py: Fixes the NN support and adapts
the QA test to the new behavior (it is error handler now).
Expand Down
18 changes: 11 additions & 7 deletions cherokee/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ cherokee_encoder_free (cherokee_encoder_t *enc)
ret_t
cherokee_encoder_add_headers (cherokee_encoder_t *enc, cherokee_buffer_t *buf)
{
if (enc->add_headers == NULL)
if (unlikely (enc->add_headers == NULL))
return ret_error;

return enc->add_headers (enc, buf);
Expand All @@ -66,11 +66,15 @@ ret_t
cherokee_encoder_init (cherokee_encoder_t *enc, void *conn)
{
encoder_func_init_t init_func;


/* Properties
*/
enc->conn = conn;
init_func = (encoder_func_init_t) MODULE(enc)->init;

if (init_func == NULL)

/* Call the virtual method
*/
init_func = (encoder_func_init_t) MODULE(enc)->init;
if (init_func == NULL)
return ret_error;

return init_func (enc);
Expand All @@ -82,7 +86,7 @@ cherokee_encoder_encode (cherokee_encoder_t *enc,
cherokee_buffer_t *in,
cherokee_buffer_t *out)
{
if (enc->encode == NULL)
if (unlikely (enc->encode == NULL))
return ret_error;

return enc->encode (enc, in, out);
Expand All @@ -94,7 +98,7 @@ cherokee_encoder_flush (cherokee_encoder_t *enc,
cherokee_buffer_t *in,
cherokee_buffer_t *out)
{
if (enc->flush == NULL)
if (unlikely (enc->flush == NULL))
return ret_error;

return enc->flush (enc, in, out);
Expand Down
38 changes: 38 additions & 0 deletions cherokee/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,3 +1354,41 @@ cherokee_fix_dirpath (cherokee_buffer_t *buf)

return ret_ok;
}


ret_t
cherokee_mkdir_p (cherokee_buffer_t *path)
{
int re;
char *p;

if (cherokee_buffer_is_empty (path))
return ret_ok;

p = path->buf;
while (true) {
p = strchr (p+1, '/');
if (p == NULL)
break;

*p = '\0';
re = mkdir (path->buf, 0700);
if ((re != 0) && (errno != EEXIST)) {
PRINT_ERRNO (errno, "Could not mkdir '%s': ${errno}\n", path->buf);
return ret_error;
}
*p = '/';

p++;
if (p > path->buf + path->len)
return ret_ok;
}

re = mkdir (path->buf, 0700);
if ((re != 0) && (errno != EEXIST)) {
PRINT_ERRNO (errno, "Could not mkdir '%s': ${errno}\n", path->buf);
return ret_error;
}

return ret_ok;
}
1 change: 1 addition & 0 deletions cherokee/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ ret_t cherokee_syslog (int priority, cherokee_buffer_t *buf);
ret_t cherokee_getpwnam (const char *name, struct passwd *pwbuf, char *buf, size_t buflen);
ret_t cherokee_getgrnam (const char *name, struct group *pwbuf, char *buf, size_t buflen);
ret_t cherokee_mkstemp (cherokee_buffer_t *buffer, int *fd);
ret_t cherokee_mkdir_p (cherokee_buffer_t *path);

/* Misc
*/
Expand Down

0 comments on commit 6af50a4

Please sign in to comment.