Skip to content

Method for closing all persistent connections at once #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/php_tarantool.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ PHP_METHOD(Tarantool, delete);
PHP_METHOD(Tarantool, update);
PHP_METHOD(Tarantool, upsert);
PHP_METHOD(Tarantool, flush_schema);
PHP_METHOD(Tarantool, close_all);

ZEND_BEGIN_MODULE_GLOBALS(tarantool)
zend_bool persistent;
Expand Down
16 changes: 16 additions & 0 deletions src/tarantool.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_tarantool_upsert, 0, 0, 3)
ZEND_END_ARG_INFO()

#define TNT_MEP(name, args) PHP_ME (Tarantool, name, args, ZEND_ACC_PUBLIC)
#define TNT_MES(name, args) PHP_ME (Tarantool, name, args, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
#define TNT_MAP(alias, name, args) PHP_MALIAS(Tarantool, alias, name, args, ZEND_ACC_PUBLIC)
#define TNT_MAS(alias, name, args) PHP_MALIAS(Tarantool, alias, name, args, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
const zend_function_entry Tarantool_methods[] = {
TNT_MEP(__construct, arginfo_tarantool_construct )
TNT_MEP(connect, arginfo_tarantool_void )
Expand All @@ -582,10 +584,14 @@ const zend_function_entry Tarantool_methods[] = {
TNT_MAP(evaluate, eval, arginfo_tarantool_proc_tuple )
TNT_MAP(flushSchema, flush_schema, arginfo_tarantool_void )
TNT_MAP(disconnect, close, arginfo_tarantool_void )
TNT_MES(close_all, arginfo_tarantool_void )
TNT_MAS(closeAll, close_all, arginfo_tarantool_void )
{NULL, NULL, NULL}
};
#undef TNT_MEP
#undef TNT_MES
#undef TNT_MAP
#undef TNT_MAS

/* ####################### HELPERS ####################### */

Expand Down Expand Up @@ -1283,6 +1289,16 @@ PHP_METHOD(Tarantool, close) {
RETURN_TRUE;
}

PHP_METHOD(Tarantool, close_all) {
zval *zle;

ZEND_HASH_FOREACH_VAL(&EG(persistent_list), zle) {
if (Z_RES_TYPE_P(zle) == php_tarantool_list_entry()) {
tarantool_stream_close((tarantool_connection *) Z_RES_VAL_P(zle));
}
} ZEND_HASH_FOREACH_END();
}

PHP_METHOD(Tarantool, ping) {
TARANTOOL_FUNCTION_BEGIN(obj, id, "");
TARANTOOL_CONNECT_ON_DEMAND(obj);
Expand Down
2 changes: 1 addition & 1 deletion src/tarantool_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <stdint.h>

#include <php_tarantool.h>
#include "php_tarantool.h"

/**
* Pack version into uint32_t.
Expand Down