php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17024 Unexpected blocking
Submitted: 2002-05-05 22:41 UTC Modified: 2002-05-06 11:20 UTC
From: ed_fair at yahoo dot com Assigned:
Status: Not a bug Package: ODBC related
PHP Version: 4.2.0 OS: W2K Server
Private report: No CVE-ID: None
 [2002-05-05 22:41 UTC] ed_fair at yahoo dot com
I am seeing some unexpected blocking of PHP/ODBC scripts.  I'm running the two scripts in two separate browser windows.  If the first PHP script is running, and the second PHP script is started, the second script won't run until the first one completes.  I've isolated this down to either apache or php blocking.  I'm unable to trace any further, but willing to assist, and grant access to my server.

My platform is W2K Server w/SP2, SQL Server 2000 8.00.194, Apache, and php 4.2.0 (binary distribution).  I'm embarassed to say I don't know how to determine the exact version of apache I've installed, but it is 1.3.x.

I have two scipts and one C++ program that illustrate the issue; you'll need VC++ to compile this (or I can send the EXE file to you).

---------------helloA.php-----------------
<?
session_start();
system("phpbug.exe");
?>
------------------------------------------

---------------helloB.php-----------------
<?
session_start();
$db = odbc_connect("ehp","ehp","ehp");
$query = "select 'Hello, beautiful world'";
$result = odbc_exec($db,$query);
odbc_result_all($result);
?>
------------------------------------------

---------------phpbug.cpp-----------------
#include <winsock2.h>
#include <windows.h>
#include <list>
#include <string>
#include <utility>


#include <sqltypes.h>
#include <sql.h>
#include <sqlext.h>
#include "tapeUtilNonOverlapped.h"

#define createSqlStmtHandle(connectionHandle, newStmtHandle) { \
	SQLRETURN rc; \
	if ((rc = SQLAllocHandle(SQL_HANDLE_STMT, connectionHandle, &newStmtHandle))!=SQL_SUCCESS) { \
		char mySQLState[10]; \
		long myNativeError; \
		char myMsgText[300]; \
		short lengthOfMyMsgText; \
		SQLGetDiagRec(SQL_HANDLE_STMT, newStmtHandle, 1, (unsigned char *) mySQLState, &myNativeError, (unsigned char *) myMsgText, 300, &lengthOfMyMsgText); \
		exit(5011); \
	} \
}

void ehpSqlPrepare(SQLHSTMT handle, std::string sqlCmd) {
	SQLRETURN rc = SQLPrepare(handle, (unsigned char *) sqlCmd.c_str(),SQL_NTS);
	if (rc!=SQL_SUCCESS) {
		char mySQLState[10];
		long myNativeError; 
		char myMsgText[300];
		short lengthOfMyMsgText;
		rc = SQLGetDiagRec(	SQL_HANDLE_STMT, handle, 1, (unsigned char *) mySQLState, &myNativeError, (unsigned char *) myMsgText, 300, &lengthOfMyMsgText);
		std::string err = "ehpSqlPrepare: couldn't prepare handle: ";
		err.append(myMsgText, lengthOfMyMsgText);
		exit(5010);
	}
} 


