Skip to content

Commit 49cd21e

Browse files
committed
OCI8 2.0: add oci8-check-connection probe and do some renaming
1 parent 72f80b2 commit 49cd21e

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

ext/oci8/config.m4

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ if test "$PHP_OCI8" != "no"; then
154154
AC_MSG_ERROR([You need at least PHP 5.4 to be able to use DTrace with PHP OCI8])
155155
else
156156
AC_CHECK_HEADERS([sys/sdt.h], [
157-
PHP_INIT_DTRACE([ext/oci8/oci8_dtrace.d],[ext/oci8/oci8_dtrace_gen.h],[ext/oci8/oci8.c \
158-
ext/oci8/oci8_interface.c ext/oci8/oci8_collection.c ext/oci8/oci8_lob.c ext/oci8/oci8_statement.c])
157+
PHP_INIT_DTRACE([ext/oci8/oci8_dtrace.d],[ext/oci8/oci8_dtrace_gen.h],[ext/oci8/oci8.c ext/oci8/oci8_statement.c])
159158
], [
160159
AC_MSG_ERROR(
161160
[Cannot find sys/sdt.h which is required for DTrace support])

ext/oci8/oci8.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,8 +1772,8 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus
17721772
}
17731773

17741774
#ifdef HAVE_DTRACE
1775-
if (DTRACE_OCI8_CONNECT_START_ENABLED()) {
1776-
DTRACE_OCI8_CONNECT_START(username, dbname, charset, session_mode, persistent, exclusive);
1775+
if (DTRACE_OCI8_CONNECT_ENTRY_ENABLED()) {
1776+
DTRACE_OCI8_CONNECT_ENTRY(username, dbname, charset, session_mode, persistent, exclusive);
17771777
}
17781778
#endif /* HAVE_DTRACE */
17791779

@@ -1784,8 +1784,8 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus
17841784
connection = php_oci_do_connect_ex(username, username_len, password, password_len, NULL, 0, dbname, dbname_len, charset, session_mode, persistent, exclusive TSRMLS_CC);
17851785

17861786
#ifdef HAVE_DTRACE
1787-
if (DTRACE_OCI8_CONNECT_DONE_ENABLED()) {
1788-
DTRACE_OCI8_CONNECT_DONE();
1787+
if (DTRACE_OCI8_CONNECT_RETURN_ENABLED()) {
1788+
DTRACE_OCI8_CONNECT_RETURN(connection);
17891789
}
17901790
#endif /* HAVE_DTRACE */
17911791

@@ -3465,6 +3465,20 @@ static sword php_oci_ping_init(php_oci_connection *connection, OCIError *errh TS
34653465
}
34663466
/* }}} */
34673467

3468+
/* {{{ php_oci_dtrace_check_connection()
3469+
*
3470+
* DTrace output for connections that may have become invalid and marked for reopening
3471+
*/
3472+
void php_oci_dtrace_check_connection(php_oci_connection *connection, sword errcode, ub4 serverStatus)
3473+
{
3474+
#ifdef HAVE_DTRACE
3475+
if (DTRACE_OCI8_CHECK_CONNECTION_ENABLED()) {
3476+
DTRACE_OCI8_CHECK_CONNECTION(connection, connection && connection->is_open ? 1 : 0, (int)errcode, (unsigned long)serverStatus);
3477+
}
3478+
#endif /* HAVE_DTRACE */
3479+
}
3480+
/* }}} */
3481+
34683482
#endif /* HAVE_OCI8 */
34693483

34703484
/*

ext/oci8/oci8_dtrace.d

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
*/
1818

1919
provider php {
20-
probe oci8__connect__start(char *username, char *dbname, char *charset, long session_mode, int persistent, int exclusive);
21-
probe oci8__connect__done();
20+
probe oci8__connect__entry(char *username, char *dbname, char *charset, long session_mode, int persistent, int exclusive);
21+
probe oci8__connect__return(void *connection);
22+
probe oci8__check__connection(void *connection, int is_open, int errcode, unsigned long serverstatus);
2223
probe oci8__sqltext(char *sql);
2324
probe oci8__error(int status, long errcode);
2425
probe oci8__execute__mode(unsigned int mode);
@@ -27,7 +28,7 @@ provider php {
2728
probe oci8__connect__p__dtor__release(void *connection);
2829
probe oci8__connect__lookup(void *connection, int is_stub);
2930
probe oci8__connect__expiry(void *connection, int is_stub, time_t idle_expiry, time_t timestamp);
30-
probe oci8__connect__type(int is_persistent, int exclusive, void *connection, long num_persistent, long num_links);
31+
probe oci8__connect__type(int persistent, int exclusive, void *connection, long num_persistent, long num_connections);
3132
probe oci8__sesspool__create(void *session_pool);
3233
probe oci8__sesspool__stats(unsigned long free, unsigned long busy, unsigned long open);
3334
probe oci8__sesspool__type(int type, void *session_pool);

ext/oci8/php_oci8_int.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ typedef struct {
310310
*/
311311
#define PHP_OCI_HANDLE_ERROR(connection, errcode) \
312312
do { \
313+
ub4 serverStatus = OCI_SERVER_NORMAL; \
313314
switch (errcode) { \
314315
case 1013: \
315316
zend_bailout(); \
@@ -339,7 +340,6 @@ typedef struct {
339340
break; \
340341
default: \
341342
{ \
342-
ub4 serverStatus = OCI_SERVER_NORMAL; \
343343
PHP_OCI_CALL(OCIAttrGet, ((dvoid *)(connection)->server, OCI_HTYPE_SERVER, (dvoid *)&serverStatus, \
344344
(ub4 *)0, OCI_ATTR_SERVER_STATUS, (connection)->err)); \
345345
if (serverStatus != OCI_SERVER_NORMAL) { \
@@ -348,6 +348,7 @@ typedef struct {
348348
} \
349349
break; \
350350
} \
351+
php_oci_dtrace_check_connection(connection, errcode, serverStatus); \
351352
} while (0)
352353

353354
#define PHP_OCI_REGISTER_RESOURCE(resource, le_resource) \
@@ -411,6 +412,7 @@ void php_oci_client_get_version(char **version TSRMLS_DC);
411412
int php_oci_server_get_version(php_oci_connection *connection, char **version TSRMLS_DC);
412413
void php_oci_fetch_row(INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_args);
413414
int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSRMLS_DC);
415+
void php_oci_dtrace_check_connection(php_oci_connection *connection, sword errcode, ub4 serverStatus);
414416

415417
/* }}} */
416418

0 commit comments

Comments
 (0)