|
39 | 39 | /* Resources */
|
40 | 40 | #define PHP_DRIVER_CLUSTER_RES_NAME PHP_DRIVER_NAMESPACE " Cluster"
|
41 | 41 | #define PHP_DRIVER_SESSION_RES_NAME PHP_DRIVER_NAMESPACE " Session"
|
| 42 | +#define PHP_DRIVER_PREPARED_STATEMENT_RES_NAME PHP_DRIVER_NAMESPACE " PreparedStatement" |
42 | 43 |
|
43 | 44 | static uv_once_t log_once = UV_ONCE_INIT;
|
44 | 45 | static char *log_location = NULL;
|
@@ -134,6 +135,26 @@ php_driver_session_dtor(php5to7_zend_resource rsrc TSRMLS_DC)
|
134 | 135 | }
|
135 | 136 | }
|
136 | 137 |
|
| 138 | +static int le_php_driver_prepared_statement_res; |
| 139 | +int |
| 140 | +php_le_php_driver_prepared_statement() |
| 141 | +{ |
| 142 | + return le_php_driver_prepared_statement_res; |
| 143 | +} |
| 144 | +static void |
| 145 | +php_driver_prepared_statement_dtor(php5to7_zend_resource rsrc TSRMLS_DC) |
| 146 | +{ |
| 147 | + php_driver_pprepared_statement *preparedStmt = (php_driver_pprepared_statement*) rsrc->ptr; |
| 148 | + |
| 149 | + if (preparedStmt) { |
| 150 | + cass_future_free(preparedStmt->future); |
| 151 | + php_driver_del_peref(&preparedStmt->ref, 1); |
| 152 | + pefree(preparedStmt, 1); |
| 153 | + PHP_DRIVER_G(persistent_prepared_statements)--; |
| 154 | + rsrc->ptr = NULL; |
| 155 | + } |
| 156 | +} |
| 157 | + |
137 | 158 | static void
|
138 | 159 | php_driver_log(const CassLogMessage *message, void *data);
|
139 | 160 |
|
@@ -414,6 +435,7 @@ static PHP_GINIT_FUNCTION(php_driver)
|
414 | 435 | php_driver_globals->uuid_gen_pid = 0;
|
415 | 436 | php_driver_globals->persistent_clusters = 0;
|
416 | 437 | php_driver_globals->persistent_sessions = 0;
|
| 438 | + php_driver_globals->persistent_prepared_statements = 0; |
417 | 439 | PHP5TO7_ZVAL_UNDEF(php_driver_globals->type_varchar);
|
418 | 440 | PHP5TO7_ZVAL_UNDEF(php_driver_globals->type_text);
|
419 | 441 | PHP5TO7_ZVAL_UNDEF(php_driver_globals->type_blob);
|
@@ -454,6 +476,11 @@ PHP_MINIT_FUNCTION(php_driver)
|
454 | 476 | PHP_DRIVER_SESSION_RES_NAME,
|
455 | 477 | module_number);
|
456 | 478 |
|
| 479 | + le_php_driver_prepared_statement_res = |
| 480 | + zend_register_list_destructors_ex(NULL, php_driver_prepared_statement_dtor, |
| 481 | + PHP_DRIVER_PREPARED_STATEMENT_RES_NAME, |
| 482 | + module_number); |
| 483 | + |
457 | 484 | php_driver_define_Exception(TSRMLS_C);
|
458 | 485 | php_driver_define_InvalidArgumentException(TSRMLS_C);
|
459 | 486 | php_driver_define_DomainException(TSRMLS_C);
|
|
0 commit comments