Changeset 1849

Show
Ignore:
Timestamp:
08/16/08 00:32:36 (3 months ago)
Author:
alo
Message:

--

Files:

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 proposal 
    5         at http://code.google.com/p/cherokee/issues/detail?id=86. 
    6  
    712008-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. 
    89 
    910        * admin/PageVServer.py (PageVServer._render_vserver_guts): Fixes 
     
    1112        the security files (certificates and keys) because a previous 
    1213        variable value messed up the property key. 
     14 
     152008-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. 
    1320 
    14212008-08-14  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
  • cherokee/trunk/cherokee/handler_fcgi.c

    r1745 r1849  
    502502{ 
    503503        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); 
    507506 
    508507        /* Get a reference to the target host 
     
    514513        } 
    515514 
    516         src_int = SOURCE_INT(hdl->src_ref); 
    517  
    518515        /* Try to connect 
    519516         */ 
    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); 
    574523} 
    575524 
  • cherokee/trunk/cherokee/handler_mirror.c

    r1848 r1849  
    148148        cherokee_handler_mirror_props_t *props    = HDL_MIRROR_PROPS(hdl); 
    149149 
     150        /* Pick a host 
     151         */ 
    150152        if (hdl->src_ref == NULL) { 
    151153                ret = cherokee_balancer_dispatch (props->balancer, conn, &hdl->src_ref); 
     
    156158        /* Try to connect 
    157159         */ 
    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); 
    185161} 
    186162 
  • cherokee/trunk/cherokee/handler_scgi.c

    r1754 r1849  
    257257{ 
    258258        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); 
    262261 
    263262        /* Get a reference to the target host 
     
    269268        } 
    270269 
    271         src_int = SOURCE_INT(hdl->src_ref); 
    272  
    273270        /* Try to connect 
    274271         */ 
    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); 
    329278} 
    330279 
  • cherokee/trunk/cherokee/source.c

    r1799 r1849  
    2828#include "resolv_cache.h" 
    2929#include "util.h" 
     30#include "thread.h" 
     31#include "connection-protected.h" 
    3032 
    3133#define ENTRIES "source,src" 
     
    4547        cherokee_buffer_init (&src->host); 
    4648 
     49        src->type = source_host; 
    4750        src->port = -1; 
    4851        src->free = NULL; 
     
    123126out:     
    124127        return cherokee_socket_connect (sock); 
     128} 
     129 
     130 
     131ret_t 
     132cherokee_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; 
    125163} 
    126164 
  • cherokee/trunk/cherokee/source.h

    r1131 r1849  
    3434#include <cherokee/socket.h> 
    3535#include <cherokee/config_node.h> 
     36#include <cherokee/connection.h> 
    3637 
    3738CHEROKEE_BEGIN_DECLS 
    3839 
     40typedef enum { 
     41        source_host, 
     42        source_interpreter 
     43} cherokee_source_type_t; 
    3944 
    4045typedef struct { 
    41         cherokee_list_t      list; 
     46        cherokee_list_t        list; 
    4247         
    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; 
    4753 
    48         cherokee_func_free_t free; 
     54        cherokee_func_free_t   free; 
    4955} cherokee_source_t; 
    5056 
     
    5662ret_t cherokee_source_mrproper  (cherokee_source_t  *src); 
    5763 
    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); 
     64ret_t cherokee_source_configure (cherokee_source_t *src, cherokee_config_node_t *conf); 
     65ret_t cherokee_source_connect   (cherokee_source_t *src, cherokee_socket_t *socket); 
     66 
     67ret_t cherokee_source_connect_polling (cherokee_source_t     *src,  
     68                                       cherokee_socket_t     *socket, 
     69                                       cherokee_connection_t *conn); 
    6070 
    6171CHEROKEE_END_DECLS 
  • cherokee/trunk/cherokee/source_interpreter.c

    r1131 r1849  
    2626#include "source_interpreter.h" 
    2727#include "util.h" 
     28#include "connection-protected.h" 
     29#include "thread.h" 
     30#include "bogotime.h" 
    2831 
    2932#include <sys/types.h> 
     
    4750        n->custom_env_len = 0; 
    4851 
     52        SOURCE(n)->type   = source_interpreter; 
    4953        SOURCE(n)->free   = (cherokee_func_free_t)interpreter_free; 
    5054 
     
    247251        return ret_error; 
    248252} 
     253 
     254 
     255ret_t 
     256cherokee_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 
     314out: 
     315        TRACE (ENTRIES, "Connected successfully fd=%d\n", socket->socket); 
     316        return ret_ok; 
     317} 
  • cherokee/trunk/cherokee/source_interpreter.h

    r1131 r1849  
    4949ret_t cherokee_source_interpreter_spawn     (cherokee_source_interpreter_t *src); 
    5050 
     51ret_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 
    5156CHEROKEE_END_DECLS 
    5257