| 91 | } |
| 92 | |
| 93 | static apr_status_t socache_rd_init(ap_socache_instance_t *ctx, |
| 94 | const char *namespace, |
| 95 | const struct ap_socache_hints *hints, |
| 96 | server_rec *s, apr_pool_t *p) |
| 97 | { |
| 98 | apr_status_t rv; |
| 99 | int thread_limit = 0; |
| 100 | apr_uint16_t nservers = 0; |
| 101 | char *cache_config; |
| 102 | char *split; |
| 103 | char *tok; |
| 104 | |
| 105 | socache_rd_svr_cfg *sconf = ap_get_module_config(s->module_config, |
| 106 | &socache_redis_module); |
| 107 | |
| 108 | ap_mpm_query(AP_MPMQ_HARD_LIMIT_THREADS, &thread_limit); |
| 109 | |
| 110 | /* Find all the servers in the first run to get a total count */ |
| 111 | cache_config = apr_pstrdup(p, ctx->servers); |
| 112 | split = apr_strtok(cache_config, ",", &tok); |
| 113 | while (split) { |
| 114 | nservers++; |
| 115 | split = apr_strtok(NULL,",", &tok); |
| 116 | } |
| 117 | |
| 118 | rv = apr_redis_create(p, nservers, 0, &ctx->rc); |
| 119 | if (rv != APR_SUCCESS) { |
| 120 | ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, APLOGNO(03473) |
| 121 | "Failed to create Redis Object of '%d' size.", |
| 122 | nservers); |
| 123 | return rv; |
| 124 | } |
| 125 | |
| 126 | /* Now add each server to the redis */ |
| 127 | cache_config = apr_pstrdup(p, ctx->servers); |
| 128 | split = apr_strtok(cache_config, ",", &tok); |
| 129 | while (split) { |
| 130 | apr_redis_server_t *st; |
| 131 | char *host_str; |
| 132 | char *scope_id; |
| 133 | apr_port_t port; |
| 134 | |
| 135 | rv = apr_parse_addr_port(&host_str, &scope_id, &port, split, p); |
| 136 | if (rv != APR_SUCCESS) { |
| 137 | ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, APLOGNO(03474) |
| 138 | "Failed to Parse redis Server: '%s'", split); |
| 139 | return rv; |
| 140 | } |
| 141 | |
| 142 | if (host_str == NULL) { |
| 143 | ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s, APLOGNO(03475) |
| 144 | "Failed to Parse Server, " |
| 145 | "no hostname specified: '%s'", split); |
| 146 | return APR_EINVAL; |
| 147 | } |
| 148 | |
| 149 | if (port == 0) { |
| 150 | port = RD_DEFAULT_SERVER_PORT; |
nothing calls this directly
no test coverage detected