@ -944,9 +944,16 @@ static void send_stratifier_deadproxy(ckpool_t *ckp, const int id, const int sub 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						send_proc ( ckp - > stratifier ,  buf ) ;   
					 
					 
					 
						send_proc ( ckp - > stratifier ,  buf ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					/* Remove the subproxy from the proxi list and put it on the dead list */  
					 
					 
					 
					/* Remove the subproxy from the proxi list and put it on the dead list.
  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					 *  Further  use  of  the  subproxy  pointer  may  point  to  a  new  proxy  but  will  not   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					 *  dereference  */   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					static  void  disable_subproxy ( gdata_t  * gdata ,  proxy_instance_t  * proxi ,  proxy_instance_t  * subproxy )  
					 
					 
					 
					static  void  disable_subproxy ( gdata_t  * gdata ,  proxy_instance_t  * proxi ,  proxy_instance_t  * subproxy )  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					{  
					 
					 
					 
					{  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						subproxy - > alive  =  false ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						send_stratifier_deadproxy ( gdata - > ckp ,  subproxy - > id ,  subproxy - > subid ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						if  ( parent_proxy ( subproxy ) )   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							return ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						mutex_lock ( & proxi - > proxy_lock ) ;   
					 
					 
					 
						mutex_lock ( & proxi - > proxy_lock ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						subproxy - > disabled  =  true ;   
					 
					 
					 
						subproxy - > disabled  =  true ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						/* Make sure subproxy is still in the list */   
					 
					 
					 
						/* Make sure subproxy is still in the list */   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -957,12 +964,9 @@ static void disable_subproxy(gdata_t *gdata, proxy_instance_t *proxi, proxy_inst 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						}   
					 
					 
					 
						}   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						mutex_unlock ( & proxi - > proxy_lock ) ;   
					 
					 
					 
						mutex_unlock ( & proxi - > proxy_lock ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						if  ( subproxy )  {   
					 
					 
					 
						if  ( subproxy )   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
							send_stratifier_deadproxy ( gdata - > ckp ,  subproxy - > id ,  subproxy - > subid ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							if  ( ! parent_proxy ( subproxy ) )   
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
							store_proxy ( gdata ,  subproxy ) ;   
					 
					 
					 
							store_proxy ( gdata ,  subproxy ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					}  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					}  
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					/* If the parent is no longer in use due to reconnect, we shouldn't use any of
  
					 
					 
					 
					/* If the parent is no longer in use due to reconnect, we shouldn't use any of
  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 *  the  child  subproxies .  */   
					 
					 
					 
					 *  the  child  subproxies .  */   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -973,6 +977,7 @@ static void drop_subproxies(proxy_instance_t *proxi) 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						mutex_lock ( & proxi - > proxy_lock ) ;   
					 
					 
					 
						mutex_lock ( & proxi - > proxy_lock ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						HASH_ITER ( sh ,  proxi - > subproxies ,  subproxy ,  tmp )  {   
					 
					 
					 
						HASH_ITER ( sh ,  proxi - > subproxies ,  subproxy ,  tmp )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							if  ( ! parent_proxy ( subproxy ) )  {   
					 
					 
					 
							if  ( ! parent_proxy ( subproxy ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
								send_stratifier_deadproxy ( proxi - > ckp ,  proxi - > id ,  subproxy - > subid ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								subproxy - > disabled  =  true ;   
					 
					 
					 
								subproxy - > disabled  =  true ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								Close ( subproxy - > cs - > fd ) ;   
					 
					 
					 
								Close ( subproxy - > cs - > fd ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							}   
					 
					 
					 
							}   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -1540,12 +1545,8 @@ static void *proxy_send(void *arg) 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							json_decref ( msg - > json_msg ) ;   
					 
					 
					 
							json_decref ( msg - > json_msg ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							free ( msg ) ;   
					 
					 
					 
							free ( msg ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							if  ( ! ret  & &  subproxy )  {   
					 
					 
					 
							if  ( ! ret  & &  subproxy )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								if  ( cs - > fd  >  0 )  {   
					 
					 
					 
								LOGNOTICE ( " Proxy %d:%d %s failed to send msg in proxy_send, dropping to reconnect " ,   
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
									LOGWARNING ( " Proxy %d:%d %s failed to send msg in proxy_send, dropping to reconnect " ,   
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
									  proxy - > id ,  proxy - > subid ,  proxy - > si - > url ) ;   
					 
					 
					 
									  proxy - > id ,  proxy - > subid ,  proxy - > si - > url ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
									Close ( cs - > fd ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								}   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								if  ( ! parent_proxy ( subproxy )  & &  ! subproxy - > disabled )   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								disable_subproxy ( gdata ,  proxy ,  subproxy ) ;   
					 
					 
					 
								disable_subproxy ( gdata ,  proxy ,  subproxy ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							}   
					 
					 
					 
							}   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						}   
					 
					 
					 
						}   
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -1902,11 +1903,9 @@ static void *proxy_recv(void *arg) 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								ret  =  read_socket_line ( cs ,  5 ) ;   
					 
					 
					 
								ret  =  read_socket_line ( cs ,  5 ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							}   
					 
					 
					 
							}   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							if  ( ret  <  1 )  {   
					 
					 
					 
							if  ( ret  <  1 )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								subproxy - > alive  =  false ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								if  ( ! parent_proxy ( subproxy ) )   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
									recruit_subproxy ( proxi ) ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								LOGNOTICE ( " Proxy %d:%d %s failed to epoll/read_socket_line in proxy_recv, attempting reconnect " ,   
					 
					 
					 
								LOGNOTICE ( " Proxy %d:%d %s failed to epoll/read_socket_line in proxy_recv, attempting reconnect " ,   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
									  proxi - > id ,  subproxy - > subid ,  subproxy - > si - > url ) ;   
					 
					 
					 
									  proxi - > id ,  subproxy - > subid ,  subproxy - > si - > url ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
								disable_subproxy ( gdata ,  proxi ,  subproxy ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
								continue ;   
					 
					 
					 
								continue ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							}   
					 
					 
					 
							}   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							if  ( parse_method ( ckp ,  subproxy ,  cs - > buf ) )  {   
					 
					 
					 
							if  ( parse_method ( ckp ,  subproxy ,  cs - > buf ) )  {   
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -1914,7 +1913,6 @@ static void *proxy_recv(void *arg) 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
									/* Call this proxy dead to allow us to fail
   
					 
					 
					 
									/* Call this proxy dead to allow us to fail
   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
									 *  over  to  a  backup  pool  until  the  reconnect   
					 
					 
					 
									 *  over  to  a  backup  pool  until  the  reconnect   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
									 *  pool  is  up  */   
					 
					 
					 
									 *  pool  is  up  */   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
									subproxy - > alive  =  false ;   
					 
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
									disable_subproxy ( gdata ,  proxi ,  subproxy ) ;   
					 
					 
					 
									disable_subproxy ( gdata ,  proxi ,  subproxy ) ;   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
									if  ( parent_proxy ( subproxy ) )  {   
					 
					 
					 
									if  ( parent_proxy ( subproxy ) )  {   
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
										reconnect_generator ( ckp ) ;   
					 
					 
					 
										reconnect_generator ( ckp ) ;