Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

handler_*.c, space / code style cleanups

git-svn-id: svn://cherokee-project.com/cherokee/trunk@869 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
commit 81679d08a71dba80434c93d5448fdae0cc33c9ff 1 parent 006479c
ADF authored
5 ChangeLog
View
@@ -1,3 +1,8 @@
+2007-07-31 A.D.F <adefacc@tin.it>
+
+ * cherokee/handler_*.c
+ - space / indentation / code style cleanups.
+
2007-07-30 A.D.F <adefacc@tin.it>
* cherokee/admin_server.c,
26 cherokee/handler_cgi.c
View
@@ -170,19 +170,21 @@ do_reap (void)
/* Reap defunct children until there aren't any more.
*/
- for (child_count = 0; ; ++child_count)
- {
- pid = waitpid (-1, &status, WNOHANG);
+ for (child_count = 0; ; ++child_count) {
- /* none left */
- if (pid == 0) break;
+ pid = waitpid (-1, &status, WNOHANG);
- else if (pid < 0) {
+ /* none left */
+ if (pid == 0)
+ break;
+ else
+ if (pid < 0) {
/* because of ptrace */
- if (errno == EINTR) continue;
+ if (errno == EINTR)
+ continue;
break;
}
- }
+ }
#endif
return child_count;
@@ -275,7 +277,7 @@ cherokee_handler_cgi_configure (cherokee_config_node_t *conf, cherokee_server_t
CHEROKEE_NEW_STRUCT (n, handler_cgi_props);
cherokee_handler_cgi_base_props_init_base (PROP_CGI_BASE(n),
- MODULE_PROPS_FREE(cherokee_handler_cgi_props_free));
+ MODULE_PROPS_FREE(cherokee_handler_cgi_props_free));
*_props = MODULE_PROPS(n);
}
@@ -303,7 +305,8 @@ cherokee_handler_cgi_add_env_pair (cherokee_handler_cgi_base_t *cgi_base,
/* Build the new envp entry
*/
entry = (char *) malloc (name_len + content_len + 2);
- if (entry == NULL) return;
+ if (entry == NULL)
+ return;
memcpy (entry, name, name_len);
entry[name_len] = '=';
@@ -333,7 +336,8 @@ add_environment (cherokee_handler_cgi_t *cgi, cherokee_connection_t *conn)
cherokee_handler_cgi_base_t *cgi_base = HDL_CGI_BASE(cgi);
ret = cherokee_handler_cgi_base_build_envp (HDL_CGI_BASE(cgi), conn);
- if (unlikely (ret != ret_ok)) return ret;
+ if (unlikely (ret != ret_ok))
+ return ret;
/* CONTENT_LENGTH
*/
39 cherokee/handler_cgi_base.c
View
@@ -61,7 +61,8 @@ cherokee_handler_cgi_base_init (cherokee_handler_cgi_base_t *cgi,
* We'll need it later
*/
ret = cherokee_connection_parse_args (conn);
- if (unlikely(ret < ret_ok)) return ret;
+ if (unlikely(ret < ret_ok))
+ return ret;
/* Init to default values
*/
@@ -150,8 +151,9 @@ cherokee_handler_cgi_base_configure (cherokee_config_node_t *conf, cherokee_serv
cherokee_list_t *i, *j;
cherokee_handler_cgi_base_props_t *props;
- /* Sanity check: This class is pure virtual, it shouldn't allocate memory here.
- * Check that the object space has been already instanced by it father.
+ /* Sanity check: This class is pure virtual,
+ * it shouldn't allocate memory here.
+ * Check that the object space has been already instanced by its father.
*/
if (*_props == NULL) {
SHOULDNT_HAPPEN;
@@ -177,7 +179,8 @@ cherokee_handler_cgi_base_configure (cherokee_config_node_t *conf, cherokee_serv
if (equal_buf_str (&subconf->key, "script_alias")) {
ret = cherokee_buffer_add_buffer (&props->script_alias, &subconf->val);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
} else if (equal_buf_str (&subconf->key, "env")) {
cherokee_config_node_foreach (j, subconf) {
@@ -185,7 +188,8 @@ cherokee_handler_cgi_base_configure (cherokee_config_node_t *conf, cherokee_serv
cherokee_config_node_t *subconf2 = CONFIG_NODE(j);
env = env_item_new (&subconf2->key, &subconf2->val);
- if (env == NULL) return ret_error;
+ if (env == NULL)
+ return ret_error;
cherokee_list_add_tail (LIST(env), &props->system_env);
}
@@ -236,7 +240,8 @@ add_win32_systemroot_env (cherokee_handler_cgi_base_t *cgi,
char *root;
root = getenv("SYSTEMROOT");
- if (!root) return;
+ if (!root)
+ return;
set_env (cgi, "SYSTEMROOT", root, strlen(root));
}
@@ -244,10 +249,11 @@ add_win32_systemroot_env (cherokee_handler_cgi_base_t *cgi,
ret_t
-cherokee_handler_cgi_base_build_basic_env (cherokee_handler_cgi_base_t *cgi,
- cherokee_handler_cgi_base_add_env_pair_t set_env_pair,
- cherokee_connection_t *conn,
- cherokee_buffer_t *tmp)
+cherokee_handler_cgi_base_build_basic_env (
+ cherokee_handler_cgi_base_t *cgi,
+ cherokee_handler_cgi_base_add_env_pair_t set_env_pair,
+ cherokee_connection_t *conn,
+ cherokee_buffer_t *tmp)
{
int re;
ret_t ret;
@@ -527,9 +533,7 @@ cherokee_handler_cgi_base_build_envp (cherokee_handler_cgi_base_t *cgi, cherokee
cherokee_buffer_clean (&tmp);
- if (cgi_props->check_file &&
- (conn->web_directory.len > 1))
- {
+ if (cgi_props->check_file && (conn->web_directory.len > 1)) {
cherokee_buffer_add_buffer (&tmp, &conn->web_directory);
}
@@ -688,8 +692,7 @@ parse_header (cherokee_handler_cgi_base_t *cgi, cherokee_buffer_t *buffer)
* In this case, we have to remove the last two characters
*/
if ((buffer->len > 4) &&
- (strncmp (CRLF_CRLF, buffer->buf + buffer->len - 4, 4) == 0))
- {
+ (strncmp (CRLF_CRLF, buffer->buf + buffer->len - 4, 4) == 0)) {
cherokee_buffer_drop_endding (buffer, 2);
}
@@ -704,7 +707,8 @@ parse_header (cherokee_handler_cgi_base_t *cgi, cherokee_buffer_t *buffer)
if (end == NULL) break;
end2 = end;
- while (((*end2 == CHR_CR) || (*end2 == CHR_LF)) && (*end2 != '\0')) end2++;
+ while (((*end2 == CHR_CR) || (*end2 == CHR_LF)) && (*end2 != '\0'))
+ end2++;
if (strncasecmp ("Status: ", begin, 8) == 0) {
int code;
@@ -853,7 +857,8 @@ cherokee_handler_cgi_base_split_pathinfo (cherokee_handler_cgi_base_t *cgi, cher
/* Look for the pathinfo
*/
ret = cherokee_split_pathinfo (buf, init_pos, allow_dirs, &pathinfo, &pathinfo_len);
- if (ret == ret_not_found) return ret;
+ if (ret == ret_not_found)
+ return ret;
/* Split the string
*/
2  cherokee/handler_common.c
View
@@ -75,7 +75,7 @@ cherokee_handler_common_configure (cherokee_config_node_t *conf, cherokee_server
CHEROKEE_NEW_STRUCT (n, handler_common_props);
cherokee_handler_props_init_base (HANDLER_PROPS(n),
- MODULE_PROPS_FREE(cherokee_handler_common_props_free));
+ MODULE_PROPS_FREE(cherokee_handler_common_props_free));
n->props_file = NULL;
n->props_dirlist = NULL;
21 cherokee/handler_dirlist.c
View
@@ -94,10 +94,12 @@ parse_if (cherokee_buffer_t *buf, char *if_entry, cherokee_boolean_t show)
cherokee_buffer_add_str (&token, "%");
begin = strstr (buf->buf, token.buf);
- if (begin == NULL) goto error;
+ if (begin == NULL)
+ goto error;
end = strstr (begin, "%fi%");
- if (end == NULL) goto error;
+ if (end == NULL)
+ goto error;
if (show) {
cherokee_buffer_remove_chunk (buf, end - buf->buf, 4);
@@ -178,7 +180,7 @@ cherokee_handler_dirlist_configure (cherokee_config_node_t *conf, cherokee_serve
CHEROKEE_NEW_STRUCT (n, handler_dirlist_props);
cherokee_handler_props_init_base (HANDLER_PROPS(n),
- MODULE_PROPS_FREE(cherokee_handler_dirlist_props_free));
+ MODULE_PROPS_FREE(cherokee_handler_dirlist_props_free));
n->show_size = true;
n->show_date = true;
@@ -244,8 +246,7 @@ is_header_file (cherokee_handler_dirlist_t *dhdl, char *filename)
{
cherokee_list_t *i;
- list_for_each (i, &HDL_DIRLIST_PROP(dhdl)->notice_files)
- {
+ list_for_each (i, &HDL_DIRLIST_PROP(dhdl)->notice_files) {
if (strcmp (filename, LIST_ITEM_INFO(i)) == 0)
return true;
}
@@ -293,8 +294,7 @@ generate_file_entry (cherokee_handler_dirlist_t *dhdl, DIR *dir, cherokee_buffer
if ((name[0] == '.') ||
(name[0] == '#') ||
(name[n->name_len-1] == '~') ||
- is_header_file (dhdl, name))
- {
+ is_header_file (dhdl, name)) {
continue;
}
@@ -427,8 +427,8 @@ check_request_finish_with_slash (cherokee_handler_dirlist_t *dhdl)
cherokee_connection_t *conn = HANDLER_CONN(dhdl);
if ((cherokee_buffer_is_empty (&conn->request)) ||
- (!cherokee_buffer_is_endding (&conn->request, '/')))
- {
+ (!cherokee_buffer_is_endding (&conn->request, '/'))) {
+
cherokee_buffer_clean (&conn->redirect);
cherokee_buffer_ensure_size (&conn->redirect, conn->request.len + conn->userdir.len + 4);
@@ -478,7 +478,8 @@ cmp_date_down (cherokee_list_t *a, cherokee_list_t *b)
file_entry_t *f2 = (file_entry_t *)b;
diff = f1->stat.st_mtime - f2->stat.st_mtime;
- if (diff == 0) cmp_name_down (a,b);
+ if (diff == 0)
+ cmp_name_down (a,b);
return diff;
}
1  cherokee/handler_error.c
View
@@ -285,4 +285,3 @@ cherokee_handler_error_step (cherokee_handler_error_t *hdl, cherokee_buffer_t *b
return ret_eof_have_data;
}
-
7 cherokee/handler_error_redir.c
View
@@ -79,14 +79,14 @@ cherokee_handler_error_redir_configure (cherokee_config_node_t *conf, cherokee_s
error = atoi (subconf->key.buf);
if (!http_type_300 (error) &&
!http_type_400 (error) &&
- !http_type_500 (error))
- {
+ !http_type_500 (error)) {
PRINT_ERROR ("ERROR: error_redir: Wrong error code: '%s'\n", subconf->key.buf);
continue;
}
entry = (error_entry_t *) malloc (sizeof(error_entry_t));
- if (entry == NULL) return ret_nomem;
+ if (entry == NULL)
+ return ret_nomem;
INIT_LIST_HEAD (&entry->entry);
entry->error = error;
@@ -140,3 +140,4 @@ PLUGIN_INIT_NAME(error_redir) (cherokee_plugin_loader_t *loader)
}
PLUGIN_INFO_HANDLER_EASY_INIT (error_redir, http_all_methods);
+
263 cherokee/handler_fastcgi.c
View
@@ -91,13 +91,14 @@ cherokee_handler_fastcgi_configure (cherokee_config_node_t *conf, cherokee_serve
if (equal_buf_str (&subconf->key, "balancer")) {
ret = cherokee_balancer_instance (&subconf->val, subconf, srv, &props->balancer);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
} else if (equal_buf_str (&subconf->key, "fcgi_env")) {
cherokee_config_node_foreach (j, conf) {
cherokee_config_node_t *subconf2 = CONFIG_NODE(j);
- // TODO : implemet this
+ // TODO : implement this
subconf2 = subconf2;
}
@@ -118,27 +119,27 @@ cherokee_handler_fastcgi_configure (cherokee_config_node_t *conf, cherokee_serve
static void
fcgi_build_header (FCGI_Header *hdr, cuchar_t type, cushort_t request_id, cuint_t content_length, cuchar_t padding)
{
- hdr->version = FCGI_VERSION_1;
- hdr->type = type;
- hdr->requestIdB0 = (cuchar_t) request_id;
- hdr->requestIdB1 = (cuchar_t) (request_id >> 8) & 0xff;
- hdr->contentLengthB0 = (cuchar_t) (content_length % 256);
- hdr->contentLengthB1 = (cuchar_t) (content_length / 256);
- hdr->paddingLength = padding;
- hdr->reserved = 0;
+ hdr->version = FCGI_VERSION_1;
+ hdr->type = type;
+ hdr->requestIdB0 = (cuchar_t) request_id;
+ hdr->requestIdB1 = (cuchar_t) (request_id >> 8) & 0xff;
+ hdr->contentLengthB0 = (cuchar_t) (content_length % 256);
+ hdr->contentLengthB1 = (cuchar_t) (content_length / 256);
+ hdr->paddingLength = padding;
+ hdr->reserved = 0;
}
static void
fcgi_build_request_body (FCGI_BeginRequestRecord *request)
{
- request->body.roleB0 = FCGI_RESPONDER;
- request->body.roleB1 = 0;
- request->body.flags = FCGI_KEEP_CONN;
- request->body.reserved[0] = 0;
- request->body.reserved[1] = 0;
- request->body.reserved[2] = 0;
- request->body.reserved[3] = 0;
- request->body.reserved[4] = 0;
+ request->body.roleB0 = FCGI_RESPONDER;
+ request->body.roleB1 = 0;
+ request->body.flags = FCGI_KEEP_CONN;
+ request->body.reserved[0] = 0;
+ request->body.reserved[1] = 0;
+ request->body.reserved[2] = 0;
+ request->body.reserved[3] = 0;
+ request->body.reserved[4] = 0;
}
static void
@@ -146,40 +147,40 @@ set_env_pair (cherokee_handler_cgi_base_t *cgi_base,
char *key, int key_len,
char *val, int val_len)
{
- int len;
- FCGI_BeginRequestRecord request;
+ int len;
+ FCGI_BeginRequestRecord request;
cherokee_handler_fastcgi_t *hdl = HDL_FASTCGI(cgi_base);
cherokee_buffer_t *buf = &hdl->write_buffer;
- len = key_len + val_len;
- len += key_len > 127 ? 4 : 1;
- len += val_len > 127 ? 4 : 1;
-
- fcgi_build_header (&request.header, FCGI_PARAMS, hdl->id, len, 0);
-
- cherokee_buffer_ensure_size (buf, buf->len + sizeof(FCGI_Header) + key_len + val_len);
- cherokee_buffer_add (buf, (void *)&request.header, sizeof(FCGI_Header));
-
- if (key_len <= 127) {
- buf->buf[buf->len++] = key_len;
- } else {
- buf->buf[buf->len++] = ((key_len >> 24) & 0xff) | 0x80;
- buf->buf[buf->len++] = (key_len >> 16) & 0xff;
- buf->buf[buf->len++] = (key_len >> 8) & 0xff;
- buf->buf[buf->len++] = (key_len >> 0) & 0xff;
- }
-
- if (val_len <= 127) {
- buf->buf[buf->len++] = val_len;
- } else {
- buf->buf[buf->len++] = ((val_len >> 24) & 0xff) | 0x80;
- buf->buf[buf->len++] = (val_len >> 16) & 0xff;
- buf->buf[buf->len++] = (val_len >> 8) & 0xff;
- buf->buf[buf->len++] = (val_len >> 0) & 0xff;
- }
-
- cherokee_buffer_add (buf, key, key_len);
- cherokee_buffer_add (buf, val, val_len);
+ len = key_len + val_len;
+ len += key_len > 127 ? 4 : 1;
+ len += val_len > 127 ? 4 : 1;
+
+ fcgi_build_header (&request.header, FCGI_PARAMS, hdl->id, len, 0);
+
+ cherokee_buffer_ensure_size (buf, buf->len + sizeof(FCGI_Header) + key_len + val_len);
+ cherokee_buffer_add (buf, (void *)&request.header, sizeof(FCGI_Header));
+
+ if (key_len <= 127) {
+ buf->buf[buf->len++] = key_len;
+ } else {
+ buf->buf[buf->len++] = ((key_len >> 24) & 0xff) | 0x80;
+ buf->buf[buf->len++] = (key_len >> 16) & 0xff;
+ buf->buf[buf->len++] = (key_len >> 8) & 0xff;
+ buf->buf[buf->len++] = (key_len >> 0) & 0xff;
+ }
+
+ if (val_len <= 127) {
+ buf->buf[buf->len++] = val_len;
+ } else {
+ buf->buf[buf->len++] = ((val_len >> 24) & 0xff) | 0x80;
+ buf->buf[buf->len++] = (val_len >> 16) & 0xff;
+ buf->buf[buf->len++] = (val_len >> 8) & 0xff;
+ buf->buf[buf->len++] = (val_len >> 0) & 0xff;
+ }
+
+ cherokee_buffer_add (buf, key, key_len);
+ cherokee_buffer_add (buf, val, val_len);
}
@@ -272,13 +273,13 @@ cherokee_handler_fastcgi_new (cherokee_handler_t **hdl, void *cnt, cherokee_modu
cherokee_buffer_init (&n->write_buffer);
- /* The first FastCGI handler of each thread must create the
- * FastCGI manager container table, and set the freeing func.
- */
- if (CONN_THREAD(cnt)->fastcgi_servers == NULL) {
- CONN_THREAD(cnt)->fastcgi_free_func = (cherokee_func_free_t) cherokee_fcgi_dispatcher_free;
- cherokee_avl_new (&CONN_THREAD(cnt)->fastcgi_servers);
- }
+ /* The first FastCGI handler of each thread must create the
+ * FastCGI manager container table, and set the freeing func.
+ */
+ if (CONN_THREAD(cnt)->fastcgi_servers == NULL) {
+ CONN_THREAD(cnt)->fastcgi_free_func = (cherokee_func_free_t) cherokee_fcgi_dispatcher_free;
+ cherokee_avl_new (&CONN_THREAD(cnt)->fastcgi_servers);
+ }
/* Return the object
*/
@@ -307,23 +308,26 @@ get_dispatcher (cherokee_handler_fastcgi_t *hdl, cherokee_fcgi_dispatcher_t **di
ret_t ret;
cherokee_source_t *src = NULL;
cherokee_thread_t *thread = HANDLER_THREAD(hdl);
- cherokee_avl_t *dispatchers = thread->fastcgi_servers;
+ cherokee_avl_t *dispatchers = thread->fastcgi_servers;
cherokee_handler_fastcgi_props_t *props = HANDLER_FASTCGI_PROPS(hdl);
/* Choose the server
*/
ret = cherokee_balancer_dispatch (props->balancer, HANDLER_CONN(hdl), &src);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
/* Get the manager
*/
ret = cherokee_avl_get (dispatchers, &src->original, (void **)dispatcher);
if (ret == ret_not_found) {
ret = cherokee_fcgi_dispatcher_new (dispatcher, thread, src, props->nsockets, props->nkeepalive, props->npipeline);
- if (unlikely (ret != ret_ok)) return ret;
+ if (unlikely (ret != ret_ok))
+ return ret;
ret = cherokee_avl_add (dispatchers, &src->original, *dispatcher);
- if (unlikely (ret != ret_ok)) return ret;
+ if (unlikely (ret != ret_ok))
+ return ret;
}
return ret_ok;
@@ -347,10 +351,12 @@ register_connection (cherokee_handler_fastcgi_t *hdl)
break;
case ret_not_found:
ret = cherokee_thread_retire_active_connection (thd, conn);
- if (unlikely (ret != ret_ok)) return ret;
+ if (unlikely (ret != ret_ok))
+ return ret;
ret = cherokee_fcgi_dispatcher_queue_conn (hdl->dispatcher, conn);
- if (unlikely (ret != ret_ok)) return ret;
+ if (unlikely (ret != ret_ok))
+ return ret;
return ret_eagain;
default:
@@ -358,10 +364,12 @@ register_connection (cherokee_handler_fastcgi_t *hdl)
}
ret = cherokee_fcgi_manager_ensure_is_connected (hdl->manager, thd);
- if (unlikely (ret != ret_ok)) return ret;
+ if (unlikely (ret != ret_ok))
+ return ret;
ret = cherokee_fcgi_manager_register (hdl->manager, conn, &hdl->id, &hdl->generation);
- if (unlikely (ret != ret_ok)) return ret;
+ if (unlikely (ret != ret_ok))
+ return ret;
TRACE (ENTRIES, "disp=%p mgr=%p, ok\n", hdl->dispatcher, hdl->manager);
@@ -374,7 +382,7 @@ add_extra_fastcgi_env (cherokee_handler_fastcgi_t *hdl, cuint_t *last_header_off
{
ret_t ret;
cherokee_handler_cgi_base_t *cgi_base = HDL_CGI_BASE(hdl);
- cherokee_buffer_t buffer = CHEROKEE_BUF_INIT;
+ cherokee_buffer_t buffer = CHEROKEE_BUF_INIT;
cherokee_connection_t *conn = HANDLER_CONN(hdl);
/* CONTENT_LENGTH
@@ -389,12 +397,12 @@ add_extra_fastcgi_env (cherokee_handler_fastcgi_t *hdl, cuint_t *last_header_off
cherokee_buffer_add_buffer (&buffer, &conn->local_directory);
if (conn->request.len > 0) {
cherokee_buffer_add (&buffer, conn->request.buf + 1, conn->request.len - 1);
- }
-
-/* if (! cherokee_buffer_is_empty (&conn->pathinfo)) { */
-/* set_env (cgi_base, "PATH_INFO", conn->pathinfo.buf, conn->pathinfo.len); */
-/* } */
+ }
+/* if (! cherokee_buffer_is_empty (&conn->pathinfo)) {
+ * set_env (cgi_base, "PATH_INFO", conn->pathinfo.buf, conn->pathinfo.len);
+ * }
+ */
/* A few more..
*/
set_env (cgi_base, "PATH_TRANSLATED", buffer.buf, buffer.len);
@@ -412,36 +420,36 @@ add_extra_fastcgi_env (cherokee_handler_fastcgi_t *hdl, cuint_t *last_header_off
static void
fixup_padding (cherokee_buffer_t *buf, cuint_t id, cuint_t last_header_offset)
{
- cuint_t rest;
- cuint_t pad;
- static char padding[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- FCGI_Header *last_header;
+ cuint_t rest;
+ cuint_t pad;
+ static char padding[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ FCGI_Header *last_header;
- if (buf->len <= 0)
- return;
- last_header = (FCGI_Header *) (buf->buf + last_header_offset);
- rest = buf->len % 8;
- pad = 8 - rest;
+ if (buf->len <= 0)
+ return;
+ last_header = (FCGI_Header *) (buf->buf + last_header_offset);
+ rest = buf->len % 8;
+ pad = 8 - rest;
- if (rest == 0)
- return;
+ if (rest == 0)
+ return;
- last_header->paddingLength = pad;
+ last_header->paddingLength = pad;
- cherokee_buffer_ensure_size (buf, buf->len + pad);
- cherokee_buffer_add (buf, padding, pad);
+ cherokee_buffer_ensure_size (buf, buf->len + pad);
+ cherokee_buffer_add (buf, padding, pad);
}
static void
add_empty_packet (cherokee_handler_fastcgi_t *hdl, cuint_t type)
{
- FCGI_BeginRequestRecord request;
+ FCGI_BeginRequestRecord request;
- fcgi_build_header (&request.header, type, hdl->id, 0, 0);
- cherokee_buffer_add (&hdl->write_buffer, (void *)&request.header, sizeof(FCGI_Header));
+ fcgi_build_header (&request.header, type, hdl->id, 0, 0);
+ cherokee_buffer_add (&hdl->write_buffer, (void *)&request.header, sizeof(FCGI_Header));
- TRACE (ENTRIES, "id=%d gen=%d, empty packet type=%d, len=%d\n", hdl->id, hdl->generation, type, hdl->write_buffer.len);
+ TRACE (ENTRIES, "id=%d gen=%d, empty packet type=%d, len=%d\n", hdl->id, hdl->generation, type, hdl->write_buffer.len);
}
@@ -450,37 +458,37 @@ build_header (cherokee_handler_fastcgi_t *hdl)
{
FCGI_BeginRequestRecord request;
cherokee_connection_t *conn = HANDLER_CONN(hdl);
- cuint_t last_header_offset;
+ cuint_t last_header_offset;
- /* Take care here, if the connection is reinjected, it
+ /* Take care here, if the connection is reinjected, it
* shouldn't parse the arguments again.
- */
- if (conn->arguments == NULL)
- cherokee_connection_parse_args (conn);
+ */
+ if (conn->arguments == NULL)
+ cherokee_connection_parse_args (conn);
cherokee_buffer_clean (&hdl->write_buffer);
cherokee_buffer_ensure_size (&hdl->write_buffer, 512);
/* FCGI_BEGIN_REQUEST
*/
- fcgi_build_header (&request.header, FCGI_BEGIN_REQUEST, hdl->id, sizeof(request.body), 0);
- fcgi_build_request_body (&request);
-
+ fcgi_build_header (&request.header, FCGI_BEGIN_REQUEST, hdl->id, sizeof(request.body), 0);
+ fcgi_build_request_body (&request);
+
cherokee_buffer_add (&hdl->write_buffer, (void *)&request, sizeof(FCGI_BeginRequestRecord));
- TRACE (ENTRIES, "id=%d gen=%d, Added FCGI_BEGIN_REQUEST, len=%d\n", hdl->id, hdl->generation, hdl->write_buffer.len);
+ TRACE (ENTRIES, "id=%d gen=%d, Added FCGI_BEGIN_REQUEST, len=%d\n", hdl->id, hdl->generation, hdl->write_buffer.len);
/* Add enviroment variables
*/
cherokee_handler_cgi_base_build_envp (HDL_CGI_BASE(hdl), conn);
add_extra_fastcgi_env (hdl, &last_header_offset);
- fixup_padding (&hdl->write_buffer, hdl->id, last_header_offset);
+ fixup_padding (&hdl->write_buffer, hdl->id, last_header_offset);
- /* There are not more parameters
- */
+ /* There are no more parameters
+ */
add_empty_packet (hdl, FCGI_PARAMS);
- TRACE (ENTRIES, "id=%d gen=%d, Added FCGI_PARAMS, len=%d\n", hdl->id, hdl->generation, hdl->write_buffer.len);
+ TRACE (ENTRIES, "id=%d gen=%d, Added FCGI_PARAMS, len=%d\n", hdl->id, hdl->generation, hdl->write_buffer.len);
return ret_ok;
}
@@ -491,7 +499,7 @@ send_post (cherokee_handler_fastcgi_t *hdl, cherokee_buffer_t *buf)
ret_t ret;
cherokee_connection_t *conn = HANDLER_CONN(hdl);
static FCGI_Header empty_header = {0,0,0,0,0,0,0,0};
-
+
switch (hdl->post_phase) {
case fcgi_post_init:
TRACE (ENTRIES, "id=%d gen=%d, Post phase = init\n", hdl->id, hdl->generation);
@@ -516,18 +524,18 @@ send_post (cherokee_handler_fastcgi_t *hdl, cherokee_buffer_t *buf)
ret = cherokee_post_walk_read (&conn->post, buf, POST_PACKAGE_LEN);
switch (ret) {
case ret_ok:
- case ret_eagain:
- break;
+ case ret_eagain:
+ break;
case ret_error:
- return ret;
+ return ret;
default:
- RET_UNKNOWN(ret);
- return ret_error;
+ RET_UNKNOWN(ret);
+ return ret_error;
}
if (buf->len > sizeof(FCGI_Header)) {
fcgi_build_header ((FCGI_Header *)buf->buf, FCGI_STDIN,
- hdl->id, buf->len - sizeof(FCGI_Header), 0);
+ hdl->id, buf->len - sizeof(FCGI_Header), 0);
}
ret = cherokee_post_walk_finished (&conn->post);
@@ -543,18 +551,18 @@ send_post (cherokee_handler_fastcgi_t *hdl, cherokee_buffer_t *buf)
if (! cherokee_buffer_is_empty (buf)) {
ret = cherokee_fcgi_manager_send_remove (hdl->manager, buf);
switch (ret) {
- case ret_ok:
- break;
- case ret_eagain:
- return ret_eagain;
- case ret_eof:
- case ret_error:
- conn->error_code = http_bad_gateway;
- return ret_error;
- default:
- RET_UNKNOWN(ret);
- return ret_error;
- }
+ case ret_ok:
+ break;
+ case ret_eagain:
+ return ret_eagain;
+ case ret_eof:
+ case ret_error:
+ conn->error_code = http_bad_gateway;
+ return ret_error;
+ default:
+ RET_UNKNOWN(ret);
+ return ret_error;
+ }
}
if (! cherokee_buffer_is_empty (buf))
@@ -591,10 +599,12 @@ init_respin (cherokee_handler_fastcgi_t *hdl)
ret_t ret;
ret = cherokee_fcgi_manager_ensure_is_connected (hdl->manager, HANDLER_THREAD(hdl));
- if (unlikely (ret != ret_ok)) return ret;
+ if (unlikely (ret != ret_ok))
+ return ret;
ret = register_connection (hdl);
- if (unlikely (ret != ret_ok)) return ret;
+ if (unlikely (ret != ret_ok))
+ return ret;
HDL_CGI_BASE(hdl)->got_eof = false;
hdl->init_phase = fcgi_init_build_header;
@@ -636,7 +646,8 @@ cherokee_handler_fastcgi_init (cherokee_handler_fastcgi_t *hdl)
/* Set the executable filename
*/
ret = cherokee_handler_cgi_base_extract_path (HDL_CGI_BASE(cgi), true);
- if (unlikely (ret < ret_ok)) return ret;
+ if (unlikely (ret < ret_ok))
+ return ret;
hdl->init_phase = fcgi_init_build_header;
@@ -646,7 +657,8 @@ cherokee_handler_fastcgi_init (cherokee_handler_fastcgi_t *hdl)
/* Build the initial header
*/
ret = build_header (hdl);
- if (unlikely (ret != ret_ok)) return ret;
+ if (unlikely (ret != ret_ok))
+ return ret;
hdl->init_phase = fcgi_init_send_header;
@@ -672,7 +684,8 @@ cherokee_handler_fastcgi_init (cherokee_handler_fastcgi_t *hdl)
TRACE (ENTRIES, "id=%d gen=%d, Init phase = send_post\n", hdl->id, hdl->generation);
ret = send_post (hdl, &hdl->write_buffer);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
hdl->init_phase = fcgi_init_read;
171 cherokee/handler_fcgi.c
View
@@ -82,8 +82,7 @@ process_package (cherokee_handler_fcgi_t *hdl, cherokee_buffer_t *inbuf, cheroke
if (header->type != FCGI_STDERR &&
header->type != FCGI_STDOUT &&
- header->type != FCGI_END_REQUEST)
- {
+ header->type != FCGI_END_REQUEST) {
cherokee_buffer_print_debug (inbuf, -1);
PRINT_ERROR_S ("Parsing error: unknown type\n");
return ret_error;
@@ -317,27 +316,27 @@ cherokee_handler_fcgi_free (cherokee_handler_fcgi_t *hdl)
static void
fcgi_build_header (FCGI_Header *hdr, cuchar_t type, cushort_t request_id, cuint_t content_length, cuchar_t padding)
{
- hdr->version = FCGI_VERSION_1;
- hdr->type = type;
- hdr->requestIdB0 = (cuchar_t) request_id;
- hdr->requestIdB1 = (cuchar_t) (request_id >> 8) & 0xff;
- hdr->contentLengthB0 = (cuchar_t) (content_length % 256);
- hdr->contentLengthB1 = (cuchar_t) (content_length / 256);
- hdr->paddingLength = padding;
- hdr->reserved = 0;
+ hdr->version = FCGI_VERSION_1;
+ hdr->type = type;
+ hdr->requestIdB0 = (cuchar_t) request_id;
+ hdr->requestIdB1 = (cuchar_t) (request_id >> 8) & 0xff;
+ hdr->contentLengthB0 = (cuchar_t) (content_length % 256);
+ hdr->contentLengthB1 = (cuchar_t) (content_length / 256);
+ hdr->paddingLength = padding;
+ hdr->reserved = 0;
}
static void
fcgi_build_request_body (FCGI_BeginRequestRecord *request)
{
- request->body.roleB0 = FCGI_RESPONDER;
- request->body.roleB1 = 0;
- request->body.flags = 0;
- request->body.reserved[0] = 0;
- request->body.reserved[1] = 0;
- request->body.reserved[2] = 0;
- request->body.reserved[3] = 0;
- request->body.reserved[4] = 0;
+ request->body.roleB0 = FCGI_RESPONDER;
+ request->body.roleB1 = 0;
+ request->body.flags = 0;
+ request->body.reserved[0] = 0;
+ request->body.reserved[1] = 0;
+ request->body.reserved[2] = 0;
+ request->body.reserved[3] = 0;
+ request->body.reserved[4] = 0;
}
static void
@@ -345,40 +344,40 @@ set_env_pair (cherokee_handler_cgi_base_t *cgi_base,
char *key, int key_len,
char *val, int val_len)
{
- int len;
- FCGI_BeginRequestRecord request;
+ int len;
+ FCGI_BeginRequestRecord request;
cherokee_handler_fcgi_t *hdl = HDL_FCGI(cgi_base);
cherokee_buffer_t *buf = &hdl->write_buffer;
- len = key_len + val_len;
- len += key_len > 127 ? 4 : 1;
- len += val_len > 127 ? 4 : 1;
-
- fcgi_build_header (&request.header, FCGI_PARAMS, 1, len, 0);
-
- cherokee_buffer_ensure_size (buf, buf->len + sizeof(FCGI_Header) + key_len + val_len);
- cherokee_buffer_add (buf, (void *)&request.header, sizeof(FCGI_Header));
-
- if (key_len <= 127) {
- buf->buf[buf->len++] = key_len;
- } else {
- buf->buf[buf->len++] = ((key_len >> 24) & 0xff) | 0x80;
- buf->buf[buf->len++] = (key_len >> 16) & 0xff;
- buf->buf[buf->len++] = (key_len >> 8) & 0xff;
- buf->buf[buf->len++] = (key_len >> 0) & 0xff;
- }
-
- if (val_len <= 127) {
- buf->buf[buf->len++] = val_len;
- } else {
- buf->buf[buf->len++] = ((val_len >> 24) & 0xff) | 0x80;
- buf->buf[buf->len++] = (val_len >> 16) & 0xff;
- buf->buf[buf->len++] = (val_len >> 8) & 0xff;
- buf->buf[buf->len++] = (val_len >> 0) & 0xff;
- }
-
- cherokee_buffer_add (buf, key, key_len);
- cherokee_buffer_add (buf, val, val_len);
+ len = key_len + val_len;
+ len += key_len > 127 ? 4 : 1;
+ len += val_len > 127 ? 4 : 1;
+
+ fcgi_build_header (&request.header, FCGI_PARAMS, 1, len, 0);
+
+ cherokee_buffer_ensure_size (buf, buf->len + sizeof(FCGI_Header) + key_len + val_len);
+ cherokee_buffer_add (buf, (void *)&request.header, sizeof(FCGI_Header));
+
+ if (key_len <= 127) {
+ buf->buf[buf->len++] = key_len;
+ } else {
+ buf->buf[buf->len++] = ((key_len >> 24) & 0xff) | 0x80;
+ buf->buf[buf->len++] = (key_len >> 16) & 0xff;
+ buf->buf[buf->len++] = (key_len >> 8) & 0xff;
+ buf->buf[buf->len++] = (key_len >> 0) & 0xff;
+ }
+
+ if (val_len <= 127) {
+ buf->buf[buf->len++] = val_len;
+ } else {
+ buf->buf[buf->len++] = ((val_len >> 24) & 0xff) | 0x80;
+ buf->buf[buf->len++] = (val_len >> 16) & 0xff;
+ buf->buf[buf->len++] = (val_len >> 8) & 0xff;
+ buf->buf[buf->len++] = (val_len >> 0) & 0xff;
+ }
+
+ cherokee_buffer_add (buf, key, key_len);
+ cherokee_buffer_add (buf, val, val_len);
}
@@ -387,7 +386,7 @@ add_extra_fcgi_env (cherokee_handler_fcgi_t *hdl, cuint_t *last_header_offset)
{
ret_t ret;
cherokee_handler_cgi_base_t *cgi_base = HDL_CGI_BASE(hdl);
- cherokee_buffer_t buffer = CHEROKEE_BUF_INIT;
+ cherokee_buffer_t buffer = CHEROKEE_BUF_INIT;
cherokee_connection_t *conn = HANDLER_CONN(hdl);
/* CONTENT_LENGTH
@@ -423,35 +422,35 @@ add_extra_fcgi_env (cherokee_handler_fcgi_t *hdl, cuint_t *last_header_offset)
static void
fixup_padding (cherokee_buffer_t *buf, cuint_t last_header_offset)
{
- cuint_t rest;
- cuint_t pad;
- static char padding[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- FCGI_Header *last_header;
+ cuint_t rest;
+ cuint_t pad;
+ static char padding[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+ FCGI_Header *last_header;
- if (buf->len <= 0)
- return;
- last_header = (FCGI_Header *) (buf->buf + last_header_offset);
- rest = buf->len % 8;
- pad = 8 - rest;
+ if (buf->len <= 0)
+ return;
+ last_header = (FCGI_Header *) (buf->buf + last_header_offset);
+ rest = buf->len % 8;
+ pad = 8 - rest;
- if (rest == 0)
- return;
+ if (rest == 0)
+ return;
- last_header->paddingLength = pad;
+ last_header->paddingLength = pad;
- cherokee_buffer_ensure_size (buf, buf->len + pad);
- cherokee_buffer_add (buf, padding, pad);
+ cherokee_buffer_ensure_size (buf, buf->len + pad);
+ cherokee_buffer_add (buf, padding, pad);
}
static void
add_empty_packet (cherokee_handler_fcgi_t *hdl, cuint_t type)
{
- FCGI_BeginRequestRecord request;
+ FCGI_BeginRequestRecord request;
- fcgi_build_header (&request.header, type, 1, 0, 0);
- cherokee_buffer_add (&hdl->write_buffer, (void *)&request.header, sizeof(FCGI_Header));
+ fcgi_build_header (&request.header, type, 1, 0, 0);
+ cherokee_buffer_add (&hdl->write_buffer, (void *)&request.header, sizeof(FCGI_Header));
- TRACE (ENTRIES, "empty packet type=%d, len=%d\n", type, hdl->write_buffer.len);
+ TRACE (ENTRIES, "empty packet type=%d, len=%d\n", type, hdl->write_buffer.len);
}
@@ -459,37 +458,37 @@ static ret_t
build_header (cherokee_handler_fcgi_t *hdl, cherokee_buffer_t *buffer)
{
FCGI_BeginRequestRecord request;
- cuint_t last_header_offset;
+ cuint_t last_header_offset;
cherokee_connection_t *conn = HANDLER_CONN(hdl);
- /* Take care here, if the connection is reinjected, it
+ /* Take care here, if the connection is reinjected, it
* shouldn't parse the arguments again.
*/
- if (conn->arguments == NULL)
- cherokee_connection_parse_args (conn);
-
+ if (conn->arguments == NULL)
+ cherokee_connection_parse_args (conn);
+
cherokee_buffer_clean (buffer);
/* FCGI_BEGIN_REQUEST
*/
- fcgi_build_header (&request.header, FCGI_BEGIN_REQUEST, 1, sizeof(request.body), 0);
- fcgi_build_request_body (&request);
+ fcgi_build_header (&request.header, FCGI_BEGIN_REQUEST, 1, sizeof(request.body), 0);
+ fcgi_build_request_body (&request);
cherokee_buffer_add (buffer, (void *)&request, sizeof(FCGI_BeginRequestRecord));
- TRACE (ENTRIES, "Added FCGI_BEGIN_REQUEST, len=%d\n", buffer->len);
+ TRACE (ENTRIES, "Added FCGI_BEGIN_REQUEST, len=%d\n", buffer->len);
/* Add enviroment variables
*/
cherokee_handler_cgi_base_build_envp (HDL_CGI_BASE(hdl), conn);
add_extra_fcgi_env (hdl, &last_header_offset);
- fixup_padding (buffer, last_header_offset);
+ fixup_padding (buffer, last_header_offset);
- /* There are not more parameters
- */
+ /* There are no more parameters
+ */
add_empty_packet (hdl, FCGI_PARAMS);
- TRACE (ENTRIES, "Added FCGI_PARAMS, len=%d\n", buffer->len);
+ TRACE (ENTRIES, "Added FCGI_PARAMS, len=%d\n", buffer->len);
return ret_ok;
}
@@ -504,7 +503,8 @@ connect_to_server (cherokee_handler_fcgi_t *hdl)
cherokee_handler_fcgi_props_t *props = HANDLER_FCGI_PROPS(hdl);
ret = cherokee_balancer_dispatch (props->balancer, conn, &src);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
ret = cherokee_source_connect (src, &hdl->socket);
if (ret != ret_ok) {
@@ -521,7 +521,8 @@ connect_to_server (cherokee_handler_fcgi_t *hdl)
while (true) {
ret = cherokee_source_connect (src, &hdl->socket);
- if (ret == ret_ok) break;
+ if (ret == ret_ok)
+ break;
TRACE (ENTRIES, "Couldn't connect: %s, try %d\n", src->host.buf ? src->host.buf : src->unix_socket.buf, try);
@@ -741,7 +742,8 @@ cherokee_handler_fcgi_init (cherokee_handler_fcgi_t *hdl)
/* Send the header
*/
ret = do_send (hdl, &hdl->write_buffer);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
HDL_CGI_BASE(hdl)->init_phase = hcgi_phase_send_post;
@@ -752,7 +754,8 @@ cherokee_handler_fcgi_init (cherokee_handler_fcgi_t *hdl)
return send_post (hdl, &hdl->write_buffer);
} else {
ret = send_no_post (hdl, &hdl->write_buffer);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
}
break;
}
18 cherokee/handler_file.c
View
@@ -410,9 +410,7 @@ cherokee_handler_file_init (cherokee_handler_file_t *fhdl)
/* Is it cached on the client?
*/
ret = check_cached (fhdl);
- if ((ret != ret_ok) ||
- (fhdl->not_modified))
- {
+ if ((ret != ret_ok) || (fhdl->not_modified)) {
cherokee_buffer_drop_endding (&conn->local_directory, conn->request.len);
return ret;
}
@@ -474,8 +472,7 @@ cherokee_handler_file_init (cherokee_handler_file_t *fhdl)
/* Range 1: Check the range and file size
*/
if (unlikely ((conn->range_start > fhdl->info->st_size) ||
- (conn->range_end > fhdl->info->st_size)))
- {
+ (conn->range_end > fhdl->info->st_size))) {
conn->range_end = fhdl->info->st_size;
conn->error_code = http_range_not_satisfiable;
return ret_error;
@@ -498,13 +495,13 @@ cherokee_handler_file_init (cherokee_handler_file_t *fhdl)
/* Set mmap or file position
*/
if ((conn->io_entry_ref != NULL) &&
- (conn->io_entry_ref->mmaped != NULL))
- {
+ (conn->io_entry_ref->mmaped != NULL)) {
/* Set the mmap info
*/
conn->mmaped = conn->io_entry_ref->mmaped + conn->range_start;
- conn->mmaped_len = conn->io_entry_ref->mmaped_len - (
- conn->range_start + (conn->io_entry_ref->mmaped_len - conn->range_end));
+ conn->mmaped_len = conn->io_entry_ref->mmaped_len -
+ ( conn->range_start +
+ (conn->io_entry_ref->mmaped_len - conn->range_end));
} else {
/* Seek the file if needed
*/
@@ -667,7 +664,8 @@ cherokee_handler_file_step (cherokee_handler_file_t *fhdl, cherokee_buffer_t *bu
goto exit_sendfile;
}
- if (ret < ret_ok) return ret;
+ if (ret < ret_ok)
+ return ret;
/* This connection is not using the cherokee_connection_send() method,
* so we have to update the connection traffic counter here.
5 cherokee/handler_mirror.c
View
@@ -56,7 +56,7 @@ cherokee_handler_mirror_configure (cherokee_config_node_t *conf, cherokee_server
CHEROKEE_NEW_STRUCT (n, handler_mirror_props);
cherokee_handler_props_init_base (HANDLER_PROPS(n),
- MODULE_PROPS_FREE(cherokee_handler_mirror_props_free));
+ MODULE_PROPS_FREE(cherokee_handler_mirror_props_free));
n->balancer = NULL;
*_props = MODULE_PROPS(n);
@@ -142,7 +142,8 @@ connect_to_server (cherokee_handler_mirror_t *hdl)
cherokee_handler_mirror_props_t *props = HDL_MIRROR_PROPS(hdl);
ret = cherokee_balancer_dispatch (props->balancer, conn, &src);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
ret = cherokee_source_connect (src, &hdl->socket);
switch (ret) {
7 cherokee/handler_nn.c
View
@@ -60,8 +60,7 @@ get_nearest_from_directory (char *directory, char *request, cherokee_buffer_t *o
if (dir == NULL)
goto go_out;
- while ((entry = readdir (dir)) != NULL)
- {
+ while ((entry = readdir (dir)) != NULL) {
int dis;
if (!strncmp (entry->d_name, ".", 1)) continue;
@@ -167,7 +166,8 @@ PLUGIN_INIT_NAME(nn) (cherokee_plugin_loader_t *loader)
{
/* Is init?
*/
- if (_nn_is_init) return;
+ if (_nn_is_init)
+ return;
_nn_is_init = true;
/* Load the dependences
@@ -176,3 +176,4 @@ PLUGIN_INIT_NAME(nn) (cherokee_plugin_loader_t *loader)
}
PLUGIN_INFO_HANDLER_EASY_INIT (nn, http_all_methods);
+
6 cherokee/handler_phpcgi.c
View
@@ -144,7 +144,8 @@ cherokee_handler_phpcgi_new (cherokee_handler_t **hdl, void *cnt, cherokee_modu
/* Create the new handler CGI object
*/
ret = cherokee_handler_cgi_new (hdl, cnt, props);
- if (unlikely(ret != ret_ok)) return ret;
+ if (unlikely(ret != ret_ok))
+ return ret;
cgi = HDL_CGI_BASE(*hdl);
@@ -264,7 +265,8 @@ PLUGIN_INIT_NAME(phpcgi) (cherokee_plugin_loader_t *loader)
{
/* Is init?
*/
- if (_phpcgi_is_init) return;
+ if (_phpcgi_is_init)
+ return;
_phpcgi_is_init = true;
/* Load the dependences
46 cherokee/handler_proxy.c
View
@@ -123,10 +123,12 @@ cherokee_handler_proxy_new (cherokee_handler_t **hdl, cherokee_connection_t *cn
/* Init
*/
ret = cherokee_downloader_init(&n->client);
- if ( ret != ret_ok ) return ret;
+ if ( ret != ret_ok )
+ return ret;
ret = cherokee_buffer_init(&n->url);
- if ( ret != ret_ok ) return ret;
+ if ( ret != ret_ok )
+ return ret;
/* Return the object
*/
@@ -154,7 +156,8 @@ add_extra_headers (cherokee_handler_proxy_t *hdl)
char *end = header->buf + header->len;
i = strstr (header->buf, CRLF);
- if (i == NULL) return ret_error;
+ if (i == NULL)
+ return ret_error;
for (i += 2; i<end;) {
char *nl;
@@ -163,8 +166,7 @@ add_extra_headers (cherokee_handler_proxy_t *hdl)
if (nl == NULL) break;
if ((strncasecmp (i, "Host:", 5) != 0) &&
- (strncasecmp (i, "Connection:", 11) != 0))
- {
+ (strncasecmp (i, "Connection:", 11) != 0)) {
cherokee_request_header_add_header (&hdl->client.request, i, nl - i);
}
@@ -191,33 +193,40 @@ cherokee_handler_proxy_init (cherokee_handler_proxy_t *hdl)
/* Construct the URL host + request + pathinfo + query_string
*/
ret = cherokee_buffer_add_buffer (&hdl->url, &conn->host);
- if ( ret != ret_ok ) return ret;
+ if ( ret != ret_ok )
+ return ret;
ret = cherokee_buffer_add_buffer (&hdl->url, &conn->request);
- if ( ret != ret_ok ) return ret;
+ if ( ret != ret_ok )
+ return ret;
ret = cherokee_buffer_add_buffer (&hdl->url, &conn->pathinfo);
- if ( ret != ret_ok ) return ret;
+ if ( ret != ret_ok )
+ return ret;
if (! cherokee_buffer_is_empty (&conn->query_string)) {
ret = cherokee_buffer_add (&hdl->url, "?", 1);
- if ( ret != ret_ok ) return ret;
+ if ( ret != ret_ok )
+ return ret;
ret = cherokee_buffer_add_buffer (&hdl->url, &conn->query_string);
- if ( ret != ret_ok ) return ret;
+ if ( ret != ret_ok )
+ return ret;
}
/* Fill in the downloader object.
*/
ret = cherokee_downloader_set_url(&hdl->client, &hdl->url);
- if ( ret != ret_ok ) return ret;
+ if ( ret != ret_ok )
+ return ret;
TRACE(ENTRIES, "Request: %s\n", hdl->client.request.url.host.buf);
/* Extra headers
*/
ret = add_extra_headers (hdl);
- if ( ret != ret_ok ) return ret;
+ if ( ret != ret_ok )
+ return ret;
/* Post
*/
@@ -228,10 +237,12 @@ cherokee_handler_proxy_init (cherokee_handler_proxy_t *hdl)
/* Properties
*/
ret = cherokee_downloader_set_keepalive (&hdl->client, false);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
ret = cherokee_downloader_connect (&hdl->client);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
TRACE(ENTRIES, "client->downloader->socket: %d\n", SOCKET_FD(&hdl->client.socket));
@@ -306,8 +317,10 @@ cherokee_handler_proxy_step (cherokee_handler_proxy_t *phdl,
case ret_eof_have_data:
break;
case ret_eagain:
- cherokee_thread_deactive_to_polling (HANDLER_THREAD(phdl), HANDLER_CONN(phdl),
- SOCKET_FD(&phdl->client.socket), 0, false);
+ cherokee_thread_deactive_to_polling (
+ HANDLER_THREAD(phdl),
+ HANDLER_CONN(phdl),
+ SOCKET_FD(&phdl->client.socket), 0, false);
return ret_eagain;
case ret_eof:
break;
@@ -330,4 +343,3 @@ cherokee_handler_proxy_step (cherokee_handler_proxy_t *phdl,
return ret;
}
-
7 cherokee/handler_redir.c
View
@@ -222,11 +222,13 @@ configure_rewrite (cherokee_config_node_t *conf, cherokee_server_t *srv, cheroke
ret = cherokee_config_node_read (conf, "regex", &regex);
if (ret == ret_ok) {
ret = cherokee_regex_table_get (srv->regexs, regex->buf, (void **)&re);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
}
ret = cherokee_config_node_read (conf, "substring", &substring);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok)
+ return ret;
/* New RegEx
*/
@@ -403,4 +405,3 @@ cherokee_handler_redir_configure (cherokee_config_node_t *conf, cherokee_server_
return ret_ok;
}
-
10 cherokee/handler_scgi.c
View
@@ -163,8 +163,11 @@ cherokee_handler_scgi_new (cherokee_handler_t **hdl, void *cnt, cherokee_module_
/* Init the base class
*/
- cherokee_handler_cgi_base_init (HDL_CGI_BASE(n), cnt, PLUGIN_INFO_HANDLER_PTR(scgi),
- HANDLER_PROPS(props), add_env_pair, read_from_scgi);
+ cherokee_handler_cgi_base_init (
+ HDL_CGI_BASE(n), cnt,
+ PLUGIN_INFO_HANDLER_PTR(scgi),
+ HANDLER_PROPS(props),
+ add_env_pair, read_from_scgi);
/* Virtual methods
*/
@@ -215,7 +218,8 @@ netstringer (cherokee_buffer_t *buf)
CHEROKEE_TEMP(num,16);
len = snprintf (num, num_size, "%d:", buf->len);
- if (len < 0) return ret_error;
+ if (len < 0)
+ return ret_error;
cherokee_buffer_ensure_size (buf, buf->len + len + 2);
cherokee_buffer_prepend (buf, num, len);
43 cherokee/handler_webcam.c
View
@@ -57,52 +57,54 @@ cherokee_handler_webcam_new (cherokee_handler_t **hdl, void *cnt, cherokee_table
static ret_t
grab_image (cherokee_handler_webcam_t *hdl)
{
- /* TODO
- */
- return ret_ok;
+ /* TODO
+ */
+ return ret_ok;
}
ret_t
cherokee_handler_webcam_init (cherokee_handler_webcam_t *hdl)
{
- ret_t ret;
+ ret_t ret;
- ret = grab_image (hdl);
- if (ret < ret_ok) return ret;
+ ret = grab_image (hdl);
+ if (ret < ret_ok)
+ return ret;
- return ret_ok;
+ return ret_ok;
}
ret_t
cherokee_handler_webcam_free (cherokee_handler_webcam_t *hdl)
{
- if (hdl->jpeg != NULL) {
- free (hdl->jpeg);
- }
+ if (hdl->jpeg != NULL) {
+ free (hdl->jpeg);
+ }
- return ret_ok;
+ return ret_ok;
}
ret_t
cherokee_handler_webcam_add_headers (cherokee_handler_webcam_t *hdl, cherokee_buffer_t *buffer)
{
- cherokee_buffer_add_str (buffer, "Content-Type: image/jpeg"CRLF);
- return ret_ok;
+ cherokee_buffer_add_str (buffer, "Content-Type: image/jpeg"CRLF);
+ return ret_ok;
}
ret_t
cherokee_handler_webcam_step (cherokee_handler_webcam_t *hdl, cherokee_buffer_t *buffer)
{
- ret_t ret;
+ ret_t ret;
- ret = cherokee_buffer_add (buffer, hdl->jpeg, hdl->jpeg_len);
- if (ret < ret_ok) return ret;
+ ret = cherokee_buffer_add (buffer, hdl->jpeg, hdl->jpeg_len);
+ if (ret < ret_ok)
+ return ret;
- return ret_eof_have_data;
+ return ret_eof_have_data;
}
@@ -113,6 +115,9 @@ static cherokee_boolean_t _is_init = false;
void
webcam_init (cherokee_module_loader_t *loader)
{
- if (_is_init) return;
- _is_init = true;
+ if (_is_init)
+ return;
+
+ _is_init = true;
}
+
Please sign in to comment.
Something went wrong with that request. Please try again.