Compare commits
	
		
			4 Commits
		
	
	
		
			feature/st
			...
			feature/no
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					f7031d0d3e | ||
| 
						 | 
					595e6c57df | ||
| 
						 | 
					87709c201e | ||
| 
						 | 
					e70d83ace1 | 
@@ -36,6 +36,8 @@ set( IXWEBSOCKET_SOURCES
 | 
			
		||||
    ixwebsocket/IXNetSystem.cpp
 | 
			
		||||
    ixwebsocket/IXSelectInterrupt.cpp
 | 
			
		||||
    ixwebsocket/IXSelectInterruptFactory.cpp
 | 
			
		||||
    ixwebsocket/IXSelectInterruptPipe.cpp
 | 
			
		||||
    ixwebsocket/IXSetThreadName.cpp
 | 
			
		||||
    ixwebsocket/IXSocket.cpp
 | 
			
		||||
    ixwebsocket/IXSocketConnect.cpp
 | 
			
		||||
    ixwebsocket/IXSocketFactory.cpp
 | 
			
		||||
@@ -69,6 +71,7 @@ set( IXWEBSOCKET_HEADERS
 | 
			
		||||
    ixwebsocket/IXProgressCallback.h
 | 
			
		||||
    ixwebsocket/IXSelectInterrupt.h
 | 
			
		||||
    ixwebsocket/IXSelectInterruptFactory.h
 | 
			
		||||
    ixwebsocket/IXSelectInterruptPipe.h
 | 
			
		||||
    ixwebsocket/IXSetThreadName.h
 | 
			
		||||
    ixwebsocket/IXSocket.h
 | 
			
		||||
    ixwebsocket/IXSocketConnect.h
 | 
			
		||||
@@ -99,23 +102,6 @@ set( IXWEBSOCKET_HEADERS
 | 
			
		||||
    ixwebsocket/IXWebSocketVersion.h
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
if (UNIX)
 | 
			
		||||
    # Linux, Mac, iOS, Android
 | 
			
		||||
    list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSelectInterruptPipe.cpp )
 | 
			
		||||
    list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSelectInterruptPipe.h )
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
# Platform specific code
 | 
			
		||||
if (APPLE)
 | 
			
		||||
    list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/apple/IXSetThreadName_apple.cpp)
 | 
			
		||||
elseif (WIN32)
 | 
			
		||||
    list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/windows/IXSetThreadName_windows.cpp)
 | 
			
		||||
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
 | 
			
		||||
    list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/freebsd/IXSetThreadName_freebsd.cpp)
 | 
			
		||||
else()
 | 
			
		||||
    list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/linux/IXSetThreadName_linux.cpp)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
option(USE_TLS "Enable TLS support" FALSE)
 | 
			
		||||
 | 
			
		||||
if (USE_TLS)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,14 @@
 | 
			
		||||
# Changelog
 | 
			
		||||
All changes to this project will be documented in this file.
 | 
			
		||||
 | 
			
		||||
## [9.9.2] - 2020-07-10
 | 
			
		||||
 | 
			
		||||
(socket server) bump default max connection count from 32 to 128
 | 
			
		||||
 | 
			
		||||
## [9.9.1] - 2020-07-10
 | 
			
		||||
 | 
			
		||||
(snake) implement super simple stream sql expression support in snake server
 | 
			
		||||
 | 
			
		||||
## [9.9.0] - 2020-07-08
 | 
			
		||||
 | 
			
		||||
(socket+websocket+http+redis+snake servers) expose the remote ip and remote port when a new connection is made
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,10 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// On macOS we use UNIX pipes to wake up select.
 | 
			
		||||
// On UNIX we use pipes to wake up select. There is no way to do that
 | 
			
		||||
// on Windows so this file is compiled out on Windows.
 | 
			
		||||
//
 | 
			
		||||
#ifndef _WIN32
 | 
			
		||||
 | 
			
		||||
#include "IXSelectInterruptPipe.h"
 | 
			
		||||
 | 
			
		||||
@@ -144,3 +146,5 @@ namespace ix
 | 
			
		||||
        return _fildes[kPipeReadIndex];
 | 
			
		||||
    }
 | 
			
		||||
} // namespace ix
 | 
			
		||||
 | 
			
		||||
#endif // !_WIN32
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										81
									
								
								ixwebsocket/IXSetThreadName.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								ixwebsocket/IXSetThreadName.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,81 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  IXSetThreadName.cpp
 | 
			
		||||
 *  Author: Benjamin Sergeant
 | 
			
		||||
 *  Copyright (c) 2018 2020 Machine Zone, Inc. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "IXSetThreadName.h"
 | 
			
		||||
 | 
			
		||||
