LCOV - code coverage report
Current view: top level - home/build/openresty-1.13.6.1/build/memc-nginx-module-0.18/src - ngx_http_memc_util.c (source / functions) Hit Total Coverage
Test: coverage ngix Lines: 0 57 0.0 %
Date: 2020-03-03 04:25:50 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : 
       2             : /*
       3             :  * Copyright (C) Yichun Zhang (agentzh)
       4             :  */
       5             : 
       6             : 
       7             : #ifndef DDEBUG
       8             : #define DDEBUG 0
       9             : #endif
      10             : #include "ddebug.h"
      11             : 
      12             : #include "ngx_http_memc_util.h"
      13             : 
      14             : ngx_http_memc_cmd_t
      15           0 : ngx_http_memc_parse_cmd(u_char *data, size_t len, ngx_flag_t *is_storage_cmd)
      16             : {
      17           0 :     switch (len) {
      18           0 :         case 3:
      19           0 :             if (ngx_http_memc_strcmp_const(data, "set") == 0) {
      20           0 :                 *is_storage_cmd = 1;
      21           0 :                 return ngx_http_memc_cmd_set;
      22             :             }
      23             : 
      24           0 :             if (ngx_http_memc_strcmp_const(data, "add") == 0) {
      25           0 :                 *is_storage_cmd = 1;
      26           0 :                 return ngx_http_memc_cmd_add;
      27             :             }
      28             : 
      29             :             /*
      30             :             if (ngx_str3cmp(data, 'c', 'a', 's')) {
      31             :                 *is_storage_cmd = 1;
      32             :                 return ngx_http_memc_cmd_cas;
      33             :             }
      34             :             */
      35             : 
      36           0 :             if (ngx_http_memc_strcmp_const(data, "get") == 0) {
      37           0 :                 return ngx_http_memc_cmd_get;
      38             :             }
      39             : 
      40           0 :             break;
      41             : 
      42           0 :         case 4:
      43             :             /*
      44             :             if (ngx_str4cmp(data, 'g', 'e', 't', 's')) {
      45             :                 return ngx_http_memc_cmd_gets;
      46             :             }
      47             :             */
      48             : 
      49           0 :             if (ngx_http_memc_strcmp_const(data, "incr") == 0) {
      50           0 :                 return ngx_http_memc_cmd_incr;
      51             :             }
      52             : 
      53           0 :             if (ngx_http_memc_strcmp_const(data, "decr") == 0) {
      54           0 :                 return ngx_http_memc_cmd_decr;
      55             :             }
      56             : 
      57           0 :             break;
      58             : 
      59           0 :         case 5:
      60           0 :             if (ngx_http_memc_strcmp_const(data, "stats") == 0) {
      61           0 :                 return ngx_http_memc_cmd_stats;
      62             :             }
      63             : 
      64           0 :             break;
      65             : 
      66           0 :         case 6:
      67           0 :             if (ngx_http_memc_strcmp_const(data, "append") == 0) {
      68           0 :                 *is_storage_cmd = 1;
      69           0 :                 return ngx_http_memc_cmd_append;
      70             :             }
      71             : 
      72           0 :             if (ngx_http_memc_strcmp_const(data, "delete") == 0) {
      73           0 :                 return ngx_http_memc_cmd_delete;
      74             :             }
      75             : 
      76           0 :             break;
      77             : 
      78           0 :         case 7:
      79           0 :             if (ngx_http_memc_strcmp_const(data, "replace") == 0) {
      80           0 :                 *is_storage_cmd = 1;
      81           0 :                 return ngx_http_memc_cmd_replace;
      82             :             }
      83             : 
      84           0 :             if (ngx_http_memc_strcmp_const(data, "prepend") == 0) {
      85           0 :                 *is_storage_cmd = 1;
      86           0 :                 return ngx_http_memc_cmd_prepend;
      87             :             }
      88             : 
      89           0 :             if (ngx_http_memc_strcmp_const(data, "version") == 0) {
      90           0 :                 return ngx_http_memc_cmd_version;
      91             :             }
      92             : 
      93           0 :             break;
      94             : 
      95           0 :         case 9:
      96           0 :             if (ngx_http_memc_strcmp_const(data, "flush_all") == 0) {
      97           0 :                 return ngx_http_memc_cmd_flush_all;
      98             :             }
      99             : 
     100             :             /*
     101             :             if (ngx_str9cmp(data, 'v', 'e', 'r', 'b', 'o', 's', 'i', 't', 'y'))
     102             :             {
     103             :                 return ngx_http_memc_cmd_verbosity;
     104             :             }
     105             :             */
     106             : 
     107           0 :             break;
     108             : 
     109           0 :         default:
     110           0 :             break;
     111             :     }
     112             : 
     113           0 :     return ngx_http_memc_cmd_unknown;
     114             : }
     115             : 
     116             : 
     117             : ngx_http_upstream_srv_conf_t *
     118           0 : ngx_http_memc_upstream_add(ngx_http_request_t *r, ngx_url_t *url)
     119             : {
     120             :     ngx_http_upstream_main_conf_t  *umcf;
     121             :     ngx_http_upstream_srv_conf_t  **uscfp;
     122             :     ngx_uint_t                      i;
     123             : 
     124           0 :     umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
     125             : 
     126           0 :     uscfp = umcf->upstreams.elts;
     127             : 
     128           0 :     for (i = 0; i < umcf->upstreams.nelts; i++) {
     129             : 
     130           0 :         if (uscfp[i]->host.len != url->host.len
     131           0 :             || ngx_strncasecmp(uscfp[i]->host.data, url->host.data,
     132             :                 url->host.len) != 0)
     133             :         {
     134             :             dd("upstream_add: host not match");
     135           0 :             continue;
     136             :         }
     137             : 
     138           0 :         if (uscfp[i]->port != url->port) {
     139             :             dd("upstream_add: port not match: %d != %d",
     140             :                     (int) uscfp[i]->port, (int) url->port);
     141           0 :             continue;
     142             :         }
     143             : 
     144             : #if (nginx_version < 1011006)
     145             :         if (uscfp[i]->default_port && url->default_port
     146             :             && uscfp[i]->default_port != url->default_port)
     147             :         {
     148             :             dd("upstream_add: default_port not match");
     149             :             continue;
     150             :         }
     151             : #endif
     152             : 
     153           0 :         return uscfp[i];
     154             :     }
     155             : 
     156             :     dd("No upstream found: %.*s", (int) url->host.len, url->host.data);
     157             : 
     158           0 :     return NULL;
     159             : }
     160             : 

Generated by: LCOV version 1.13