]> granicus.if.org Git - php/commitdiff
OCI8 2.0: add oci8-check-connection probe and do some renaming
authorChristopher Jones <sixd@php.net>
Tue, 27 Aug 2013 23:41:02 +0000 (16:41 -0700)
committerChristopher Jones <sixd@php.net>
Tue, 27 Aug 2013 23:41:02 +0000 (16:41 -0700)
ext/oci8/config.m4
ext/oci8/oci8.c
ext/oci8/oci8_dtrace.d
ext/oci8/php_oci8_int.h

index b76db646385444de2b8314ac8f783f446d62e18d..2af75a27f3e498ea7cb0866d99427d99f2c3e597 100644 (file)
@@ -154,8 +154,7 @@ if test "$PHP_OCI8" != "no"; then
       AC_MSG_ERROR([You need at least PHP 5.4 to be able to use DTrace with PHP OCI8])
     else
       AC_CHECK_HEADERS([sys/sdt.h], [
-        PHP_INIT_DTRACE([ext/oci8/oci8_dtrace.d],[ext/oci8/oci8_dtrace_gen.h],[ext/oci8/oci8.c \
-                       ext/oci8/oci8_interface.c ext/oci8/oci8_collection.c ext/oci8/oci8_lob.c ext/oci8/oci8_statement.c])
+        PHP_INIT_DTRACE([ext/oci8/oci8_dtrace.d],[ext/oci8/oci8_dtrace_gen.h],[ext/oci8/oci8.c ext/oci8/oci8_statement.c])
        ], [
         AC_MSG_ERROR(
           [Cannot find sys/sdt.h which is required for DTrace support])
index f717caa713e64666c182f68099936a49adf81e1c..b30fb4bef45d9f5ce8a56b736f1546ea0cff08ef 100644 (file)
@@ -1772,8 +1772,8 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus
        }
 
 #ifdef HAVE_DTRACE
-       if (DTRACE_OCI8_CONNECT_START_ENABLED()) {
-               DTRACE_OCI8_CONNECT_START(username, dbname, charset, session_mode, persistent, exclusive);
+       if (DTRACE_OCI8_CONNECT_ENTRY_ENABLED()) {
+               DTRACE_OCI8_CONNECT_ENTRY(username, dbname, charset, session_mode, persistent, exclusive);
        }
 #endif /* HAVE_DTRACE */
 
@@ -1784,8 +1784,8 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus
        connection = php_oci_do_connect_ex(username, username_len, password, password_len, NULL, 0, dbname, dbname_len, charset, session_mode, persistent, exclusive TSRMLS_CC);
 
 #ifdef HAVE_DTRACE
-       if (DTRACE_OCI8_CONNECT_DONE_ENABLED()) {
-               DTRACE_OCI8_CONNECT_DONE();
+       if (DTRACE_OCI8_CONNECT_RETURN_ENABLED()) {
+               DTRACE_OCI8_CONNECT_RETURN(connection);
        }
 #endif /* HAVE_DTRACE */
 
@@ -3465,6 +3465,20 @@ static sword php_oci_ping_init(php_oci_connection *connection, OCIError *errh TS
 }
 /* }}} */
 
+/* {{{ php_oci_dtrace_check_connection()
+ *
+ * DTrace output for connections that may have become invalid and marked for reopening
+ */
+void php_oci_dtrace_check_connection(php_oci_connection *connection, sword errcode, ub4 serverStatus)
+{
+#ifdef HAVE_DTRACE
+       if (DTRACE_OCI8_CHECK_CONNECTION_ENABLED()) {
+               DTRACE_OCI8_CHECK_CONNECTION(connection, connection && connection->is_open ? 1 : 0, (int)errcode, (unsigned long)serverStatus);
+       }
+#endif /* HAVE_DTRACE */
+}
+/* }}} */
+
 #endif /* HAVE_OCI8 */
 
 /*
index 2773f782181343209eb64d225b537199f9121881..15d210cf6dfbcb52c1ed685a9eda42e90db735a3 100644 (file)
@@ -17,8 +17,9 @@
 */
 
 provider php {
-       probe oci8__connect__start(char *username, char *dbname, char *charset, long session_mode, int persistent, int exclusive);
-       probe oci8__connect__done();
+       probe oci8__connect__entry(char *username, char *dbname, char *charset, long session_mode, int persistent, int exclusive);
+       probe oci8__connect__return(void *connection);
+       probe oci8__check__connection(void *connection, int is_open, int errcode, unsigned long serverstatus);
        probe oci8__sqltext(char *sql);
        probe oci8__error(int status, long errcode);
        probe oci8__execute__mode(unsigned int mode);
@@ -27,7 +28,7 @@ provider php {
        probe oci8__connect__p__dtor__release(void *connection);
        probe oci8__connect__lookup(void *connection, int is_stub);
        probe oci8__connect__expiry(void *connection, int is_stub, time_t idle_expiry, time_t timestamp);
-       probe oci8__connect__type(int is_persistent, int exclusive, void *connection, long num_persistent, long num_links);
+       probe oci8__connect__type(int persistent, int exclusive, void *connection, long num_persistent, long num_connections);
        probe oci8__sesspool__create(void *session_pool);
        probe oci8__sesspool__stats(unsigned long free, unsigned long busy, unsigned long open);
        probe oci8__sesspool__type(int type, void *session_pool);
index daf649b0cf55bb30bff0503a2b82385a9e1ad551..ac58145f44957b86325ddd390bf7de570566408c 100644 (file)
@@ -310,6 +310,7 @@ typedef struct {
  */
 #define PHP_OCI_HANDLE_ERROR(connection, errcode) \
        do {                                                                              \
+               ub4 serverStatus = OCI_SERVER_NORMAL;     \
                switch (errcode) {                                                \
                        case  1013:                                                       \
                                zend_bailout();                                   \
@@ -339,7 +340,6 @@ typedef struct {
                                break;                                                    \
                        default:                                                                                \
                        {                                                                                               \
-                               ub4 serverStatus = OCI_SERVER_NORMAL;           \
                                PHP_OCI_CALL(OCIAttrGet, ((dvoid *)(connection)->server, OCI_HTYPE_SERVER, (dvoid *)&serverStatus, \
                                                                                  (ub4 *)0, OCI_ATTR_SERVER_STATUS, (connection)->err)); \
                                if (serverStatus != OCI_SERVER_NORMAL) {        \
@@ -348,6 +348,7 @@ typedef struct {
                        }                                                                                               \
                        break;                                                                                  \
                }                                                                                                       \
+               php_oci_dtrace_check_connection(connection, errcode, serverStatus); \
        } while (0)
 
 #define PHP_OCI_REGISTER_RESOURCE(resource, le_resource) \
@@ -411,6 +412,7 @@ void php_oci_client_get_version(char **version TSRMLS_DC);
 int php_oci_server_get_version(php_oci_connection *connection, char **version TSRMLS_DC);
 void php_oci_fetch_row(INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_args);
 int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSRMLS_DC);
+void php_oci_dtrace_check_connection(php_oci_connection *connection, sword errcode, ub4 serverStatus);
 
 /* }}} */