Skip to content
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

Fix ssh crash on reconnect #459

Merged
Merged
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
67 changes: 29 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,25 +143,21 @@ set(NETBOX_DLL_LINK_FLAGS
/NODEFAULTLIB:KERNEL32.LIB
/NODEFAULTLIB:USER32.LIB
/NODEFAULTLIB:VERSION.LIB
/DELAYLOAD:version.dll
/DELAYLOAD:ws2_32.dll
/DELAYLOAD:oleaut32.dll
/DELAYLOAD:shell32.dll
/DELAYLOAD:shlwapi.dll
/DELAYLOAD:crypt32.dll
/DELAYLOAD:secur32.dll
/MANIFEST:NO
/TLBID:1 /DYNAMICBASE /SUBSYSTEM:WINDOWS
/TLBID:1 /DYNAMICBASE /SUBSYSTEM:WINDOWS /NOLOGO
/INCREMENTAL:NO
/SUBSYSTEM:WINDOWS
/NOLOGO
/ignore:4099
/ignore:4197
/ignore:4199
)
#/DELAYLOAD:gdi32.dll

set(NETBOX_DLL_LINK_FLAGS_RELEASE /OPT:REF)
set(NETBOX_DLL_LINK_FLAGS_DEBUG /DEBUG)
set(NETBOX_DLL_LINK_FLAGS_RELEASE ${NETBOX_DLL_LINK_FLAGS} /RELEASE /INCREMENTAL:NO /OPT:REF /OPT:ICF /LTCG)
set(NETBOX_DLL_LINK_FLAGS_DEBUG ${NETBOX_DLL_LINK_FLAGS} /DEBUG)

