- Timestamp:
- 01/17/09 18:28:53 (3 years ago)
- Branches:
- master-v0.7, master-v0.6, memcached_hash, upstream_count_limit
- Children:
- 12bc79
- Parents:
- 9ceabd
- git-author:
- Tomash Brechko <tomash.brechko@…> (01/17/09 15:49:50)
- git-committer:
- Tomash Brechko <tomash.brechko@…> (01/17/09 18:28:53)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
memcached_hash/ngx_http_upstream_memcached_hash_module.c
r9ceabd r38354f 1 1 /* 2 Copyright (C) 2007-200 8Tomash Brechko. All rights reserved.2 Copyright (C) 2007-2009 Tomash Brechko. All rights reserved. 3 3 4 4 Development of this module was sponsored by Monashev Co. Ltd. … … 55 55 ngx_http_upstream_server_t *server; 56 56 ngx_http_request_t *request; 57 struct memcached_hash_peer *peer; 57 58 }; 58 59 … … 97 98 98 99 static 100 unsigned int 101 memcached_hash_find_peer(struct memcached_hash_find_ctx *find_ctx); 102 103 104 static 99 105 ngx_int_t 100 106 memcached_hash_get_peer(ngx_peer_connection_t *pc, void *data) 101 107 { 102 struct memcached_hash_peer *peer = data; 108 struct memcached_hash_find_ctx *find_ctx = data; 109 struct memcached_hash_peer *peer = find_ctx->peer; 103 110 ngx_peer_addr_t *addr; 111 112 if (! peer) 113 { 114 unsigned int index; 115 116 index = memcached_hash_find_peer(find_ctx); 117 118 peer = find_ctx->peer; 119 pc->tries = find_ctx->server[index].naddrs; 120 } 104 121 105 122 if (peer->server->down) … … 132 149 133 150 static 134 ngx_int_t 135 memcached_hash_find_peer(ngx_peer_connection_t *pc, void *data) 136 { 137 struct memcached_hash_find_ctx *find_ctx = data; 151 unsigned int 152 memcached_hash_find_peer(struct memcached_hash_find_ctx *find_ctx) 153 { 138 154 struct memcached_hash *memd = find_ctx->memd; 139 155 u_char *key; … … 185 201 } 186 202 187 pc->data = &memd->peers[index]; 188 pc->get = memcached_hash_get_peer; 189 pc->tries = find_ctx->server[index].naddrs; 190 191 return memcached_hash_get_peer(pc, pc->data); 203 find_ctx->peer = &memd->peers[index]; 204 205 return index; 192 206 } 193 207 … … 198 212 ngx_uint_t state) 199 213 { 200 struct memcached_hash_peer *peer = data; 214 struct memcached_hash_find_ctx *find_ctx = data; 215 struct memcached_hash_peer *peer = find_ctx->peer; 201 216 202 217 if (state & NGX_PEER_FAILED) … … 243 258 find_ctx->request = r; 244 259 find_ctx->server = us->servers->elts; 260 find_ctx->peer = NULL; 245 261 246 262 r->upstream->peer.free = memcached_hash_free_peer; … … 250 266 memcached_hash_find_peer(). 251 267 */ 252 r->upstream->peer.get = memcached_hash_ find_peer;268 r->upstream->peer.get = memcached_hash_get_peer; 253 269 r->upstream->peer.data = find_ctx; 254 270 r->upstream->peer.tries = 1;
Note: See TracChangeset
for help on using the changeset viewer.
