Skip to content

Commit 29751e7

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 0f3e741 commit 29751e7

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

ext/pdo_dblib/dblib_driver.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,16 @@ static int dblib_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_valu
422422
return 1;
423423
}
424424

425+
static zend_result dblib_handle_check_liveness(pdo_dbh_t *dbh)
426+
{
427+
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
428+
429+
if (dbdead(H->link))
430+
return FAILURE;
431+
432+
return SUCCESS;
433+
}
434+
425435
static const struct pdo_dbh_methods dblib_methods = {
426436
dblib_handle_closer,
427437
dblib_handle_preparer,
@@ -434,7 +444,7 @@ static const struct pdo_dbh_methods dblib_methods = {
434444
dblib_handle_last_id, /* last insert id */
435445
dblib_fetch_error, /* fetch error */
436446
dblib_get_attribute, /* get attr */
437-
NULL, /* check liveness */
447+
dblib_handle_check_liveness, /* check_liveness */
438448
NULL, /* get driver methods */
439449
NULL, /* request shutdown */
440450
NULL, /* in transaction, use PDO's internal tracking mechanism */

0 commit comments

Comments
 (0)