Changeset 4381

Show
Ignore:
Timestamp:
12/03/09 12:02:46 (8 months ago)
Author:
tfheen
Message:

Merge r4356, r4357: Don't half-close probes, add .expected_response

r4356:
Don't halfclose the backend polling TCP connection after sending the
request, some backends gets confused by this.

Add a ".status" to backend polling, to configure the expected HTTP
status code for a good poll.

Fixes #584

r4357:
.expected_response is a better idea than .status

Tip o' the hat to: tfheen

Location:
branches/2.0/varnish-cache
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.c

    r4303 r4381  
    173173        } 
    174174        vt->good_xmit |= 1; 
    175  
    176         /* And do a shutdown(WR) so we know that the backend got it */ 
    177         i = shutdown(s, SHUT_WR); 
    178         if (i != 0) { 
    179                 vt->err_shut |= 1; 
    180                 TCP_close(&s); 
    181                 return; 
    182         } 
    183         vt->good_shut |= 1; 
    184  
    185         /* Check if that took too long time */ 
    186         t_now = TIM_real(); 
    187         tmo = (int)round((t_end - t_now) * 1e3); 
    188         if (tmo < 0) { 
    189                 TCP_close(&s); 
    190                 return; 
    191         } 
    192175 
    193176        pfd->fd = s; 
     
    237220        i = sscanf(vt->resp_buf, "HTTP/%*f %u %s", &resp, buf); 
    238221 
    239         if (i == 2 && resp == 200) 
     222        if (i == 2 && resp == vt->probe.exp_status) 
    240223                vt->happy |= 1; 
    241224} 
     
    336319        if (vt->probe.threshold == 0) 
    337320                vt->probe.threshold = 3; 
     321        if (vt->probe.exp_status == 0) 
     322                vt->probe.exp_status = 200; 
    338323 
    339324        if (vt->probe.threshold == ~0U) 
  • branches/2.0/varnish-cache/bin/varnishd/cache_backend_poll.h

    r3557 r4381  
    3434BITMAP( err_xmit, 'x', "Error Xmit", 0) 
    3535BITMAP(good_xmit, 'X', "Good Xmit", 0) 
    36 BITMAP( err_shut, 's', "Error Shut", 0) 
    37 BITMAP(good_shut, 'S', "Good Shut", 0) 
    3836BITMAP( err_recv, 'r', "Error Recv", 0) 
    3937BITMAP(good_recv, 'R', "Good Recv", 0) 
  • branches/2.0/varnish-cache/bin/varnishtest/tests/v00002.vtc

    r3293 r4381  
    186186} 
    187187 
     188 
     189varnish v1 -badvcl { 
     190        backend b1 { 
     191                .host = "127.0.0.1"; 
     192                .probe = { .expected_response = 13; } 
     193        } 
     194} 
     195 
  • branches/2.0/varnish-cache/bin/varnishtest/tests/v00005.vtc

    r3278 r4381  
    22 
    33test "VCL: test backend probe syntax" 
     4 
     5# Check status definition 
     6varnish v1 -vcl { 
     7        backend b1 { 
     8                .host = "127.0.0.1"; 
     9                .probe = { 
     10                        .expected_response = 204; 
     11                } 
     12        } 
     13} 
    414 
    515# Check url definition 
  • branches/2.0/varnish-cache/include/vrt.h

    r4303 r4381  
    5353        double          timeout; 
    5454        double          interval; 
     55        unsigned        exp_status; 
    5556        unsigned        window; 
    5657        unsigned        threshold; 
  • branches/2.0/varnish-cache/lib/libvcl/vcc_backend.c

    r4303 r4381  
    342342        struct token *t_did = NULL, *t_window = NULL, *t_threshold = NULL; 
    343343        struct token *t_initial = NULL; 
    344         unsigned window, threshold, initial; 
     344        unsigned window, threshold, initial, status; 
    345345 
    346346        fs = vcc_FldSpec(tl, 
    347347            "?url", 
    348348            "?request", 
     349            "?expected_response", 
    349350            "?timeout", 
    350351            "?interval", 
     
    360361        threshold = 0; 
    361362        initial = 0; 
     363        status = 0; 
    362364        Fb(tl, 0, "\t.probe = {\n"); 
    363365        while (tl->t->tok != '}') { 
     
    403405                        t_initial = tl->t; 
    404406                        initial = vcc_UintVal(tl); 
     407                        vcc_NextToken(tl); 
     408                        ERRCHK(tl); 
     409                } else if (vcc_IdIs(t_field, "expected_response")) { 
     410                        status = vcc_UintVal(tl); 
     411                        if (status < 100 || status > 999) { 
     412                                vsb_printf(tl->sb, 
     413                                    "Must specify .status with exactly three " 
     414                                    " digits (100 <= x <= 999)\n"); 
     415                                vcc_ErrWhere(tl, tl->t); 
     416                                return; 
     417                        } 
    405418                        vcc_NextToken(tl); 
    406419                        ERRCHK(tl); 
     
    456469        else 
    457470                Fb(tl, 0, "\t\t.initial = ~0U,\n", initial); 
     471        if (status > 0) 
     472                Fb(tl, 0, "\t\t.exp_status = %u,\n", status); 
    458473        Fb(tl, 0, "\t},\n"); 
    459474        ExpectErr(tl, '}'); 
  • branches/2.0/varnish-cache/lib/libvcl/vcc_fixed_token.c

    r4304 r4381  
    247247        vsb_cat(sb, "\nstruct vrt_backend_probe {\n\tconst char\t*url;\n"); 
    248248        vsb_cat(sb, "\tconst char\t*request;\n\tdouble\t\ttimeout;\n"); 
    249         vsb_cat(sb, "\tdouble\t\tinterval;\n\tunsigned\twindow;\n"); 
    250         vsb_cat(sb, "\tunsigned\tthreshold;\n\tunsigned\tinitial;\n"); 
    251         vsb_cat(sb, "};\n\n/*\n * A backend is a host+port somewhere on the"); 
    252         vsb_cat(sb, " network\n */\nstruct vrt_backend {\n"); 
    253         vsb_cat(sb, "\tconst char\t\t\t*vcl_name;\n\tconst char\t\t\t*ident"); 
    254         vsb_cat(sb, ";\n\n\tconst char\t\t\t*hosthdr;\n"); 
    255         vsb_cat(sb, "\n\tconst unsigned char\t\t*ipv4_sockaddr;\n"); 
     249        vsb_cat(sb, "\tdouble\t\tinterval;\n\tunsigned\texp_status;\n"); 
     250        vsb_cat(sb, "\tunsigned\twindow;\n\tunsigned\tthreshold;\n"); 
     251        vsb_cat(sb, "\tunsigned\tinitial;\n};\n\n/*\n"); 
     252        vsb_cat(sb, " * A backend is a host+port somewhere on the network\n"); 
     253        vsb_cat(sb, " */\nstruct vrt_backend {\n\tconst char\t\t\t*vcl_name"); 
     254        vsb_cat(sb, ";\n\tconst char\t\t\t*ident;\n\n"); 
     255        vsb_cat(sb, "\tconst char\t\t\t*hosthdr;\n\n"); 
     256        vsb_cat(sb, "\tconst unsigned char\t\t*ipv4_sockaddr;\n"); 
    256257        vsb_cat(sb, "\tconst unsigned char\t\t*ipv6_sockaddr;\n"); 
    257258        vsb_cat(sb, "\n\tdouble\t\t\t\tconnect_timeout;\n"); 
     
    325326        /* ../../include/vrt_obj.h */ 
    326327 
    327         vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 4082 2009-05-19 07:14:00Z "); 
    328         vsb_cat(sb, "sky $\n *\n * NB:  This file is machine generated, DO "); 
    329         vsb_cat(sb, "NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n"); 
     328        vsb_cat(sb, "/*\n * $Id$\n"); 
     329        vsb_cat(sb, " *\n * NB:  This file is machine generated, DO NOT EDI"); 
     330        vsb_cat(sb, "T!\n *\n * Edit vcc_gen_obj.tcl instead\n"); 
    330331        vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct "); 
    331332        vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");