// unix systems
 | 
			
		||||
#if defined(__APPLE__) || defined(__linux__) || defined(BSD)
 | 
			
		||||
# include <pthread.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// freebsd needs this header as well
 | 
			
		||||
#if defined(BSD)
 | 
			
		||||
# include <pthread_np.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// Windows
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
# include <Windows.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
namespace ix
 | 
			
		||||
{
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
    const DWORD MS_VC_EXCEPTION = 0x406D1388;
 | 
			
		||||
 | 
			
		||||
#pragma pack(push, 8)
 | 
			
		||||
    typedef struct tagTHREADNAME_INFO
 | 
			
		||||
    {
 | 
			
		||||
        DWORD dwType;     // Must be 0x1000.
 | 
			
		||||
        LPCSTR szName;    // Pointer to name (in user addr space).
 | 
			
		||||
        DWORD dwThreadID; // Thread ID (-1=caller thread).
 | 
			
		||||
        DWORD dwFlags;    // Reserved for future use, must be zero.
 | 
			
		||||
    } THREADNAME_INFO;
 | 
			
		||||
#pragma pack(pop)
 | 
			
		||||
 | 
			
		||||
    void SetThreadName(DWORD dwThreadID, const char* threadName)
 | 
			
		||||
    {
 | 
			
		||||
        THREADNAME_INFO info;
 | 
			
		||||
        info.dwType = 0x1000;
 | 
			
		||||
        info.szName = threadName;
 | 
			
		||||
        info.dwThreadID = dwThreadID;
 | 
			
		||||
        info.dwFlags = 0;
 | 
			
		||||
 | 
			
		||||
        __try
 | 
			
		||||
        {
 | 
			
		||||
            RaiseException(
 | 
			
		||||
                MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*) &info);
 | 
			
		||||
        }
 | 
			
		||||
        __except (EXCEPTION_EXECUTE_HANDLER)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    void setThreadName(const std::string& name)
 | 
			
		||||
    {
 | 
			
		||||
#if defined(__APPLE__)
 | 
			
		||||
        //
 | 
			
		||||
        // Apple reserves 16 bytes for its thread names
 | 
			
		||||
        // Notice that the Apple version of pthread_setname_np
 | 
			
		||||
        // does not take a pthread_t argument
 | 
			
		||||
        //
 | 
			
		||||
        pthread_setname_np(name.substr(0, 63).c_str());
 | 
			
		||||
#elif defined(__linux__)
 | 
			
		||||
        //
 | 
			
		||||
        // Linux only reserves 16 bytes for its thread names
 | 
			
		||||
        // See prctl and PR_SET_NAME property in
 | 
			
		||||
        // http://man7.org/linux/man-pages/man2/prctl.2.html
 | 
			
		||||
        //
 | 
			
		||||
        pthread_setname_np(pthread_self(), name.substr(0, 15).c_str());
 | 
			
		||||
#elif defined(_WIN32)
 | 
			
		||||
        SetThreadName(-1, name.c_str());
 | 
			
		||||
#elif defined(BSD)
 | 
			
		||||
        pthread_set_name_np(pthread_self(), name.substr(0, 15).c_str());
 | 
			
		||||
#else
 | 
			
		||||
        // ... assert here ?
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
} // namespace ix
 | 
			
		||||
@@ -22,7 +22,7 @@ namespace ix
 | 
			
		||||
    const int SocketServer::kDefaultPort(8080);
 | 
			
		||||
    const std::string SocketServer::kDefaultHost("127.0.0.1");
 | 
			
		||||
    const int SocketServer::kDefaultTcpBacklog(5);
 | 
			
		||||
    const size_t SocketServer::kDefaultMaxConnections(32);
 | 
			
		||||
    const size_t SocketServer::kDefaultMaxConnections(128);
 | 
			
		||||
    const int SocketServer::kDefaultAddressFamily(AF_INET);
 | 
			
		||||
 | 
			
		||||
    SocketServer::SocketServer(
 | 
			
		||||
 
 | 
			
		||||
@@ -6,4 +6,4 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#define IX_WEBSOCKET_VERSION "9.9.0"
 | 
			
		||||
#define IX_WEBSOCKET_VERSION "9.9.2"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,20 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  IXSetThreadName_apple.cpp
 | 
			
		||||
 *  Author: Benjamin Sergeant
 | 
			
		||||
 *  Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "../IXSetThreadName.h"
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
 | 
			
		||||
namespace ix
 | 
			
		||||
{
 | 
			
		||||
    void setThreadName(const std::string& name)
 | 
			
		||||
    {
 | 
			
		||||
        //
 | 
			
		||||
        // Apple reserves 16 bytes for its thread names
 | 
			
		||||
        // Notice that the Apple version of pthread_setname_np
 | 
			
		||||
        // does not take a pthread_t argument
 | 
			
		||||
        //
 | 
			
		||||
        pthread_setname_np(name.substr(0, 63).c_str());
 | 
			
		||||
    }
 | 
			
		||||
} // namespace ix
 | 
			
		||||
@@ -1,16 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  IXSetThreadName_freebsd.cpp
 | 
			
		||||
 *  Author: Benjamin Sergeant
 | 
			
		||||
 *  Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "../IXSetThreadName.h"
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
#include <pthread_np.h>
 | 
			
		||||
 | 
			
		||||
namespace ix
 | 
			
		||||
{
 | 
			
		||||
    void setThreadName(const std::string& name)
 | 
			
		||||
    {
 | 
			
		||||
        pthread_set_name_np(pthread_self(), name.substr(0, 15).c_str());
 | 
			
		||||
    }
 | 
			
		||||
} // namespace ix
 | 
			
		||||
@@ -1,20 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  IXSetThreadName_linux.cpp
 | 
			
		||||
 *  Author: Benjamin Sergeant
 | 
			
		||||
 *  Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "../IXSetThreadName.h"
 | 
			
		||||
#include <pthread.h>
 | 
			
		||||
 | 
			
		||||
namespace ix
 | 
			
		||||
{
 | 
			
		||||
    void setThreadName(const std::string& name)
 | 
			
		||||
    {
 | 
			
		||||
        //
 | 
			
		||||
        // Linux only reserves 16 bytes for its thread names
 | 
			
		||||
        // See prctl and PR_SET_NAME property in
 | 
			
		||||
        // http://man7.org/linux/man-pages/man2/prctl.2.html
 | 
			
		||||
        //
 | 
			
		||||
        pthread_setname_np(pthread_self(), name.substr(0, 15).c_str());
 | 
			
		||||
    }
 | 
			
		||||
} // namespace ix
 | 
			
		||||
@@ -1,46 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 *  IXSetThreadName_windows.cpp
 | 
			
		||||
 *  Author: Benjamin Sergeant
 | 
			
		||||
 *  Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
 | 
			
		||||
 */
 | 
			
		||||
#include "../IXSetThreadName.h"
 | 
			
		||||
 | 
			
		||||
#include <Windows.h>
 | 
			
		||||
 | 
			
		||||
namespace ix
 | 
			
		||||
{
 | 
			
		||||
    const DWORD MS_VC_EXCEPTION = 0x406D1388;
 | 
			
		||||
 | 
			
		||||
#pragma pack(push, 8)
 | 
			
		||||
    typedef struct tagTHREADNAME_INFO
 | 
			
		||||
    {
 | 
			
		||||
        DWORD dwType;     // Must be 0x1000.
 | 
			
		||||
        LPCSTR szName;    // Pointer to name (in user addr space).
 | 
			
		||||
        DWORD dwThreadID; // Thread ID (-1=caller thread).
 | 
			
		||||
        DWORD dwFlags;    // Reserved for future use, must be zero.
 | 
			
		||||
    } THREADNAME_INFO;
 | 
			
		||||
#pragma pack(pop)
 | 
			
		||||
 | 
			
		||||
    void SetThreadName(DWORD dwThreadID, const char* threadName)
 | 
			
		||||
    {
 | 
			
		||||
        THREADNAME_INFO info;
 | 
			
		||||
        info.dwType = 0x1000;
 | 
			
		||||
        info.szName = threadName;
 | 
			
		||||
        info.dwThreadID = dwThreadID;
 | 
			
		||||
        info.dwFlags = 0;
 | 
			
		||||
 | 
			
		||||
        __try
 | 
			
		||||
        {
 | 
			
		||||
            RaiseException(
 | 
			
		||||
                MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*) &info);
 | 
			
		||||
        }
 | 
			
		||||
        __except (EXCEPTION_EXECUTE_HANDLER)
 | 
			
		||||
        {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void setThreadName(const std::string& name)
 | 
			
		||||
    {
 | 
			
		||||
        SetThreadName(-1, name.c_str());
 | 
			
		||||
    }
 | 
			
		||||
} // namespace ix
 | 
			
		||||
		Reference in New Issue
	
	Block a user