diff --git a/cpp-lib/cpprestsdk_install/linux/lib/cpprestsdk/cpprestsdk-targets.cmake b/cpp-lib/cpprestsdk_install/linux/lib/cpprestsdk/cpprestsdk-targets.cmake index e110759e3..f9630e93c 100644 --- a/cpp-lib/cpprestsdk_install/linux/lib/cpprestsdk/cpprestsdk-targets.cmake +++ b/cpp-lib/cpprestsdk_install/linux/lib/cpprestsdk/cpprestsdk-targets.cmake @@ -16,7 +16,7 @@ set(CMAKE_IMPORT_FILE_VERSION 1) set(_targetsDefined) set(_targetsNotDefined) set(_expectedTargets) -foreach(_expectedTarget cpprestsdk::cpprest cpprestsdk::cpprestsdk_boost_internal cpprestsdk::cpprestsdk_zlib_internal cpprestsdk::cpprestsdk_openssl_internal cpprestsdk::cpprestsdk_websocketpp_internal) +foreach(_expectedTarget cpprestsdk::cpprest cpprestsdk::cpprestsdk_boost_internal cpprestsdk::cpprestsdk_zlib_internal cpprestsdk::cpprestsdk_openssl_internal) list(APPEND _expectedTargets ${_expectedTarget}) if(NOT TARGET ${_expectedTarget}) list(APPEND _targetsNotDefined ${_expectedTarget}) @@ -53,10 +53,9 @@ endif() add_library(cpprestsdk::cpprest STATIC IMPORTED) set_target_properties(cpprestsdk::cpprest PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "CPPREST_FORCE_HTTP_CLIENT_ASIO;CPPREST_FORCE_HTTP_LISTENER_ASIO" - INTERFACE_COMPILE_OPTIONS "-fPIC" + INTERFACE_COMPILE_DEFINITIONS "CPPREST_EXCLUDE_WEBSOCKETS=1;CPPREST_FORCE_HTTP_CLIENT_ASIO;CPPREST_FORCE_HTTP_LISTENER_ASIO" INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" - INTERFACE_LINK_LIBRARIES "-ldl;-lpthread;\$;\$;\$;\$;cpprestsdk::cpprestsdk_boost_internal;cpprestsdk::cpprestsdk_openssl_internal;cpprestsdk::cpprestsdk_boost_internal;cpprestsdk::cpprestsdk_openssl_internal" + INTERFACE_LINK_LIBRARIES "-lpthread;\$;cpprestsdk::cpprestsdk_boost_internal;cpprestsdk::cpprestsdk_openssl_internal;cpprestsdk::cpprestsdk_boost_internal;cpprestsdk::cpprestsdk_openssl_internal" ) # Create imported target cpprestsdk::cpprestsdk_boost_internal @@ -73,17 +72,9 @@ set_target_properties(cpprestsdk::cpprestsdk_zlib_internal PROPERTIES add_library(cpprestsdk::cpprestsdk_openssl_internal INTERFACE IMPORTED) set_target_properties(cpprestsdk::cpprestsdk_openssl_internal PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "CPPREST_NO_SSL_LEAK_SUPPRESS" INTERFACE_LINK_LIBRARIES "OpenSSL::SSL" ) -# Create imported target cpprestsdk::cpprestsdk_websocketpp_internal -add_library(cpprestsdk::cpprestsdk_websocketpp_internal INTERFACE IMPORTED) - -set_target_properties(cpprestsdk::cpprestsdk_websocketpp_internal PROPERTIES - INTERFACE_LINK_LIBRARIES "cpprestsdk::cpprestsdk_boost_internal;cpprestsdk::cpprestsdk_openssl_internal" -) - if(CMAKE_VERSION VERSION_LESS 3.0.0) message(FATAL_ERROR "This file relies on consumers using CMake 3.0.0 or greater.") endif() diff --git a/cpp-lib/cpprestsdk_install/mac/lib/cpprestsdk/cpprestsdk-targets.cmake b/cpp-lib/cpprestsdk_install/mac/lib/cpprestsdk/cpprestsdk-targets.cmake index 4026a4602..0d6b5ed74 100644 --- a/cpp-lib/cpprestsdk_install/mac/lib/cpprestsdk/cpprestsdk-targets.cmake +++ b/cpp-lib/cpprestsdk_install/mac/lib/cpprestsdk/cpprestsdk-targets.cmake @@ -56,7 +56,7 @@ set_target_properties(cpprestsdk::cpprest PROPERTIES INTERFACE_COMPILE_DEFINITIONS "CPPREST_FORCE_HTTP_CLIENT_ASIO;CPPREST_FORCE_HTTP_LISTENER_ASIO" INTERFACE_COMPILE_OPTIONS "-fPIC" INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" - INTERFACE_LINK_LIBRARIES "-ldl;\$;\$;\$;\$;/Library/Frameworks/CoreFoundation.framework;/Library/Frameworks/Security.framework;cpprestsdk::cpprestsdk_boost_internal;cpprestsdk::cpprestsdk_openssl_internal;cpprestsdk::cpprestsdk_boost_internal;cpprestsdk::cpprestsdk_openssl_internal" + INTERFACE_LINK_LIBRARIES "-ldl;\$;\$;\$;cpprestsdk::cpprestsdk_boost_internal;cpprestsdk::cpprestsdk_openssl_internal;cpprestsdk::cpprestsdk_boost_internal;cpprestsdk::cpprestsdk_openssl_internal" ) # Create imported target cpprestsdk::cpprestsdk_boost_internal diff --git a/cpp-lib/src/pitaya/c_wrapper.cpp b/cpp-lib/src/pitaya/c_wrapper.cpp index c1450eecf..78c6b5c20 100644 --- a/cpp-lib/src/pitaya/c_wrapper.cpp +++ b/cpp-lib/src/pitaya/c_wrapper.cpp @@ -56,7 +56,7 @@ FreePitayaError(CPitayaError* err) { free(err->code); free(err->msg); - free(err); + //free(err); } static void @@ -66,7 +66,7 @@ FreeServer(CServer* sv) free(sv->type); free(sv->metadata); free(sv->hostname); - free(sv); + //free(sv); } pitaya::etcdv3_service_discovery::Config diff --git a/csharp-example/csharp-example/Program.cs b/csharp-example/csharp-example/Program.cs index 2c35a793a..7f298b4a9 100644 --- a/csharp-example/csharp-example/Program.cs +++ b/csharp-example/csharp-example/Program.cs @@ -96,4 +96,4 @@ static void Main(string[] args) // } } } -} \ No newline at end of file +} diff --git a/csharp-example/csharp-example/csharp-example.csproj b/csharp-example/csharp-example/csharp-example.csproj index 73f82145a..8952473c9 100644 --- a/csharp-example/csharp-example/csharp-example.csproj +++ b/csharp-example/csharp-example/csharp-example.csproj @@ -31,7 +31,7 @@ - ..\..\csharp-lib\packages\protobuf.net35.3.5.1\lib\net35\Google.Protobuf.dll + ..\..\csharp-lib\packages\TFG.Protobuff35.3.6.1\lib\net35\Google.Protobuf.dll diff --git a/csharp-lib/cluster-lib/PitayaCluster.cs b/csharp-lib/cluster-lib/PitayaCluster.cs index e5282b5df..1cc1db1df 100644 --- a/csharp-lib/cluster-lib/PitayaCluster.cs +++ b/csharp-lib/cluster-lib/PitayaCluster.cs @@ -211,9 +211,9 @@ public static unsafe T Rpc(string serverId, Route route, IMessage msg) if (!ok) // error { -// FreePitayaErrorInternal(retError); - - throw new PitayaException($"RPC call failed: ({retError.code}: {retError.msg})"); + string code = string.Copy(retError.code); + string errMsg = string.Copy(retError.msg); + throw new PitayaException($"RPC call failed: ({code}: {errMsg})"); } var protoRet = GetProtoMessageFromMemoryBuffer(*memBufPtr); @@ -248,7 +248,7 @@ public static T Rpc(Route route, IMessage msg) [DllImport("libpitaya_cluster", CallingConvention = CallingConvention.Cdecl, EntryPoint = "tfg_pitc_OnSignal")] private static extern void OnSignalInternal(OnSignalFunc ptr); -// [DllImport("libpitaya_cluster", CallingConvention = CallingConvention.Cdecl, EntryPoint = "tfg_pitc_FreePitayaError")] -// private static extern unsafe void FreePitayaErrorInternal(/**/Pitaya.Error *ptr); + [DllImport("libpitaya_cluster", CallingConvention = CallingConvention.Cdecl, EntryPoint = "tfg_pitc_FreePitayaError")] + private static extern unsafe void FreePitayaErrorInternal(ref Error err); } } diff --git a/precompiled/libpitaya_cluster.dylib b/precompiled/libpitaya_cluster.dylib index d79c70f00..f25fe9ea3 100755 Binary files a/precompiled/libpitaya_cluster.dylib and b/precompiled/libpitaya_cluster.dylib differ diff --git a/precompiled/libpitaya_cluster.so b/precompiled/libpitaya_cluster.so index 0bff4e0c2..23db7a448 100644 Binary files a/precompiled/libpitaya_cluster.so and b/precompiled/libpitaya_cluster.so differ diff --git a/python-lib/pitayaserver/pitayaserver.py b/python-lib/pitayaserver/pitayaserver.py index 3a66726ba..ef64f99f4 100644 --- a/python-lib/pitayaserver/pitayaserver.py +++ b/python-lib/pitayaserver/pitayaserver.py @@ -1,6 +1,6 @@ from .route import Route from google.protobuf import message -from ctypes import POINTER, byref, c_char, c_void_p, addressof, memmove, sizeof +from ctypes import POINTER, byref, c_char, c_char_p, c_void_p, addressof, memmove, sizeof from .gen.response_pb2 import Response from .remote import BaseRemote from .c_interop import SdConfig, NatsConfig, Server, Native, FREECB, MemoryBuffer, RPCReq, RPCCB, PitayaError @@ -29,11 +29,12 @@ def initialize_pitaya( def get_server_by_id(server_id: str): """ gets a server by its id """ - # TODO needs free + # TODO needs free -- leak here! sv = Server() success = LIB.tfg_pitc_GetServerById(server_id.encode('utf-8'), sv) if success is False: raise Exception('failed to get server {}'.format(server_id)) + # LIB.tfg_pitc_FreeServer(byref(sv)) return sv @@ -120,7 +121,7 @@ def _rpc_cb(req: POINTER(RPCReq)) -> c_void_p: return _get_error_response_c_void_p("PIT-500", err_str) -def send_rpc(route: str, in_msg: message.Message, res_class: message.Message, server_id: str = '') -> message.Message: +def send_rpc(route: str, in_msg: message.Message, res_class: message.Message, server_id: str='') -> message.Message: """ sends a rpc to other pitaya server """ if not issubclass(type(in_msg), message.Message) or not issubclass(res_class, message.Message): raise TypeError @@ -132,8 +133,9 @@ def send_rpc(route: str, in_msg: message.Message, res_class: message.Message, se res = LIB.tfg_pitc_RPC(server_id.encode( 'utf-8'), route.encode('utf-8'), addressof(c_bytes), msg_len, byref(ret_ptr), byref(err)) if not res: - # TODO: needs free - raise Exception("code: {} msg: {}".format(err.code, err.msg)) + exception_msg = "code: {} msg: {}".format(err.code, err.msg) + LIB.tfg_pitc_FreePitayaError(err) + raise Exception(exception_msg) ret_bytes = ( c_char * ret_ptr.contents.size).from_address(ret_ptr.contents.data) response = Response() diff --git a/python-lib/setup.py b/python-lib/setup.py index d29ae4319..7a60fc465 100644 --- a/python-lib/setup.py +++ b/python-lib/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='pitayaserver', - version='0.2.0', + version='0.2.1', author="TFG Co", author_email="backend@tfgco.com", description="A library for creating pitaya backend servers using python",