Lines Matching refs:connection
293 static void dba_close_connection(dba_connection *connection) in dba_close_connection() argument
295 bool persistent = connection->info->flags & DBA_PERSISTENT; in dba_close_connection()
298 dba_close_info(connection->info); in dba_close_connection()
301 connection->info = NULL; in dba_close_connection()
303 if (connection->hash) { in dba_close_connection()
304 zend_hash_del(&DBA_G(connections), connection->hash); in dba_close_connection()
305 zend_string_release_ex(connection->hash, persistent); in dba_close_connection()
306 connection->hash = NULL; in dba_close_connection()
349 dba_connection *connection = dba_connection_from_obj(obj); in dba_connection_free_obj() local
351 if (connection->info) { in dba_connection_free_obj()
352 dba_close_connection(connection); in dba_connection_free_obj()
355 zend_object_std_dtor(&connection->std); in dba_connection_free_obj()
587 dba_connection *connection = Z_DBA_CONNECTION_P(return_value); in php_dba_open() local
588 connection->info = (dba_info *)le->ptr; in php_dba_open()
589 connection->hash = zend_string_dup(resource_key, /* persistent */ true); in php_dba_open()
590 GC_MAKE_PERSISTENT_LOCAL(connection->hash); in php_dba_open()
592 if (zend_hash_exists(&DBA_G(connections), connection->hash)) { in php_dba_open()
593 zend_hash_del(&DBA_G(connections), connection->hash); in php_dba_open()
596 zend_hash_add_new(&DBA_G(connections), connection->hash, return_value); in php_dba_open()
778 dba_connection *connection; in php_dba_open() local
781 connection = Z_DBA_CONNECTION_P(return_value); in php_dba_open()
783 connection->info = pecalloc(1, sizeof(dba_info), persistent); in php_dba_open()
784 connection->info->path = php_dba_zend_string_dup_safe(path, persistent); in php_dba_open()
785 connection->info->mode = modenr; in php_dba_open()
786 connection->info->file_permission = permission; in php_dba_open()
787 connection->info->map_size = map_size; in php_dba_open()
788 connection->info->driver_flags = driver_flags; in php_dba_open()
789 …connection->info->flags = (hptr->flags & ~DBA_LOCK_ALL) | (lock_flag & DBA_LOCK_ALL) | (persistent… in php_dba_open()
790 connection->info->lock.mode = lock_mode; in php_dba_open()
792 connection->hash = zend_string_dup(resource_key, /* persistent */ true); in php_dba_open()
793 GC_MAKE_PERSISTENT_LOCAL(connection->hash); in php_dba_open()
795 connection->hash = zend_string_copy(resource_key); in php_dba_open()
799 connection = Z_DBA_CONNECTION_P(return_value); in php_dba_open()
808 if ((other = php_dba_find(connection->info->path)) != NULL) { in php_dba_open()
824 spprintf(&lock_name, 0, "%s.lck", ZSTR_VAL(connection->info->path)); in php_dba_open()
829 …connection->info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IG… in php_dba_open()
831 if (!connection->info->lock.fp) { in php_dba_open()
836 if (!connection->info->lock.fp) { in php_dba_open()
838 …connection->info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|RE… in php_dba_open()
839 if (connection->info->lock.fp) { in php_dba_open()
843 zend_string_release_ex(connection->info->path, persistent); in php_dba_open()
844 connection->info->path = php_dba_zend_string_dup_safe(opened_path, persistent); in php_dba_open()
858 if (!connection->info->lock.fp) { in php_dba_open()
864 if (!error && !php_stream_supports_lock(connection->info->lock.fp)) { in php_dba_open()
867 if (!error && php_stream_lock(connection->info->lock.fp, lock_mode)) { in php_dba_open()
874 if (connection->info->lock.fp && is_db_lock) { in php_dba_open()
875 …connection->info->fp = connection->info->lock.fp; /* use the same stream for locking and database … in php_dba_open()
877 …connection->info->fp = php_stream_open_wrapper(ZSTR_VAL(connection->info->path), file_mode, STREAM… in php_dba_open()
879 if (!connection->info->fp) { in php_dba_open()
889 …if (SUCCESS != php_stream_cast(connection->info->fp, PHP_STREAM_AS_FD, (void*)&connection->info->f… in php_dba_open()
896 int flags = fcntl(connection->info->fd, F_GETFL); in php_dba_open()
897 fcntl(connection->info->fd, F_SETFL, flags & ~O_APPEND); in php_dba_open()
900 if (connection->info->lock.fp != NULL) { in php_dba_open()
901 …php_stream_free(connection->info->lock.fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STR… in php_dba_open()
903 if (connection->info->fp != connection->info->lock.fp) { in php_dba_open()
904 …php_stream_free(connection->info->fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_F… in php_dba_open()
906 connection->info->fp = NULL; in php_dba_open()
907 connection->info->lock.fp = NULL; in php_dba_open()
908 connection->info->fd = -1; in php_dba_open()
919 if (error || hptr->open(connection->info, &error) == FAILURE) { in php_dba_open()
932 connection->info->hnd = hptr; in php_dba_open()
935 if (zend_register_persistent_resource_ex(connection->hash, connection->info, le_pdb) == NULL) { in php_dba_open()
943 zend_hash_add_new(&DBA_G(connections), connection->hash, return_value); in php_dba_open()
966 dba_connection *connection = NULL; in PHP_FUNCTION() local
972 connection = Z_DBA_CONNECTION_P(id); in PHP_FUNCTION()
973 CHECK_DBA_CONNECTION(connection->info); in PHP_FUNCTION()
975 bool persistent = connection->info->flags & DBA_PERSISTENT; in PHP_FUNCTION()
977 dba_close_connection(connection); in PHP_FUNCTION()
980 …apply_with_argument(&EG(persistent_list), remove_pconnection_from_list, (void *) connection->info); in PHP_FUNCTION()