From:             [EMAIL PROTECTED]
Operating system: W2K Server
PHP version:      4.2.0
PHP Bug Type:     ODBC related
Bug description:  Unexpected blocking

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;
}

-- 
Edit bug report at http://bugs.php.net/?id=17024&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=17024&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=17024&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=17024&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=17024&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17024&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=17024&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=17024&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=17024&r=submittedtwice
register_globals:    http://bugs.php.net/fix.php?id=17024&r=globals

Reply via email to