upstream: add upstream list parameter to upstream_add()
to abstract it from the concrete list in the config struct. Michael
This commit is contained in:
		
							parent
							
								
									fd987e97f0
								
							
						
					
					
						commit
						22fba83df2
					
				@ -802,11 +802,11 @@ static HANDLE_FUNC (handle_upstream)
 | 
				
			|||||||
        if (match[9].rm_so != -1) {
 | 
					        if (match[9].rm_so != -1) {
 | 
				
			||||||
                domain = get_string_arg (line, &match[9]);
 | 
					                domain = get_string_arg (line, &match[9]);
 | 
				
			||||||
                if (domain) {
 | 
					                if (domain) {
 | 
				
			||||||
                        upstream_add (ip, port, domain);
 | 
					                        upstream_add (ip, port, domain, &conf->upstream_list);
 | 
				
			||||||
                        safefree (domain);
 | 
					                        safefree (domain);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
                upstream_add (ip, port, NULL);
 | 
					                upstream_add (ip, port, NULL, &conf->upstream_list);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        safefree (ip);
 | 
					        safefree (ip);
 | 
				
			||||||
@ -822,7 +822,7 @@ static HANDLE_FUNC (handle_upstream_no)
 | 
				
			|||||||
        if (!domain)
 | 
					        if (!domain)
 | 
				
			||||||
                return -1;
 | 
					                return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        upstream_add (NULL, 0, domain);
 | 
					        upstream_add (NULL, 0, domain, &conf->upstream_list);
 | 
				
			||||||
        safefree (domain);
 | 
					        safefree (domain);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
 | 
				
			|||||||
@ -119,7 +119,8 @@ fail:
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * Add an entry to the upstream list
 | 
					 * Add an entry to the upstream list
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void upstream_add (const char *host, int port, const char *domain)
 | 
					void upstream_add (const char *host, int port, const char *domain,
 | 
				
			||||||
 | 
					                   struct upstream **upstream_list)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
        struct upstream *up;
 | 
					        struct upstream *up;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -129,7 +130,7 @@ void upstream_add (const char *host, int port, const char *domain)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!up->domain && !up->ip) {   /* always add default to end */
 | 
					        if (!up->domain && !up->ip) {   /* always add default to end */
 | 
				
			||||||
                struct upstream *tmp = config.upstream_list;
 | 
					                struct upstream *tmp = *upstream_list;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                while (tmp) {
 | 
					                while (tmp) {
 | 
				
			||||||
                        if (!tmp->domain && !tmp->ip) {
 | 
					                        if (!tmp->domain && !tmp->ip) {
 | 
				
			||||||
@ -148,8 +149,8 @@ void upstream_add (const char *host, int port, const char *domain)
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        up->next = config.upstream_list;
 | 
					        up->next = *upstream_list;
 | 
				
			||||||
        config.upstream_list = up;
 | 
					        *upstream_list = up;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -40,7 +40,8 @@ struct upstream {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef UPSTREAM_SUPPORT
 | 
					#ifdef UPSTREAM_SUPPORT
 | 
				
			||||||
extern void upstream_add (const char *host, int port, const char *domain);
 | 
					extern void upstream_add (const char *host, int port, const char *domain,
 | 
				
			||||||
 | 
					                          struct upstream **upstream_list);
 | 
				
			||||||
struct upstream *upstream_get (char *host);
 | 
					struct upstream *upstream_get (char *host);
 | 
				
			||||||
#endif /* UPSTREAM_SUPPORT */
 | 
					#endif /* UPSTREAM_SUPPORT */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user