CVS update: php3/functions

From: Date: Mon, 09 Nov 1998 18:30:42 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-2297@lists.php.net to get a copy of this message
Date: Monday November 9, 1998 @ 13:30 Author: tommay Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv6840 Modified Files: php3_sybase-ct.h sybase-ct.c Log Message: Ct-lib wasn't always marking connections dead on database server restart/reboot. So I added a sybct_ptr->dead flag which we set when functions return CS_FAIL and related statuses. Index: php3/functions/php3_sybase-ct.h diff -c php3/functions/php3_sybase-ct.h:1.17 php3/functions/php3_sybase-ct.h:1.18 *** php3/functions/php3_sybase-ct.h:1.17 Fri Nov 6 12:04:35 1998 --- php3/functions/php3_sybase-ct.h Mon Nov 9 13:30:37 1998 *************** *** 28,34 **** */ ! /* $Id: php3_sybase-ct.h,v 1.17 1998/11/06 17:04:35 tommay Exp $ */ #ifndef _PHP3_SYBASE_CT_H #define _PHP3_SYBASE_CT_H --- 28,34 ---- */ ! /* $Id: php3_sybase-ct.h,v 1.18 1998/11/09 18:30:37 tommay Exp $ */ #ifndef _PHP3_SYBASE_CT_H #define _PHP3_SYBASE_CT_H *************** *** 90,95 **** --- 90,96 ---- CS_COMMAND *cmd; int valid; int deadlock; + int dead; long affected_rows; } sybct_link; Index: php3/functions/sybase-ct.c diff -c php3/functions/sybase-ct.c:1.55 php3/functions/sybase-ct.c:1.56 *** php3/functions/sybase-ct.c:1.55 Fri Nov 6 12:04:32 1998 --- php3/functions/sybase-ct.c Mon Nov 9 13:30:40 1998 *************** *** 28,34 **** +----------------------------------------------------------------------+ */ ! /* $Id: sybase-ct.c,v 1.55 1998/11/06 17:04:32 tommay Exp $ */ #ifndef MSVC5 --- 28,34 ---- +----------------------------------------------------------------------+ */ ! /* $Id: sybase-ct.c,v 1.56 1998/11/09 18:30:40 tommay Exp $ */ #ifndef MSVC5 *************** *** 156,167 **** con_status = CS_CONSTAT_CONNECTED | CS_CONSTAT_DEAD; } if (con_status & CS_CONSTAT_CONNECTED) { ! if (con_status & CS_CONSTAT_DEAD) { ct_close(sybct_ptr->connection, CS_FORCE_CLOSE); } - else { - ct_close(sybct_ptr->connection, CS_UNUSED); - } } ct_con_drop(sybct_ptr->connection); --- 156,164 ---- con_status = CS_CONSTAT_CONNECTED | CS_CONSTAT_DEAD; } if (con_status & CS_CONSTAT_CONNECTED) { ! if ((con_status & CS_CONSTAT_DEAD) || ct_close(sybct_ptr->connection, CS_UNUSED)!=CS_SUCCEED) { ct_close(sybct_ptr->connection, CS_FORCE_CLOSE); } } ct_con_drop(sybct_ptr->connection); *************** *** 184,195 **** con_status = CS_CONSTAT_CONNECTED | CS_CONSTAT_DEAD; } if (con_status & CS_CONSTAT_CONNECTED) { ! if (con_status & CS_CONSTAT_DEAD) { ct_close(sybct_ptr->connection, CS_FORCE_CLOSE); } - else { - ct_close(sybct_ptr->connection, CS_UNUSED); - } } ct_con_drop(sybct_ptr->connection); --- 181,189 ---- con_status = CS_CONSTAT_CONNECTED | CS_CONSTAT_DEAD; } if (con_status & CS_CONSTAT_CONNECTED) { ! if ((con_status & CS_CONSTAT_DEAD) || ct_close(sybct_ptr->connection, CS_UNUSED)!=CS_SUCCEED) { ct_close(sybct_ptr->connection, CS_FORCE_CLOSE); } } ct_con_drop(sybct_ptr->connection); *************** *** 338,343 **** --- 332,338 ---- } ct_con_props(sybct->connection, CS_SET, CS_APPNAME, php3_sybct_module.appname, CS_NULLTERM, NULL); sybct->valid = 1; + sybct->dead = 0; /* create the link */ if (ct_connect(sybct->connection, host, CS_NULLTERM)!=CS_SUCCEED) { *************** *** 485,491 **** efree(hashed_details); RETURN_FALSE; } ! if (!(con_status & CS_CONSTAT_CONNECTED) || (con_status & CS_CONSTAT_DEAD)) { sybct_link sybct; if (con_status & CS_CONSTAT_CONNECTED) { --- 480,486 ---- efree(hashed_details); RETURN_FALSE; } ! if (!(con_status & CS_CONSTAT_CONNECTED) || (con_status & CS_CONSTAT_DEAD) || sybct_ptr->dead) { sybct_link sybct; if (con_status & CS_CONSTAT_CONNECTED) { *************** *** 636,650 **** --- 631,653 ---- CS_INT restype; int failure=0; + /* Fail if we already marked this connection dead. */ + + if (sybct_ptr->dead) { + return FAILURE; + } + /* ** Get a command handle, store the command string in it, and ** send it to the server. */ if (ct_command(sybct_ptr->cmd, CS_LANG_CMD, cmdbuf, CS_NULLTERM, CS_UNUSED)!=CS_SUCCEED) { + sybct_ptr->dead = 1; return FAILURE; } if (ct_send(sybct_ptr->cmd)!=CS_SUCCEED) { + sybct_ptr->dead = 1; return FAILURE; } *************** *** 685,690 **** --- 688,697 ---- * doc for ct_results()==CS_FAIL. */ ct_cancel(NULL, sybct_ptr->cmd, CS_CANCEL_ALL); + /* Don't take chances with the vagaries of ct-lib. Mark it + * dead ourselves. + */ + sybct_ptr->dead = 1; return FAILURE; default: *************** *** 945,950 **** --- 952,963 ---- convert_to_string(query); + /* Fail if we already marked this connection dead. */ + + if (sybct_ptr->dead) { + RETURN_FALSE; + } + /* Repeat until we don't deadlock. */ for (;;) { *************** *** 956,966 **** --- 969,987 ---- * loop, but not on Linux 11.0. */ if (ct_command(sybct_ptr->cmd, CS_LANG_CMD, query->value.str.val, CS_NULLTERM, CS_UNUSED)!=CS_SUCCEED) { + /* If this didn't work, the connection is screwed but + * ct-lib might not set CS_CONSTAT_DEAD. So set our own + * flag. This happens sometimes when the database is restarted + * and/or its machine is rebooted, and ct_command() returns + * CS_BUSY for some reason. + */ + sybct_ptr->dead = 1; RETURN_FALSE; } if (ct_send(sybct_ptr->cmd)!=CS_SUCCEED) { ct_cancel(NULL, sybct_ptr->cmd, CS_CANCEL_ALL); + sybct_ptr->dead = 1; RETURN_FALSE; } *************** *** 972,977 **** --- 993,999 ---- */ if (ct_results(sybct_ptr->cmd, &restype)!=CS_SUCCEED) { ct_cancel(NULL, sybct_ptr->cmd, CS_CANCEL_ALL); + sybct_ptr->dead = 1; RETURN_FALSE; } *************** *** 1002,1007 **** --- 1024,1030 ---- result = _php3_sybct_fetch_result_set(sybct_ptr); if (result == NULL) { ct_cancel(NULL, sybct_ptr->cmd, CS_CANCEL_ALL); + sybct_ptr->dead = 1; RETURN_FALSE; } status = Q_RESULT; *************** *** 1056,1073 **** * doc for ct_results()==CS_FAIL. */ ct_cancel(NULL, sybct_ptr->cmd, CS_CANCEL_ALL); case CS_CANCELED: default: status = Q_FAILURE; break; } ! /* If or completed without deadlock, break out of the loop. * Sometimes deadlock results in failures and sometimes not, * it seems to depend on the server flavor. But we want to * retry all deadlocks. */ ! if (sybct_ptr->deadlock == 0) { break; } --- 1079,1100 ---- * doc for ct_results()==CS_FAIL. */ ct_cancel(NULL, sybct_ptr->cmd, CS_CANCEL_ALL); + /* Don't take chances with the vagaries of ct-lib. Mark it + * dead ourselves. + */ + sybct_ptr->dead = 1; case CS_CANCELED: default: status = Q_FAILURE; break; } ! /* If query completed without deadlock, break out of the loop. * Sometimes deadlock results in failures and sometimes not, * it seems to depend on the server flavor. But we want to * retry all deadlocks. */ ! if (sybct_ptr->dead || sybct_ptr->deadlock == 0) { break; } *************** *** 1075,1081 **** * e.g., our result set may be a stored procedure status which * is returned even if the stored procedure deadlocks. As an * optimization, we could try not to fetch results in known ! * deadlock condittions, but deadlock is (should be) rare. */ if (result != NULL) { _free_sybct_result(result); --- 1102,1108 ---- * e.g., our result set may be a stored procedure status which * is returned even if the stored procedure deadlocks. As an * optimization, we could try not to fetch results in known ! * deadlock conditions, but deadlock is (should be) rare. */ if (result != NULL) { _free_sybct_result(result); -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#2297) next »