fix goroutine leak while calling db.Ping() error
This commit is contained in:
		
							parent
							
								
									041cd3dd31
								
							
						
					
					
						commit
						7dcd80ddf9
					
				
							
								
								
									
										3
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								main.go
									
									
									
									
									
								
							@ -75,6 +75,9 @@ func Open(dialect string, args ...interface{}) (*DB, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		if err == nil {
 | 
							if err == nil {
 | 
				
			||||||
			err = db.DB().Ping() // Send a ping to make sure the database connection is alive.
 | 
								err = db.DB().Ping() // Send a ping to make sure the database connection is alive.
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									db.DB().Close()
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user