mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
Merge pull request #11855 from akallabeth/threadpool
[winpr,threadpool] default minimum thread count
This commit is contained in:
@@ -1455,11 +1455,31 @@ freerdp_peer* freerdp_peer_new(int sockfd)
|
||||
|
||||
if (sockfd >= 0)
|
||||
{
|
||||
if (setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (void*)&option_value, option_len) < 0)
|
||||
int type = -1;
|
||||
socklen_t typelen = sizeof(type);
|
||||
const int rc = getsockopt(sockfd, SOL_SOCKET, SO_TYPE, &type, &typelen);
|
||||
if (rc < 0)
|
||||
{
|
||||
/* local unix sockets don't have the TCP_NODELAY implemented, so don't make this
|
||||
* error fatal */
|
||||
WLog_DBG(TAG, "can't set TCP_NODELAY, continuing anyway");
|
||||
char buffer[128] = { 0 };
|
||||
WLog_DBG(TAG, "can't get SOL_SOCKET|SO_TYPE, continuing anyway (%s)",
|
||||
winpr_strerror(errno, buffer, sizeof(buffer)));
|
||||
}
|
||||
else if (type == SOCK_STREAM)
|
||||
{
|
||||
const int sr =
|
||||
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (void*)&option_value, option_len);
|
||||
if (sr < 0)
|
||||
{
|
||||
/* local unix sockets don't have the TCP_NODELAY implemented, so don't make this
|
||||
* error fatal */
|
||||
char buffer[128] = { 0 };
|
||||
WLog_DBG(TAG, "can't set TCP_NODELAY, continuing anyway (%s)",
|
||||
winpr_strerror(errno, buffer, sizeof(buffer)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WLog_DBG(TAG, "Socket SOL_SOCKET|SO_TYPE %d unsupported, continuing anyway", type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
set(WINPR_THREADPOOL_DEFAULT_MAX_COUNT "16" CACHE STRING "The maximum (default) number of threads in a pool")
|
||||
set(WINPR_THREADPOOL_DEFAULT_MIN_COUNT "4" CACHE STRING "The minimum (default) number of threads in a pool")
|
||||
winpr_definition_add(WINPR_THREADPOOL_DEFAULT_MAX_COUNT=${WINPR_THREADPOOL_DEFAULT_MAX_COUNT})
|
||||
winpr_definition_add(WINPR_THREADPOOL_DEFAULT_MIN_COUNT=${WINPR_THREADPOOL_DEFAULT_MIN_COUNT})
|
||||
winpr_module_add(
|
||||
synch.c
|
||||
work.c
|
||||
|
||||
@@ -127,10 +127,15 @@ static BOOL InitializeThreadpool(PTP_POOL pool)
|
||||
obj = ArrayList_Object(pool->Threads);
|
||||
obj->fnObjectFree = threads_close;
|
||||
|
||||
#if !defined(WINPR_THREADPOOL_DEFAULT_MIN_COUNT)
|
||||
#error "WINPR_THREADPOOL_DEFAULT_MIN_COUNT must be defined"
|
||||
#endif
|
||||
|
||||
SYSTEM_INFO info = { 0 };
|
||||
GetSystemInfo(&info);
|
||||
if (info.dwNumberOfProcessors < 1)
|
||||
info.dwNumberOfProcessors = 1;
|
||||
if (info.dwNumberOfProcessors < WINPR_THREADPOOL_DEFAULT_MIN_COUNT)
|
||||
info.dwNumberOfProcessors = WINPR_THREADPOOL_DEFAULT_MIN_COUNT;
|
||||
|
||||
if (!SetThreadpoolThreadMinimum(pool, info.dwNumberOfProcessors))
|
||||
goto fail;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user