diff --git a/src/ffisyms.cc b/src/ffisyms.cc index f6a0ba52181e73daf7430cb131af4704ac7d4190..b8e6dbe926fd5083ab21f084ade0e50fbe634f99 100644 --- a/src/ffisyms.cc +++ b/src/ffisyms.cc @@ -7,8 +7,6 @@ #include <box/lua/call.h> #include <lua/init.h> #include <tarantool.h> -#include <stdio.h> -#include <readline/readline.h> /* * A special hack to cc/ld to keep symbols in an optimized binary. @@ -31,7 +29,6 @@ void *ffi_symbols[] = { (void *) port_ffi_destroy, (void *) boxffi_select, (void *) password_prepare, - (void *) readline, (void *) tarantool_lua_interactive, (void *) load_cfg, (void *) box_set_wal_fsync_delay, diff --git a/src/lua/init.cc b/src/lua/init.cc index e2a8076cdbf0918b1a4088bedad196e932866c91..6c9194265a5dc121adf98302c84c218c0e8e581a 100644 --- a/src/lua/init.cc +++ b/src/lua/init.cc @@ -44,6 +44,7 @@ extern "C" { #include <fiber.h> +#include "coeio.h" #include "lua/fiber.h" #include "lua/admin.h" #include "lua/errinj.h" @@ -58,6 +59,8 @@ extern "C" { #include <ctype.h> #include "small/region.h" +#include <stdio.h> +#include <readline/readline.h> #include <readline/history.h> struct lua_State *tarantool_L; @@ -422,17 +425,32 @@ tarantool_lua(struct lua_State *L, char *history = NULL; +ssize_t +readline_cb(va_list ap) +{ + const char **line = va_arg(ap, const char **); + *line = readline("tarantool> "); + return 0; +} + extern "C" void -tarantool_lua_interactive(char *line) +tarantool_lua_interactive() { - struct tbuf *out = tbuf_new(&fiber()->gc); - struct lua_State *L = lua_newthread(tarantool_L); - tarantool_lua(L, out, line); - lua_pop(tarantool_L, 1); - printf("%.*s", out->size, out->data); - fiber_gc(); - if (history) - add_history(line); + char *line; + while (true) { + coeio_custom(readline_cb, TIMEOUT_INFINITY, &line); + if (line == NULL) + break; + struct tbuf *out = tbuf_new(&fiber()->gc); + struct lua_State *L = lua_newthread(tarantool_L); + tarantool_lua(L, out, line); + lua_pop(tarantool_L, 1); + printf("%.*s", out->size, out->data); + fiber_gc(); + if (history) + add_history(line); + free(line); + } } /** diff --git a/src/lua/init.h b/src/lua/init.h index 34529787d9da67d68d553a4ea5681b8896ebdb53..2b97ff1f6cd16f06d768f697cc3c9049028ff431 100644 --- a/src/lua/init.h +++ b/src/lua/init.h @@ -85,6 +85,6 @@ extern char *history; * Eval line and print output. */ extern "C" void -tarantool_lua_interactive(char *line); +tarantool_lua_interactive(); #endif /* INCLUDES_TARANTOOL_LUA_H */ diff --git a/src/lua/interactive.lua b/src/lua/interactive.lua index 3ca5a37e050fe0dced42a4ea7ba35568fe34a66b..f9aea57bbf148c581c10c1be24d3ac412f8a837b 100644 --- a/src/lua/interactive.lua +++ b/src/lua/interactive.lua @@ -2,20 +2,12 @@ -- local ffi = require('ffi') ffi.cdef([[ - char *readline(const char *prompt); - void tarantool_lua_interactive(char *); + void tarantool_lua_interactive(); void free(void *ptr); ]]) function interactive() - while true do - line = ffi.C.readline("tarantool> ") - if line == nil then - return - end - ffi.C.tarantool_lua_interactive(line) - ffi.C.free(line) - end + ffi.C.tarantool_lua_interactive() end jit.off(interactive) diff --git a/test/lib/tarantool_server.py b/test/lib/tarantool_server.py index 004cff8b5d9787eb5aca65f7b3144a77ac341f8d..6d03fe0e9199f88608ff0ce8cdf28f18d33def1c 100644 --- a/test/lib/tarantool_server.py +++ b/test/lib/tarantool_server.py @@ -502,9 +502,6 @@ class TarantoolServer(Server): 2) wait until server tells us his status """ - print self.logfile_pos.log_begin - print self.logfile_pos.path - self.logfile_pos.seek_from('entering the event loop', self.process if not self.gdb else None) while True: try: