Changeset 1849
- Timestamp:
- 08/16/08 00:32:36 (3 months ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (2 diffs)
- cherokee/trunk/cherokee/handler_fcgi.c (modified) (2 diffs)
- cherokee/trunk/cherokee/handler_mirror.c (modified) (2 diffs)
- cherokee/trunk/cherokee/handler_scgi.c (modified) (2 diffs)
- cherokee/trunk/cherokee/source.c (modified) (3 diffs)
- cherokee/trunk/cherokee/source.h (modified) (2 diffs)
- cherokee/trunk/cherokee/source_interpreter.c (modified) (3 diffs)
- cherokee/trunk/cherokee/source_interpreter.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r1845 r1849 1 2008-08-14 Taher Shihadeh <taher@unixwars.com>2 3 * admin/PageVServers.py, admin/PageVServer.py,4 admin/static/css/cherokee.css: addresses UI enhancement proposal5 at http://code.google.com/p/cherokee/issues/detail?id=86.6 7 1 2008-08-15 Alvaro Lopez Ortega <alvaro@alobbs.com> 2 3 * cherokee/handler_mirror.c, cherokee/source_interpreter.c, 4 cherokee/source_interpreter.h, cherokee/source.c, 5 cherokee/source.h, cherokee/handler_fcgi.c, 6 cherokee/handler_scgi.c: Clean up the code where handler were 7 using 'source' object in order to connect to an external 8 information source. This path removes some code duplication. 8 9 9 10 * admin/PageVServer.py (PageVServer._render_vserver_guts): Fixes … … 11 12 the security files (certificates and keys) because a previous 12 13 variable value messed up the property key. 14 15 2008-08-14 Taher Shihadeh <taher@unixwars.com> 16 17 * admin/PageVServers.py, admin/PageVServer.py, 18 admin/static/css/cherokee.css: addresses UI enhancement proposal 19 at http://code.google.com/p/cherokee/issues/detail?id=86. 13 20 14 21 2008-08-14 Alvaro Lopez Ortega <alvaro@alobbs.com> cherokee/trunk/cherokee/handler_fcgi.c
r1745 r1849 502 502 { 503 503 ret_t ret; 504 cherokee_source_interpreter_t *src_int; 505 cherokee_connection_t *conn = HANDLER_CONN(hdl); 506 cherokee_handler_fcgi_props_t *props = HANDLER_FCGI_PROPS(hdl); 504 cherokee_connection_t *conn = HANDLER_CONN(hdl); 505 cherokee_handler_fcgi_props_t *props = HANDLER_FCGI_PROPS(hdl); 507 506 508 507 /* Get a reference to the target host … … 514 513 } 515 514 516 src_int = SOURCE_INT(hdl->src_ref);517 518 515 /* Try to connect 519 516 */ 520 ret = cherokee_source_connect (hdl->src_ref, &hdl->socket); 521 switch (ret) { 522 case ret_ok: 523 goto out; 524 case ret_deny: 525 break; 526 case ret_eagain: 527 ret = cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl), 528 conn, 529 SOCKET_FD(&hdl->socket), 530 FDPOLL_MODE_WRITE, 531 false); 532 if (ret != ret_ok) { 533 return ret_deny; 534 } 535 536 return ret_eagain; 537 case ret_error: 538 return ret_error; 539 default: 540 break; 541 } 542 543 /* In case it did not success, launch a interpreter 544 */ 545 if (hdl->spawned == 0) { 546 /* Launch a new interpreter */ 547 ret = cherokee_source_interpreter_spawn (src_int); 548 if (ret != ret_ok) { 549 if (src_int->interpreter.buf) 550 TRACE (ENTRIES, "Couldn't spawn: %s\n", 551 src_int->interpreter.buf); 552 else 553 TRACE (ENTRIES, "No interpreter to be spawned %s", "\n"); 554 return ret_error; 555 } 556 557 hdl->spawned = cherokee_bogonow_now; 558 559 /* Reset the internal socket */ 560 cherokee_socket_close (&hdl->socket); 561 562 } else if (cherokee_bogonow_now > hdl->spawned + 3) { 563 TRACE (ENTRIES, "Giving up; spawned 3 secs ago: %s\n", 564 src_int->interpreter.buf); 565 return ret_error; 566 567 } 568 569 return ret_eagain; 570 571 out: 572 TRACE (ENTRIES, "Connected successfully fd=%d\n", hdl->socket.socket); 573 return ret_ok; 517 if (hdl->src_ref->type == source_host) 518 return cherokee_source_connect_polling (hdl->src_ref, &hdl->socket, conn); 519 520 return cherokee_source_interpreter_connect_polling (SOURCE_INT(hdl->src_ref), 521 &hdl->socket, conn, 522 &hdl->spawned); 574 523 } 575 524 cherokee/trunk/cherokee/handler_mirror.c
r1848 r1849 148 148 cherokee_handler_mirror_props_t *props = HDL_MIRROR_PROPS(hdl); 149 149 150 /* Pick a host 151 */ 150 152 if (hdl->src_ref == NULL) { 151 153 ret = cherokee_balancer_dispatch (props->balancer, conn, &hdl->src_ref); … … 156 158 /* Try to connect 157 159 */ 158 ret = cherokee_source_connect (hdl->src_ref, &hdl->socket); 159 switch (ret) { 160 case ret_ok: 161 TRACE (ENTRIES, "Connected successfully fd=%d\n", 162 hdl->socket.socket); 163 return ret_ok; 164 case ret_deny: 165 break; 166 case ret_eagain: 167 ret = cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl), 168 conn, 169 SOCKET_FD(&hdl->socket), 170 FDPOLL_MODE_WRITE, 171 false); 172 if (ret != ret_ok) { 173 return ret_deny; 174 } 175 176 return ret_eagain; 177 case ret_error: 178 return ret_error; 179 default: 180 break; 181 } 182 183 TRACE (ENTRIES, "Couldn't connect%s", "\n"); 184 return ret_error; 160 return cherokee_source_connect_polling (hdl->src_ref, &hdl->socket, conn); 185 161 } 186 162 cherokee/trunk/cherokee/handler_scgi.c
r1754 r1849 257 257 { 258 258 ret_t ret; 259 cherokee_source_interpreter_t *src_int; 260 cherokee_connection_t *conn = HANDLER_CONN(hdl); 261 cherokee_handler_scgi_props_t *props = HANDLER_SCGI_PROPS(hdl); 259 cherokee_connection_t *conn = HANDLER_CONN(hdl); 260 cherokee_handler_scgi_props_t *props = HANDLER_SCGI_PROPS(hdl); 262 261 263 262 /* Get a reference to the target host … … 269 268 } 270 269 271 src_int = SOURCE_INT(hdl->src_ref);272 273 270 /* Try to connect 274 271 */ 275 ret = cherokee_source_connect (hdl->src_ref, &hdl->socket); 276 switch (ret) { 277 case ret_ok: 278 goto out; 279 case ret_deny: 280 break; 281 case ret_eagain: 282 ret = cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl), 283 conn, 284 SOCKET_FD(&hdl->socket), 285 FDPOLL_MODE_WRITE, 286 false); 287 if (ret != ret_ok) { 288 return ret_deny; 289 } 290 291 return ret_eagain; 292 case ret_error: 293 return ret_error; 294 default: 295 break; 296 } 297 298 /* In case it did not success, launch a interpreter 299 */ 300 if (hdl->spawned == 0) { 301 /* Launch a new interpreter */ 302 ret = cherokee_source_interpreter_spawn (src_int); 303 if (ret != ret_ok) { 304 if (src_int->interpreter.buf) 305 TRACE (ENTRIES, "Couldn't spawn: %s\n", 306 src_int->interpreter.buf); 307 else 308 TRACE (ENTRIES, "No interpreter to be spawned %s", "\n"); 309 return ret_error; 310 } 311 312 hdl->spawned = cherokee_bogonow_now; 313 314 /* Reset the internal socket */ 315 cherokee_socket_close (&hdl->socket); 316 317 } else if (cherokee_bogonow_now > hdl->spawned + 3) { 318 TRACE (ENTRIES, "Giving up; spawned 3 secs ago: %s\n", 319 src_int->interpreter.buf); 320 return ret_error; 321 322 } 323 324 return ret_eagain; 325 326 out: 327 TRACE (ENTRIES, "Connected successfully fd=%d\n", hdl->socket.socket); 328 return ret_ok; 272 if (hdl->src_ref->type == source_host) 273 return cherokee_source_connect_polling (hdl->src_ref, &hdl->socket, conn); 274 275 return cherokee_source_interpreter_connect_polling (SOURCE_INT(hdl->src_ref), 276 &hdl->socket, conn, 277 &hdl->spawned); 329 278 } 330 279 cherokee/trunk/cherokee/source.c
r1799 r1849 28 28 #include "resolv_cache.h" 29 29 #include "util.h" 30 #include "thread.h" 31 #include "connection-protected.h" 30 32 31 33 #define ENTRIES "source,src" … … 45 47 cherokee_buffer_init (&src->host); 46 48 49 src->type = source_host; 47 50 src->port = -1; 48 51 src->free = NULL; … … 123 126 out: 124 127 return cherokee_socket_connect (sock); 128 } 129 130 131 ret_t 132 cherokee_source_connect_polling (cherokee_source_t *src, 133 cherokee_socket_t *socket, 134 cherokee_connection_t *conn) 135 { 136 ret_t ret; 137 138 ret = cherokee_source_connect (src, socket); 139 switch (ret) { 140 case ret_ok: 141 TRACE (ENTRIES, "Connected successfully fd=%d\n", socket->socket); 142 return ret_ok; 143 case ret_deny: 144 break; 145 case ret_eagain: 146 ret = cherokee_thread_deactive_to_polling (CONN_THREAD(conn), 147 conn, 148 SOCKET_FD(socket), 149 FDPOLL_MODE_WRITE, 150 false); 151 if (ret != ret_ok) { 152 return ret_deny; 153 } 154 return ret_eagain; 155 case ret_error: 156 return ret_error; 157 default: 158 break; 159 } 160 161 TRACE (ENTRIES, "Couldn't connect%s", "\n"); 162 return ret_error; 125 163 } 126 164 cherokee/trunk/cherokee/source.h
r1131 r1849 34 34 #include <cherokee/socket.h> 35 35 #include <cherokee/config_node.h> 36 #include <cherokee/connection.h> 36 37 37 38 CHEROKEE_BEGIN_DECLS 38 39 40 typedef enum { 41 source_host, 42 source_interpreter 43 } cherokee_source_type_t; 39 44 40 45 typedef struct { 41 cherokee_list_t list;46 cherokee_list_t list; 42 47 43 cherokee_buffer_t original; 44 cherokee_buffer_t unix_socket; 45 cherokee_buffer_t host; 46 cint_t port; 48 cherokee_source_type_t type; 49 cherokee_buffer_t original; 50 cherokee_buffer_t unix_socket; 51 cherokee_buffer_t host; 52 cint_t port; 47 53 48 cherokee_func_free_t free;54 cherokee_func_free_t free; 49 55 } cherokee_source_t; 50 56 … … 56 62 ret_t cherokee_source_mrproper (cherokee_source_t *src); 57 63 58 ret_t cherokee_source_configure (cherokee_source_t *src, cherokee_config_node_t *conf); 59 ret_t cherokee_source_connect (cherokee_source_t *src, cherokee_socket_t *socket); 64 ret_t cherokee_source_configure (cherokee_source_t *src, cherokee_config_node_t *conf); 65 ret_t cherokee_source_connect (cherokee_source_t *src, cherokee_socket_t *socket); 66 67 ret_t cherokee_source_connect_polling (cherokee_source_t *src, 68 cherokee_socket_t *socket, 69 cherokee_connection_t *conn); 60 70 61 71 CHEROKEE_END_DECLS cherokee/trunk/cherokee/source_interpreter.c
r1131 r1849 26 26 #include "source_interpreter.h" 27 27 #include "util.h" 28 #include "connection-protected.h" 29 #include "thread.h" 30 #include "bogotime.h" 28 31 29 32 #include <sys/types.h> … … 47 50 n->custom_env_len = 0; 48 51 52 SOURCE(n)->type = source_interpreter; 49 53 SOURCE(n)->free = (cherokee_func_free_t)interpreter_free; 50 54 … … 247 251 return ret_error; 248 252 } 253 254 255 ret_t 256 cherokee_source_interpreter_connect_polling (cherokee_source_interpreter_t *src, 257 cherokee_socket_t *socket, 258 cherokee_connection_t *conn, 259 time_t *spawned) 260 { 261 ret_t ret; 262 263 /* Try to connect 264 */ 265 ret = cherokee_source_connect (SOURCE(src), socket); 266 switch (ret) { 267 case ret_ok: 268 goto out; 269 case ret_deny: 270 break; 271 case ret_eagain: 272 ret = cherokee_thread_deactive_to_polling (CONN_THREAD(conn), 273 conn, 274 SOCKET_FD(socket), 275 FDPOLL_MODE_WRITE, 276 false); 277 if (ret != ret_ok) { 278 return ret_deny; 279 } 280 return ret_eagain; 281 case ret_error: 282 return ret_error; 283 default: 284 break; 285 } 286 287 /* In case it did not success, launch a interpreter 288 */ 289 if (*spawned == 0) { 290 /* Launch a new interpreter */ 291 ret = cherokee_source_interpreter_spawn (src); 292 if (ret != ret_ok) { 293 if (src->interpreter.buf) 294 TRACE (ENTRIES, "Couldn't spawn: %s\n", 295 src->interpreter.buf); 296 else 297 TRACE (ENTRIES, "No interpreter to be spawned %s", "\n"); 298 return ret_error; 299 } 300 301 *spawned = cherokee_bogonow_now; 302 303 /* Reset the internal socket */ 304 cherokee_socket_close (socket); 305 306 } else if (cherokee_bogonow_now > *spawned + 3) { 307 TRACE (ENTRIES, "Giving up; spawned 3 secs ago: %s\n", 308 src->interpreter.buf); 309 return ret_error; 310 } 311 312 return ret_eagain; 313 314 out: 315 TRACE (ENTRIES, "Connected successfully fd=%d\n", socket->socket); 316 return ret_ok; 317 } cherokee/trunk/cherokee/source_interpreter.h
r1131 r1849 49 49 ret_t cherokee_source_interpreter_spawn (cherokee_source_interpreter_t *src); 50 50 51 ret_t cherokee_source_interpreter_connect_polling (cherokee_source_interpreter_t *src, 52 cherokee_socket_t *socket, 53 cherokee_connection_t *conn, 54 time_t *spawned); 55 51 56 CHEROKEE_END_DECLS 52 57