Skip to content
Closed
2 changes: 2 additions & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ if test "$PHP_TARANTOOL" != "no"; then
src/tarantool_schema.c \
src/tarantool_proto.c \
src/tarantool_tp.c \
src/tarantool_url.c \
src/tarantool_exception.c \
src/utils.c \
src/third_party/msgpuck.c \
src/third_party/sha1.c \
src/third_party/uri.c \
src/third_party/PMurHash.c \
, $ext_shared)
PHP_ADD_BUILD_DIR([$ext_builddir/src/])
Expand Down
39 changes: 27 additions & 12 deletions lib/tarantool_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ def execute_no_reconnect(self, command):

class TarantoolServer(object):
default_tarantool = {
"bin": "tarantool",
"logfile": "tarantool.log",
"init": "init.lua"}
"bin": "tarantool",
"logfile": "tarantool.log",
"init": "init.lua",
"unix": "tarantool.sock"
}

default_cfg = {
"custom_proc_title": "\"tarantool-python testing\"",
"slab_alloc_arena": 0.5,
"pid_file": "\"box.pid\"",
"rows_per_wal": 200}
"custom_proc_title": "\"tarantool-python testing\"",
"slab_alloc_arena": 0.5,
"pid_file": "\"box.pid\"",
"rows_per_wal": 200
}

@property
def logfile_path(self):
Expand All @@ -134,6 +137,10 @@ def cfgfile_path(self):
def script_path(self):
return os.path.join(self.vardir, self.default_tarantool['init'])

@property
def unix_path(self):
return os.path.join(self.vardir, self.default_tarantool['unix'])

@property
def script_dst(self):
return os.path.join(self.vardir, os.path.basename(self.script))
Expand Down Expand Up @@ -187,9 +194,9 @@ def log_des(self):
def __init__(self):
os.popen('ulimit -c unlimited')
self.args = {}
self.args['primary'] = find_port()
self.args['admin'] = find_port(self.args['primary'] + 1)
self._admin = self.args['admin']

self.use_unix = False

self.vardir = tempfile.mkdtemp(prefix='var_', dir=os.getcwd())
self.find_exe()

Expand All @@ -204,6 +211,7 @@ def find_exe(self):
raise RuntimeError("Can't find server executable in " + os.environ["PATH"])

def generate_configuration(self):
# print(self.args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgotten debug print.

os.putenv("PRIMARY_PORT", str(self.args['primary']))
os.putenv("ADMIN_PORT", str(self.args['admin']))

Expand Down Expand Up @@ -242,6 +250,14 @@ def start(self):
# start Tarantool\Box --DONE(prepare_args)
# * Wait unitl Tarantool\Box
# started --DONE(wait_until_started)
if self.use_unix:
self.args['primary'] = self.unix_path
self.args['admin'] = find_port()
else:
self.args['primary'] = find_port()
self.args['admin'] = find_port(self.args['primary'] + 1)
self._admin = self.args['admin']

self.generate_configuration()
if self.script:
shutil.copy(self.script, self.script_dst)
Expand All @@ -268,5 +284,4 @@ def clean(self):

def __del__(self):
self.stop()
self.clean()

# self.clean()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you comment clean here?

8 changes: 3 additions & 5 deletions src/php_tarantool.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,16 @@ ZEND_EXTERN_MODULE_GLOBALS(tarantool);

typedef struct tarantool_object {
struct tarantool_connection {
char *host;
int port;
char *login;
char *passwd;
char *url;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it wroth to comment purpose of url field, because it is not obvious considering presence of url_parsed. First poor variant of the description:

The url to perform 'physical' connection using php stream; it does not contain authentification information and uses the schema that php streams understands; see tarantool_url_write_php_format for more info.

struct tarantool_url *url_parsed;
php_stream *stream;
struct tarantool_schema *schema;
smart_string *value;
struct tp *tps;
char *greeting;
char *salt;
/* Only for persistent connections */
char *orig_login;
char *orig_user;
char *suffix;
int suffix_len;
zend_string *persistent_id;
Expand Down
Loading