Changeset 1789

Show
Ignore:
Timestamp:
08/13/08 11:14:13 (3 months ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/ChangeLog

    r1788 r1789  
     12008-08-13  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
     2 
     3        * cherokee/handler_mirror.c, cherokee/handler_mirror.h: Fixes the 
     4        TCP mirroring handler. It fixes it to use the new async client 
     5        connections. 
     6 
    172008-08-12  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
    28 
  • cherokee/trunk/cherokee/handler_mirror.c

    r1439 r1789  
    2828#include "connection-protected.h" 
    2929#include "thread.h" 
    30  
     30#include "source.h" 
    3131 
    3232#define ENTRIES "handler,mirror" 
     
    113113        n->post_sent   = 0; 
    114114        n->post_len    = 0; 
     115        n->src_ref     = NULL; 
    115116        n->phase       = hmirror_phase_connect; 
    116117 
     
    138139{ 
    139140        ret_t                            ret; 
    140         cherokee_source_t               *src   = NULL; 
    141         cherokee_connection_t           *conn  = HANDLER_CONN(hdl); 
    142         cherokee_handler_mirror_props_t *props = HDL_MIRROR_PROPS(hdl); 
    143  
    144         ret = cherokee_balancer_dispatch (props->balancer, conn, &src); 
    145         if (ret != ret_ok) 
    146                 return ret; 
    147  
    148         ret = cherokee_source_connect (src, &hdl->socket);  
     141        cherokee_connection_t           *conn     = HANDLER_CONN(hdl); 
     142        cherokee_handler_mirror_props_t *props    = HDL_MIRROR_PROPS(hdl); 
     143 
     144        if (hdl->src_ref == NULL) { 
     145                ret = cherokee_balancer_dispatch (props->balancer, conn, &hdl->src_ref); 
     146                if (ret != ret_ok) 
     147                        return ret; 
     148        } 
     149 
     150        /* Try to connect 
     151         */ 
     152        ret = cherokee_source_connect (hdl->src_ref, &hdl->socket);  
    149153        switch (ret) { 
    150154        case ret_ok: 
     155                TRACE (ENTRIES, "Connected successfully fd=%d\n",  
     156                       hdl->socket.socket); 
     157                return ret_ok; 
     158        case ret_deny: 
    151159                break; 
    152         case ret_deny: 
    153                 conn->error_code = http_bad_gateway; 
     160        case ret_eagain: 
     161                ret = cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl), 
     162                                                           conn, 
     163                                                           SOCKET_FD(&hdl->socket), 
     164                                                           FDPOLL_MODE_WRITE,  
     165                                                           false); 
     166                if (ret != ret_ok) { 
     167                        return ret_deny; 
     168                } 
     169 
     170                return ret_eagain; 
     171        case ret_error: 
    154172                return ret_error; 
    155173        default: 
    156                 return ret_error
    157         } 
    158  
    159        TRACE (ENTRIES, "connected fd=%d\n", hdl->socket.socket); 
    160         return ret_ok
     174                break
     175        } 
     176 
     177       TRACE (ENTRIES, "Couldn't connect%s", "\n"); 
     178        return ret_error
    161179} 
    162180 
     
    288306 
    289307        case ret_eagain: 
    290                 cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl), HANDLER_CONN(hdl),  
    291                                                      hdl->socket.socket, 0, false); 
     308                cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl),  
     309                                                     HANDLER_CONN(hdl),  
     310                                                     hdl->socket.socket,  
     311                                                     FDPOLL_MODE_READ, 
     312                                                     false); 
    292313                return ret_eagain; 
    293314 
    294315        case ret_eof: 
    295316        case ret_error: 
    296                 return ret_ok
     317                return ret
    297318 
    298319        default: 
  • cherokee/trunk/cherokee/handler_mirror.h

    r1131 r1789  
    4747        cherokee_handler_t              base; 
    4848        cherokee_socket_t               socket; 
     49        cherokee_source_t              *src_ref; 
    4950 
    5051        cherokee_handler_mirror_phase_t phase;