elseif(CMAKE_COMPILER_IS_MINGW)
set(NETBOX_DLL_LINK_FLAGS )
Expand Down Expand Up @@ -2420,23 +2416,23 @@ file(GLOB DIST_FILES
${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt
)

add_custom_command(TARGET NetBox POST_BUILD
COMMAND ${CMAKE_COMMAND}
"-DFILE_NAME=NetBox.dll"
"-DFULL_FILE_NAME=$<TARGET_FILE_DIR:NetBox>/NetBox.dll"
"-DNETBOX_PLUGIN_DIR=${NETBOX_PLUGIN_DIR}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/copy_file.cmake"
VERBATIM
)
add_custom_command(TARGET NetBox POST_BUILD
COMMAND ${CMAKE_COMMAND}
"-DFILE_NAME=NetBox.pdb"
"-DFULL_FILE_NAME=$<TARGET_FILE_DIR:NetBox>/NetBox.pdb"
"-DNETBOX_PLUGIN_DIR=${NETBOX_PLUGIN_DIR}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/copy_file.cmake"
VERBATIM
set(NB_TARGET_FILES
NetBox.dll
NetBox.pdb
NetBox.map
)

foreach(NB_TARGET ${NB_TARGET_FILES})
add_custom_command(TARGET NetBox POST_BUILD
COMMAND ${CMAKE_COMMAND}
"-DFILE_NAME=${NB_TARGET}"
"-DFULL_FILE_NAME=$<TARGET_FILE_DIR:NetBox>//${NB_TARGET}"
"-DNETBOX_PLUGIN_DIR=${NETBOX_PLUGIN_DIR}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/copy_file.cmake"
VERBATIM
)
endforeach()

foreach(DIST_FILE ${DIST_FILES})
get_filename_component(FILE_NAME ${DIST_FILE} NAME)
add_custom_command(TARGET NetBox POST_BUILD
Expand All @@ -2452,22 +2448,17 @@ endif(OPT_CREATE_PLUGIN_DIR)

#-------------------------------------------------------------------------------
ucm_set_runtime(STATIC)
ucm_add_flags(CXX /EHsc)
#/Ob2 /GR
ucm_add_flags(CXX C /Gy /GS- /fp:fast /Oy /GA /GF /Gw /GL CONFIG Release)
#/O1 release min size
#/O2 release
#/Oy - omit frame pointers
#/Oi - enable intrinsic functions
#/RTC1 - Run-time error checks
ucm_add_flags(CXX C /Gm- -Ox -Oi -Os CONFIG Release)
ucm_add_flags(CXX /EHs)
# /O1 - minimize size, implies /Og /Oy /Ob2 /GF /Gy /Os
# /O2 - maximize speed, implies /Og /Oy /Ob2 /GF /Gy /Oi /Ot
# /Gw - Enables whole program global data optimization
# /GL - Enables whole program optimization
ucm_remove_flags(CXX C /Ob1 /Ob2 CONFIG Release MinSizeRel RelWithDebInfo)
ucm_add_flags(CXX C /fp:fast /Gw /GL CONFIG Release RelWithDebInfo MinSizeRel)
ucm_add_flags(CXX C /RTC1 /DDEBUG CONFIG Debug)
ucm_add_flags(CXX C /DDEBUG CONFIG RelWithDebInfo)
# ucm_add_flags(CXX /fsanitize=address CONFIG Debug) #/sdl
ucm_add_linker_flags(MODULE STATIC SHARED EXE /LTCG CONFIG Release)
ucm_add_linker_flags(MODULE SHARED ${NETBOX_DLL_LINK_FLAGS} /OPT:REF /OPT:ICF=6 /NXCOMPAT /DYNAMICBASE /MANIFEST:NO CONFIG Release)
ucm_add_linker_flags(MODULE SHARED ${NETBOX_DLL_LINK_FLAGS} CONFIG Debug)
ucm_add_linker_flags(MODULE SHARED EXE /DEBUG /MAP CONFIG Debug)
ucm_add_linker_flags(MODULE SHARED EXE /DEBUG /INCREMENTAL:NO CONFIG RelWithDebInfo)
ucm_add_linker_flags(MODULE SHARED ${NETBOX_DLL_LINK_FLAGS_RELEASE} CONFIG Release RelWithDebInfo MinSizeRel)
ucm_add_linker_flags(MODULE SHARED ${NETBOX_DLL_LINK_FLAGS_DEBUG} CONFIG Debug)
ucm_add_linker_flags(MODULE SHARED /DEBUG /MAP CONFIG RelWithDebInfo)
#ucm_print_flags()
#-------------------------------------------------------------------------------
38 changes: 35 additions & 3 deletions cmake/ucm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,38 @@ macro(ucm_set_flags)
ucm_add_flags(CLEAR_OLD ${ARGN})
endmacro()

# ucm_remove_flags
# Removes compiler flags from CMAKE_<LANG>_FLAGS or from a specific config
macro(ucm_remove_flags)
cmake_parse_arguments(ARG "C;CXX" "" "CONFIG" ${ARGN})

if(NOT ARG_CONFIG)
set(ARG_CONFIG " ")
endif()

foreach(CONFIG ${ARG_CONFIG})
# determine from which flags to remove
if(NOT ${CONFIG} STREQUAL " ")
string(TOUPPER ${CONFIG} CONFIG)
set(CXX_FLAGS CMAKE_CXX_FLAGS_${CONFIG})
set(C_FLAGS CMAKE_C_FLAGS_${CONFIG})
else()
set(CXX_FLAGS CMAKE_CXX_FLAGS)
set(C_FLAGS CMAKE_C_FLAGS)
endif()

# remove all the passed flags
foreach(flag ${ARG_UNPARSED_ARGUMENTS})
if("${ARG_CXX}" OR NOT "${ARG_C}")
string(REGEX REPLACE "${flag}" "" ${CXX_FLAGS} "${${CXX_FLAGS}}")
endif()
if("${ARG_C}" OR NOT "${ARG_CXX}")
string(REGEX REPLACE "${flag}" "" ${C_FLAGS} "${${C_FLAGS}}")
endif()
endforeach()
endforeach()
endmacro()

# ucm_add_linker_flags
# Adds linker flags to CMAKE_<TYPE>_LINKER_FLAGS or to a specific config
macro(ucm_add_linker_flags)
Expand Down Expand Up @@ -247,11 +279,11 @@ endmacro()
# Prints all compiler flags for all configurations
macro(ucm_print_flags)
ucm_gather_flags(1 flags_configs)
message("")
message(STATUS "")
foreach(flags ${flags_configs})
message("${flags}: ${${flags}}")
message(STATUS "${flags}: ${${flags}}")
endforeach()
message("")
message(STATUS "")
endmacro()

# ucm_count_sources
Expand Down
4 changes: 3 additions & 1 deletion src/core/SecureShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1794,8 +1794,10 @@ void TSecureShell::FreeBackend()
if (CheckHandle(FCallbackSet->ready_event))
{
CloseHandle(FCallbackSet->ready_event);
FCallbackSet->ready_event = INVALID_HANDLE_VALUE;
DeleteCriticalSection(FCallbackSet->ready_critsec);
}
memset(FCallbackSet.get(), 0, sizeof(callback_set));
FCallbackSet->ready_event = INVALID_HANDLE_VALUE;
}
}

Expand Down