Changeset 1500

Show
Ignore:
Timestamp:
01/03/2007 09:46:32 AM (20 months ago)
Author:
jakabosky
Message:

Added round-robin support to mod_fastcgi.

Location:
branches/lighttpd-1.4.x/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/lighttpd-1.4.x/src/mod_fastcgi.c

    r1371 r1500  
    276276 
    277277        int note_is_sent; 
     278        int last_used_ndx; 
    278279 
    279280        fcgi_extension_host **hosts; 
     
    564565                assert(fe); 
    565566                fe->key = buffer_init(); 
     567                fe->last_used_ndx = -1; 
    566568                buffer_copy_string_buffer(fe->key, key); 
    567569 
     
    23822384                /* append to read-buffer */ 
    23832385                if (-1 == (r = read(hctx->fd, b->ptr, toread))) { 
     2386                        if (errno == EAGAIN) return 0; 
    23842387                        log_error_write(srv, __FILE__, __LINE__, "sds", 
    23852388                                        "unexpected end-of-file (perhaps the fastcgi process died):", 
     
    29802983                int ndx, used = -1; 
    29812984 
    2982                 /* get best server */ 
    2983                 for (k = 0, ndx = -1; k < hctx->ext->used; k++) { 
    2984                         host = hctx->ext->hosts[k]; 
    2985  
    2986                         /* we should have at least one proc that can do something */ 
    2987                         if (host->active_procs == 0) continue; 
    2988  
    2989                         if (used == -1 || host->load < used) { 
    2990                                 used = host->load; 
    2991  
    2992                                 ndx = k; 
     2985                /* check if the next server has no load. */ 
     2986                ndx = hctx->ext->last_used_ndx + 1; 
     2987                if(ndx >= hctx->ext->used || ndx < 0) ndx = 0; 
     2988                host = hctx->ext->hosts[ndx]; 
     2989                if (host->load > 0) { 
     2990                        /* get backend with the least load. */ 
     2991                        for (k = 0, ndx = -1; k < hctx->ext->used; k++) { 
     2992                                host = hctx->ext->hosts[k]; 
     2993 
     2994                                /* we should have at least one proc that can do something */ 
     2995                                if (host->active_procs == 0) continue; 
     2996 
     2997                                if (used == -1 || host->load < used) { 
     2998                                        used = host->load; 
     2999 
     3000                                        ndx = k; 
     3001                                } 
    29933002                        } 
    29943003                } 
     
    30063015                } 
    30073016 
     3017                hctx->ext->last_used_ndx = ndx; 
    30083018                host = hctx->ext->hosts[ndx]; 
    30093019 
  • branches/lighttpd-1.4.x/src/mod_proxy.c

    r1371 r1500  
    657657 
    658658                if (-1 == (r = read(hctx->fd, hctx->response->ptr + hctx->response->used - 1, b))) { 
     659                        if (errno == EAGAIN) return 0; 
    659660                        log_error_write(srv, __FILE__, __LINE__, "sds", 
    660661                                        "unexpected end-of-file (perhaps the proxy process died):",