Permalink
Browse files

git-svn-id: svn://cherokee-project.com/cherokee/trunk@1849 5dc97367-9…

…7f1-0310-9951-d761b3857238
  • Loading branch information...
1 parent 2930555 commit 5695e2335f47debfe151ea099fb248bbe7207020 @alobbs alobbs committed Aug 15, 2008
Showing with 160 additions and 157 deletions.
  1. +13 −6 ChangeLog
  2. +7 −58 cherokee/handler_fcgi.c
  3. +3 −27 cherokee/handler_mirror.c
  4. +7 −58 cherokee/handler_scgi.c
  5. +38 −0 cherokee/source.c
  6. +18 −8 cherokee/source.h
  7. +69 −0 cherokee/source_interpreter.c
  8. +5 −0 cherokee/source_interpreter.h
View
@@ -1,16 +1,23 @@
-2008-08-14 Taher Shihadeh <taher@unixwars.com>
-
- * admin/PageVServers.py, admin/PageVServer.py,
- admin/static/css/cherokee.css: addresses UI enhancement proposal
- at http://code.google.com/p/cherokee/issues/detail?id=86.
-
2008-08-15 Alvaro Lopez Ortega <alvaro@alobbs.com>
+ * cherokee/handler_mirror.c, cherokee/source_interpreter.c,
+ cherokee/source_interpreter.h, cherokee/source.c,
+ cherokee/source.h, cherokee/handler_fcgi.c,
+ cherokee/handler_scgi.c: Clean up the code where handler were
+ using 'source' object in order to connect to an external
+ information source. This path removes some code duplication.
+
* admin/PageVServer.py (PageVServer._render_vserver_guts): Fixes
an unfortunate error. The administration interface fails to set
the security files (certificates and keys) because a previous
variable value messed up the property key.
+2008-08-14 Taher Shihadeh <taher@unixwars.com>
+
+ * admin/PageVServers.py, admin/PageVServer.py,
+ admin/static/css/cherokee.css: addresses UI enhancement proposal
+ at http://code.google.com/p/cherokee/issues/detail?id=86.
+
2008-08-14 Alvaro Lopez Ortega <alvaro@alobbs.com>
* cherokee/socket.c, cherokee/socket.h, cherokee/thread.c,
View
@@ -501,9 +501,8 @@ static ret_t
connect_to_server (cherokee_handler_fcgi_t *hdl)
{
ret_t ret;
- cherokee_source_interpreter_t *src_int;
- cherokee_connection_t *conn = HANDLER_CONN(hdl);
- cherokee_handler_fcgi_props_t *props = HANDLER_FCGI_PROPS(hdl);
+ cherokee_connection_t *conn = HANDLER_CONN(hdl);
+ cherokee_handler_fcgi_props_t *props = HANDLER_FCGI_PROPS(hdl);
/* Get a reference to the target host
*/
@@ -513,64 +512,14 @@ connect_to_server (cherokee_handler_fcgi_t *hdl)
return ret;
}
- src_int = SOURCE_INT(hdl->src_ref);
-
/* Try to connect
*/
- ret = cherokee_source_connect (hdl->src_ref, &hdl->socket);
- switch (ret) {
- case ret_ok:
- goto out;
- case ret_deny:
- break;
- case ret_eagain:
- ret = cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl),
- conn,
- SOCKET_FD(&hdl->socket),
- FDPOLL_MODE_WRITE,
- false);
- if (ret != ret_ok) {
- return ret_deny;
- }
-
- return ret_eagain;
- case ret_error:
- return ret_error;
- default:
- break;
- }
+ if (hdl->src_ref->type == source_host)
+ return cherokee_source_connect_polling (hdl->src_ref, &hdl->socket, conn);
- /* In case it did not success, launch a interpreter
- */
- if (hdl->spawned == 0) {
- /* Launch a new interpreter */
- ret = cherokee_source_interpreter_spawn (src_int);
- if (ret != ret_ok) {
- if (src_int->interpreter.buf)
- TRACE (ENTRIES, "Couldn't spawn: %s\n",
- src_int->interpreter.buf);
- else
- TRACE (ENTRIES, "No interpreter to be spawned %s", "\n");
- return ret_error;
- }
-
- hdl->spawned = cherokee_bogonow_now;
-
- /* Reset the internal socket */
- cherokee_socket_close (&hdl->socket);
-
- } else if (cherokee_bogonow_now > hdl->spawned + 3) {
- TRACE (ENTRIES, "Giving up; spawned 3 secs ago: %s\n",
- src_int->interpreter.buf);
- return ret_error;
-
- }
-
- return ret_eagain;
-
-out:
- TRACE (ENTRIES, "Connected successfully fd=%d\n", hdl->socket.socket);
- return ret_ok;
+ return cherokee_source_interpreter_connect_polling (SOURCE_INT(hdl->src_ref),
+ &hdl->socket, conn,
+ &hdl->spawned);
}
View
@@ -147,6 +147,8 @@ connect_to_server (cherokee_handler_mirror_t *hdl)
cherokee_connection_t *conn = HANDLER_CONN(hdl);
cherokee_handler_mirror_props_t *props = HDL_MIRROR_PROPS(hdl);
+ /* Pick a host
+ */
if (hdl->src_ref == NULL) {
ret = cherokee_balancer_dispatch (props->balancer, conn, &hdl->src_ref);
if (ret != ret_ok)
@@ -155,33 +157,7 @@ connect_to_server (cherokee_handler_mirror_t *hdl)
/* Try to connect
*/
- ret = cherokee_source_connect (hdl->src_ref, &hdl->socket);
- switch (ret) {
- case ret_ok:
- TRACE (ENTRIES, "Connected successfully fd=%d\n",
- hdl->socket.socket);
- return ret_ok;
- case ret_deny:
- break;
- case ret_eagain:
- ret = cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl),
- conn,
- SOCKET_FD(&hdl->socket),
- FDPOLL_MODE_WRITE,
- false);
- if (ret != ret_ok) {
- return ret_deny;
- }
-
- return ret_eagain;
- case ret_error:
- return ret_error;
- default:
- break;
- }
-
- TRACE (ENTRIES, "Couldn't connect%s", "\n");
- return ret_error;
+ return cherokee_source_connect_polling (hdl->src_ref, &hdl->socket, conn);
}
View
@@ -256,9 +256,8 @@ static ret_t
connect_to_server (cherokee_handler_scgi_t *hdl)
{
ret_t ret;
- cherokee_source_interpreter_t *src_int;
- cherokee_connection_t *conn = HANDLER_CONN(hdl);
- cherokee_handler_scgi_props_t *props = HANDLER_SCGI_PROPS(hdl);
+ cherokee_connection_t *conn = HANDLER_CONN(hdl);
+ cherokee_handler_scgi_props_t *props = HANDLER_SCGI_PROPS(hdl);
/* Get a reference to the target host
*/
@@ -268,64 +267,14 @@ connect_to_server (cherokee_handler_scgi_t *hdl)
return ret;
}
- src_int = SOURCE_INT(hdl->src_ref);
-
/* Try to connect
*/
- ret = cherokee_source_connect (hdl->src_ref, &hdl->socket);
- switch (ret) {
- case ret_ok:
- goto out;
- case ret_deny:
- break;
- case ret_eagain:
- ret = cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl),
- conn,
- SOCKET_FD(&hdl->socket),
- FDPOLL_MODE_WRITE,
- false);
- if (ret != ret_ok) {
- return ret_deny;
- }
-
- return ret_eagain;
- case ret_error:
- return ret_error;
- default:
- break;
- }
+ if (hdl->src_ref->type == source_host)
+ return cherokee_source_connect_polling (hdl->src_ref, &hdl->socket, conn);
- /* In case it did not success, launch a interpreter
- */
- if (hdl->spawned == 0) {
- /* Launch a new interpreter */
- ret = cherokee_source_interpreter_spawn (src_int);
- if (ret != ret_ok) {
- if (src_int->interpreter.buf)
- TRACE (ENTRIES, "Couldn't spawn: %s\n",
- src_int->interpreter.buf);
- else
- TRACE (ENTRIES, "No interpreter to be spawned %s", "\n");
- return ret_error;
- }
-
- hdl->spawned = cherokee_bogonow_now;
-
- /* Reset the internal socket */
- cherokee_socket_close (&hdl->socket);
-
- } else if (cherokee_bogonow_now > hdl->spawned + 3) {
- TRACE (ENTRIES, "Giving up; spawned 3 secs ago: %s\n",
- src_int->interpreter.buf);
- return ret_error;
-
- }
-
- return ret_eagain;
-
-out:
- TRACE (ENTRIES, "Connected successfully fd=%d\n", hdl->socket.socket);
- return ret_ok;
+ return cherokee_source_interpreter_connect_polling (SOURCE_INT(hdl->src_ref),
+ &hdl->socket, conn,
+ &hdl->spawned);
}
View
@@ -27,6 +27,8 @@
#include "config_node.h"
#include "resolv_cache.h"
#include "util.h"
+#include "thread.h"
+#include "connection-protected.h"
#define ENTRIES "source,src"
@@ -44,6 +46,7 @@ cherokee_source_init (cherokee_source_t *src)
cherokee_buffer_init (&src->unix_socket);
cherokee_buffer_init (&src->host);
+ src->type = source_host;
src->port = -1;
src->free = NULL;
@@ -125,6 +128,41 @@ cherokee_source_connect (cherokee_source_t *src, cherokee_socket_t *sock)
}
+ret_t
+cherokee_source_connect_polling (cherokee_source_t *src,
+ cherokee_socket_t *socket,
+ cherokee_connection_t *conn)
+{
+ ret_t ret;
+
+ ret = cherokee_source_connect (src, socket);
+ switch (ret) {
+ case ret_ok:
+ TRACE (ENTRIES, "Connected successfully fd=%d\n", socket->socket);
+ return ret_ok;
+ case ret_deny:
+ break;
+ case ret_eagain:
+ ret = cherokee_thread_deactive_to_polling (CONN_THREAD(conn),
+ conn,
+ SOCKET_FD(socket),
+ FDPOLL_MODE_WRITE,
+ false);
+ if (ret != ret_ok) {
+ return ret_deny;
+ }
+ return ret_eagain;
+ case ret_error:
+ return ret_error;
+ default:
+ break;
+ }
+
+ TRACE (ENTRIES, "Couldn't connect%s", "\n");
+ return ret_error;
+}
+
+
static ret_t
set_host (cherokee_source_t *src, cherokee_buffer_t *host)
{
View
@@ -33,19 +33,25 @@
#include <cherokee/buffer.h>
#include <cherokee/socket.h>
#include <cherokee/config_node.h>
+#include <cherokee/connection.h>
CHEROKEE_BEGIN_DECLS
+typedef enum {
+ source_host,
+ source_interpreter
+} cherokee_source_type_t;
typedef struct {
- cherokee_list_t list;
+ cherokee_list_t list;
- cherokee_buffer_t original;
- cherokee_buffer_t unix_socket;
- cherokee_buffer_t host;
- cint_t port;
+ cherokee_source_type_t type;
+ cherokee_buffer_t original;
+ cherokee_buffer_t unix_socket;
+ cherokee_buffer_t host;
+ cint_t port;
- cherokee_func_free_t free;
+ cherokee_func_free_t free;
} cherokee_source_t;
#define SOURCE(s) ((cherokee_source_t *)(s))
@@ -55,8 +61,12 @@ ret_t cherokee_source_free (cherokee_source_t *src);
ret_t cherokee_source_init (cherokee_source_t *src);
ret_t cherokee_source_mrproper (cherokee_source_t *src);
-ret_t cherokee_source_configure (cherokee_source_t *src, cherokee_config_node_t *conf);
-ret_t cherokee_source_connect (cherokee_source_t *src, cherokee_socket_t *socket);
+ret_t cherokee_source_configure (cherokee_source_t *src, cherokee_config_node_t *conf);
+ret_t cherokee_source_connect (cherokee_source_t *src, cherokee_socket_t *socket);
+
+ret_t cherokee_source_connect_polling (cherokee_source_t *src,
+ cherokee_socket_t *socket,
+ cherokee_connection_t *conn);
CHEROKEE_END_DECLS
Oops, something went wrong.

0 comments on commit 5695e23

Please sign in to comment.