1. try to fix crash on Linux by use libssh multi-thread initialization function.

2. update libssh to v0.7.5.
3. update build script to match libssh threads library.
pull/32/head
Apex Liu 2017-04-30 17:46:11 +00:00
parent 79451a95ff
commit 13250ec081
6 changed files with 18 additions and 7 deletions

View File

@ -422,7 +422,7 @@ class BuilderLinux(BuilderBase):
# os.rename(os.path.join(self.PATH_TMP, 'master'), os.path.join(self.PATH_TMP, 'libssh-{}'.format(LIBSSH_VER)))
cc.n('build libssh...', end='')
if os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libssh.a')):
if os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libssh.a')) and os.path.exists(os.path.join(self.PATH_RELEASE, 'lib', 'libssh_threads.a')):
cc.w('already exists, skip.')
return
cc.v('')
@ -482,7 +482,9 @@ class BuilderLinux(BuilderBase):
# because make install will fail because we can not disable ssh_shared target,
# so we copy necessary files ourselves.
utils.ensure_file_exists(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', 'libssh.a'))
utils.ensure_file_exists(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', 'threads', 'libssh_threads.a'))
utils.copy_file(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src'), os.path.join(self.PATH_RELEASE, 'lib'), 'libssh.a')
utils.copy_file(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', 'threads'), os.path.join(self.PATH_RELEASE, 'lib'), 'libssh_threads.a')
utils.copy_ex(os.path.join(self.LIBSSH_PATH_SRC, 'include'), os.path.join(self.PATH_RELEASE, 'include'), 'libssh')
def _build_sqlite(self, file_name):
@ -504,7 +506,8 @@ class BuilderLinux(BuilderBase):
def fix_output(self):
# remove .so files, otherwise will link to .so but not .a in default.
rm = ['libsqlite3.la', 'libsqlite3.so.0', 'libsqlite3.so', 'libsqlite3.so.0.8.6', 'libuv.la', 'libuv.so.1', 'libuv.so', 'libuv.so.1.0.0']
# rm = ['libsqlite3.la', 'libsqlite3.so.0', 'libsqlite3.so', 'libsqlite3.so.0.8.6', 'libuv.la', 'libuv.so.1', 'libuv.so', 'libuv.so.1.0.0']
rm = ['libuv.la', 'libuv.so.1', 'libuv.so', 'libuv.so.1.0.0']
for i in rm:
_path = os.path.join(self.PATH_RELEASE, 'lib', i)
if os.path.exists(_path):
@ -550,7 +553,9 @@ def main():
builder.build_libuv()
builder.build_mbedtls()
builder.build_libssh()
builder.build_sqlite()
# do not need sqlite any more.
# builder.build_sqlite()
builder.fix_output()

View File

@ -36,7 +36,7 @@ openssl = 1.0.2h,1000208f
libuv = 1.11.0
mbedtls = 2.3.0
sqlite = 3170000
libssh = 0.7.4
libssh = 0.7.5
jsoncpp = 0.10.6
mongoose = 6.6

View File

@ -35,4 +35,5 @@ include_directories(
link_directories(../../../external/linux/release/lib)
add_executable(tp_core ${DIR_SRCS})
target_link_libraries(tp_core ssl crypto mbedx509 mbedtls mbedcrypto sqlite3 dl pthread rt util)
#target_link_libraries(tp_core ssl crypto mbedx509 mbedtls mbedcrypto sqlite3 dl pthread rt util)
target_link_libraries(tp_core ssl crypto mbedx509 mbedtls mbedcrypto dl pthread rt util)

View File

@ -153,7 +153,7 @@ bool TppManager::load_tpp(const ex_wstr& libname)
lib->dylib = ex_dlopen(libfile.c_str());
if (NULL == lib->dylib)
{
EXLOGE(L"[core] load dylib `%ls` failed, maybe it not exists.\n", libfile.c_str());
EXLOGE(L"[core] load dylib `%ls` failed.\n", libfile.c_str());
delete lib;
return false;
}

View File

@ -22,4 +22,4 @@ include_directories(
link_directories(../../../../external/linux/release/lib)
add_library(tpssh SHARED ${DIR_SSH_SRCS})
target_link_libraries(tpssh ssh ssl crypto mbedx509 mbedtls mbedcrypto dl pthread rt util)
target_link_libraries(tpssh ssh ssh_threads ssl crypto mbedx509 mbedtls mbedcrypto dl pthread rt util)

View File

@ -3,6 +3,11 @@
TPP_API ex_rv tpp_init(TPP_INIT_ARGS* init_args)
{
#ifdef EX_OS_UNIX
ssh_threads_set_callbacks(ssh_threads_get_pthread());
ssh_init();
#endif
if (!g_ssh_env.init(init_args))
return TSR_FAILED;