Skip to content

Commit 21052af

Browse files
committed
pdo_dblib: Do not reuse dead connections
In case of persistent connection it was not checked if the connection was still alive always assuming it was. If the connection was broken this caused PHP to reuse the broken connection over and over. dbdead function is supported by all dblib implementation (MS, Sybase, FreeTDS). Change tested manually, see FreeTDS/freetds#711 (comment) Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
1 parent 1462499 commit 21052af

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

ext/pdo_dblib/dblib_driver.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,17 @@ static int dblib_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_valu
420420
return 1;
421421
}
422422

423+
static zend_result dblib_handle_check_liveness(pdo_dbh_t *dbh)
424+
{
425+
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
426+
427+
if (dbdead(H->link)) {
428+
return FAILURE;
429+
}
430+
431+
return SUCCESS;
432+
}
433+
423434
static const struct pdo_dbh_methods dblib_methods = {
424435
dblib_handle_closer,
425436
dblib_handle_preparer,
@@ -432,7 +443,7 @@ static const struct pdo_dbh_methods dblib_methods = {
432443
dblib_handle_last_id, /* last insert id */
433444
dblib_fetch_error, /* fetch error */
434445
dblib_get_attribute, /* get attr */
435-
NULL, /* check liveness */
446+
dblib_handle_check_liveness, /* check_liveness */
436447
NULL, /* get driver methods */
437448
NULL, /* request shutdown */
438449
NULL, /* in transaction, use PDO's internal tracking mechanism */

0 commit comments

Comments
 (0)