mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 01:37:31 +03:00 
			
		
		
		
	Close the connection if discovered bad on poll()
Conflicts: NEWS
This commit is contained in:
		
							parent
							
								
									cdb206d3e7
								
							
						
					
					
						commit
						71eeb9086a
					
				
							
								
								
									
										1
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								NEWS
									
									
									
									
									
								
							| 
						 | 
					@ -26,6 +26,7 @@ What's new in psycopg 2.4.7
 | 
				
			||||||
    happens for TCP connections instead (:ticket:`#196`).
 | 
					    happens for TCP connections instead (:ticket:`#196`).
 | 
				
			||||||
  - Fixed overflow opening a lobject with an oid not fitting in a signed int
 | 
					  - Fixed overflow opening a lobject with an oid not fitting in a signed int
 | 
				
			||||||
    (:ticket:`#203`).
 | 
					    (:ticket:`#203`).
 | 
				
			||||||
 | 
					  - Mark the connection closed if found broken on `poll()`.
 | 
				
			||||||
  - Fixed possible segfault in named cursors creation.
 | 
					  - Fixed possible segfault in named cursors creation.
 | 
				
			||||||
  - Fixed debug build on Windows, thanks to James Emerton.
 | 
					  - Fixed debug build on Windows, thanks to James Emerton.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -774,6 +774,12 @@ pq_is_busy(connectionObject *conn)
 | 
				
			||||||
        Dprintf("pq_is_busy: PQconsumeInput() failed");
 | 
					        Dprintf("pq_is_busy: PQconsumeInput() failed");
 | 
				
			||||||
        pthread_mutex_unlock(&(conn->lock));
 | 
					        pthread_mutex_unlock(&(conn->lock));
 | 
				
			||||||
        Py_BLOCK_THREADS;
 | 
					        Py_BLOCK_THREADS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* if the libpq says pgconn is lost, close the py conn */
 | 
				
			||||||
 | 
					        if (CONNECTION_BAD == PQstatus(conn->pgconn)) {
 | 
				
			||||||
 | 
					            conn->closed = 2;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn));
 | 
					        PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn));
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -803,6 +809,12 @@ pq_is_busy_locked(connectionObject *conn)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (PQconsumeInput(conn->pgconn) == 0) {
 | 
					    if (PQconsumeInput(conn->pgconn) == 0) {
 | 
				
			||||||
        Dprintf("pq_is_busy_locked: PQconsumeInput() failed");
 | 
					        Dprintf("pq_is_busy_locked: PQconsumeInput() failed");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* if the libpq says pgconn is lost, close the py conn */
 | 
				
			||||||
 | 
					        if (CONNECTION_BAD == PQstatus(conn->pgconn)) {
 | 
				
			||||||
 | 
					            conn->closed = 2;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn));
 | 
					        PyErr_SetString(OperationalError, PQerrorMessage(conn->pgconn));
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user