diff options
author | Ard Biesheuvel <abies@php.net> | 2004-06-01 00:44:20 +0000 |
---|---|---|
committer | Ard Biesheuvel <abies@php.net> | 2004-06-01 00:44:20 +0000 |
commit | 5a8a9a59e21121e0973807eff8cadc4333e49e2d (patch) | |
tree | 07a3678b3eda46ca57d85ec63431810227269da4 | |
parent | 95910aa26c99b22d3884c4b60a04a302dd7099fe (diff) | |
download | php-git-5a8a9a59e21121e0973807eff8cadc4333e49e2d.tar.gz |
Fixed bug #28569 (connection id is not thread safe)
-rw-r--r-- | ext/informix/ifx.ec | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/ext/informix/ifx.ec b/ext/informix/ifx.ec index 7fa3e21f01..86beda6582 100644 --- a/ext/informix/ifx.ec +++ b/ext/informix/ifx.ec @@ -54,6 +54,12 @@ #include <winsock.h> #endif +#ifdef ZTS +#define IFX_THRD_ID tsrm_thread_id() +#else +#define IFX_THRD_ID 0 +#endif + #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif @@ -123,16 +129,16 @@ EXEC SQL include sqlstype; typedef char IFX[128]; #define SAFE_STRING(s) ((s) ? (s) : "") -#define PHP_IFX_CHECK_CONNECTION(ifx) \ - { \ - if (ifx_check() < 0) { \ - char *ifx_err = ifx_error(ifx); \ - IFXG(sv_sqlcode) = SQLCODE; \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Set connection %s fails (%s)", ifx, ifx_err); \ - efree(ifx_err); \ - RETURN_FALSE; \ - } \ - } +#define PHP_IFX_CHECK_CONNECTION(ifx) \ + do { \ + if (ifx_check() < 0) { \ + char *ifx_err = ifx_error(ifx); \ + IFXG(sv_sqlcode) = SQLCODE; \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Set connection %s fails (%s)", ifx, ifx_err); \ + efree(ifx_err); \ + RETURN_FALSE; \ + } \ + } while (0) function_entry ifx_functions[] = { PHP_FE(ifx_connect, NULL) @@ -541,7 +547,7 @@ EXEC SQL END DECLARE SECTION; /* create the link */ ifx = (char *) malloc(sizeof(IFX)); IFXG(connectionid)++; - sprintf(ifx, "%s%x", SAFE_STRING(user), IFXG(connectionid)); + sprintf(ifx, "%s%x_%x", SAFE_STRING(user), IFX_THRD_ID,IFXG(connectionid)); EXEC SQL CONNECT TO :host AS :ifx USER :user USING :passwd WITH CONCURRENT TRANSACTION; @@ -644,7 +650,7 @@ EXEC SQL END DECLARE SECTION; ifx = (char *) emalloc(sizeof(IFX)); IFXG(connectionid)++; - sprintf(ifx, "connec%x", IFXG(connectionid)); + sprintf(ifx, "connec%x_%x", IFX_THRD_ID, IFXG(connectionid)); EXEC SQL CONNECT TO :host AS :ifx USER :user USING :passwd WITH CONCURRENT TRANSACTION; @@ -1241,10 +1247,10 @@ EXEC SQL END DECLARE SECTION; statement = Z_STRVAL_PP(query); IFXG(cursorid)++; - sprintf(statemid, "statem%x", IFXG(cursorid)); - sprintf(cursorid, "cursor%x", IFXG(cursorid)); - sprintf(descrpid, "descrp%x", IFXG(cursorid)); - sprintf(i_descrpid, "i_descrp%x", IFXG(cursorid)); + sprintf(statemid, "statem%x_%x", IFX_THRD_ID, IFXG(cursorid)); + sprintf(cursorid, "cursor%x_%x", IFX_THRD_ID, IFXG(cursorid)); + sprintf(descrpid, "descrp%x_%x", IFX_THRD_ID, IFXG(cursorid)); + sprintf(i_descrpid, "i_descrp%x_%x", IFX_THRD_ID,IFXG(cursorid)); EXEC SQL set connection :ifx; PHP_IFX_CHECK_CONNECTION(ifx); |