main(int argc,char * argv[]) {

	SQLHENV myEnvHandle;	// odbc environment handle
	SQLHDBC myDbcHandle;	// obdc connection handle
	SQLHSTMT myStmtHandle;
	int rc;					// return code for various system calls

	std::string myDSN = "ehp";			// DSN to connect using
	std::string myUserName = "ehp";		// login to use when connecting
	std::string myPassWord = "ehp";		// password to use when connecting

	std::string myQuery = "select 'Hello, World'";

	// set up an ODBC environment handle, request ODBC V3, set up an ODBC connector handle
	if ((rc=SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &myEnvHandle))!=SQL_SUCCESS) {
		exit(5001);
	}
	if ((rc=SQLSetEnvAttr(myEnvHandle, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3,0))!=SQL_SUCCESS) {
		exit(5002);
	}
	if ((rc=SQLAllocHandle(SQL_HANDLE_DBC, myEnvHandle, &myDbcHandle))!=SQL_SUCCESS) {
		exit(5003);
	}

	// connect the ODBC connector handle to DSN
	rc = SQLConnect(myDbcHandle, (SQLCHAR *) myDSN.c_str(), (SQLSMALLINT) myDSN.size()+1, (SQLCHAR *) myUserName.c_str(), (SQLSMALLINT)	myUserName.size()+1, (SQLCHAR *) myPassWord.c_str(), (SQLSMALLINT) myPassWord.size()+1);
	if ((rc!=SQL_SUCCESS)&&(rc!=SQL_SUCCESS_WITH_INFO)) {
		exit(5020);
	}

	int SCV=SQL_CONCUR_VALUES;
	// set the connection attributes for server-side cursors
	if ((SQLSetConnectAttr(myDbcHandle,SQL_ATTR_CONCURRENCY,(void *) SQL_CONCUR_VALUES,0))!=SQL_SUCCESS) {
		exit(5021);
	}
	
	// create a statment handle
	if ((SQLAllocHandle(SQL_HANDLE_STMT, myDbcHandle, &myStmtHandle))!=SQL_SUCCESS) {
		exit(5011);
	}

	// prepare a statement
	if((SQLPrepare(myStmtHandle, (unsigned char *) myQuery.c_str(),SQL_NTS))!=SQL_SUCCESS) {
		exit(5044);
	}

	// note that no query actually gets executed
	// this is where the long-running activities occur, I'll just sleep to simulate it though
	Sleep(30000);
	return 0;
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-06 08:29 UTC] ed_fair at yahoo dot com
My bad for not cleaning my code up entirely before posting it; here is the same program with all unnecessary items removed.  Ed.

#include <winsock2.h>
#include <windows.h>
#include <list>
#include <string>
#include <utility>


#include <sqltypes.h>
#include <sql.h>
#include <sqlext.h>

main(int argc,char * argv[]) {

	SQLHENV myEnvHandle;	// odbc environment handle
	SQLHDBC myDbcHandle;	// obdc connection handle
	SQLHSTMT myStmtHandle;
	int rc;					// return code for various system calls

	std::string myDSN = "ehp";			// DSN to connect using
	std::string myUserName = "ehp";		// login to use when connecting
	std::string myPassWord = "ehp";		// password to use when connecting

	std::string myQuery = "select 'Hello, World'";

	// set up an ODBC environment handle, request ODBC V3, set up an ODBC connector handle
	if ((rc=SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &myEnvHandle))!=SQL_SUCCESS) {
		exit(5001);
	}
	if ((rc=SQLSetEnvAttr(myEnvHandle, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3,0))!=SQL_SUCCESS) {
		exit(5002);
	}
	if ((rc=SQLAllocHandle(SQL_HANDLE_DBC, myEnvHandle, &myDbcHandle))!=SQL_SUCCESS) {
		exit(5003);
	}

	// connect the ODBC connector handle to DSN
	rc = SQLConnect(myDbcHandle, (SQLCHAR *) myDSN.c_str(), (SQLSMALLINT) myDSN.size()+1, (SQLCHAR *) myUserName.c_str(), (SQLSMALLINT)	myUserName.size()+1, (SQLCHAR *) myPassWord.c_str(), (SQLSMALLINT) myPassWord.size()+1);
	if ((rc!=SQL_SUCCESS)&&(rc!=SQL_SUCCESS_WITH_INFO)) {
		exit(5020);
	}

	int SCV=SQL_CONCUR_VALUES;
	// set the connection attributes for server-side cursors
	if ((SQLSetConnectAttr(myDbcHandle,SQL_ATTR_CONCURRENCY,(void *) SQL_CONCUR_VALUES,0))!=SQL_SUCCESS) {
		exit(5021);
	}
	
	// create a statment handle
	if ((SQLAllocHandle(SQL_HANDLE_STMT, myDbcHandle, &myStmtHandle))!=SQL_SUCCESS) {
		exit(5011);
	}

	// prepare a statement
	if((SQLPrepare(myStmtHandle, (unsigned char *) myQuery.c_str(),SQL_NTS))!=SQL_SUCCESS) {
		exit(5044);
	}

	// note that no query actually gets executed
	// this is where the long-running activities occur, I'll just sleep to simulate it though
	Sleep(30000);
	return 0;
}
 [2002-05-06 11:20 UTC] ed_fair at yahoo dot com
Further investigation revealed this to be related to sessions, not odbc.  Sorry!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC