Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F1842388
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/common/ipc_common.c b/lib/common/ipc_common.c
index 78fedbdd61..d0c06365cd 100644
--- a/lib/common/ipc_common.c
+++ b/lib/common/ipc_common.c
@@ -1,104 +1,110 @@
/*
- * Copyright 2004-2020 the Pacemaker project contributors
+ * Copyright 2004-2021 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU Lesser General Public License
* version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
*/
#include <crm_internal.h>
#include <stdio.h>
#include <stdint.h> // uint64_t
#include <sys/types.h>
#include <crm/msg_xml.h>
#include "crmcommon_private.h"
#define MIN_MSG_SIZE 12336 // sizeof(struct qb_ipc_connection_response)
#define MAX_MSG_SIZE 128*1024 // 128k default
/*!
* \internal
* \brief Choose an IPC buffer size in bytes
*
* \param[in] max Use this value if environment/default is lower
*
* \return Maximum of max and value of PCMK_ipc_buffer (default 128KB)
*/
unsigned int
pcmk__ipc_buffer_size(unsigned int max)
{
static unsigned int global_max = 0;
if (global_max == 0) {
- const char *env = getenv("PCMK_ipc_buffer");
+ long long global_ll;
- if (env) {
- int env_max = crm_parse_int(env, "0");
+ if ((pcmk__scan_ll(getenv("PCMK_ipc_buffer"), &global_ll,
+ 0LL) != pcmk_rc_ok)
+ || (global_ll <= 0)) {
+ global_max = MAX_MSG_SIZE; // Default for unset or invalid
- global_max = (env_max > 0)? QB_MAX(MIN_MSG_SIZE, env_max) : MAX_MSG_SIZE;
+ } else if (global_ll < MIN_MSG_SIZE) {
+ global_max = MIN_MSG_SIZE;
+
+ } else if (global_ll > UINT_MAX) {
+ global_max = UINT_MAX;
} else {
- global_max = MAX_MSG_SIZE;
+ global_max = (unsigned int) global_ll;
}
}
return QB_MAX(max, global_max);
}
/*!
* \brief Return pacemaker's default IPC buffer size
*
* \return IPC buffer size in bytes
*/
unsigned int
crm_ipc_default_buffer_size(void)
{
static unsigned int default_size = 0;
if (default_size == 0) {
default_size = pcmk__ipc_buffer_size(0);
}
return default_size;
}
/*!
* \internal
* \brief Check whether an IPC header is valid
*
* \param[in] header IPC header to check
*
* \return true if IPC header has a supported version, false otherwise
*/
bool
pcmk__valid_ipc_header(const pcmk__ipc_header_t *header)
{
if (header == NULL) {
crm_err("IPC message without header");
return false;
} else if (header->version > PCMK__IPC_VERSION) {
crm_err("Filtering incompatible v%d IPC message (only versions <= %d supported)",
header->version, PCMK__IPC_VERSION);
return false;
}
return true;
}
const char *
pcmk__client_type_str(uint64_t client_type)
{
switch (client_type) {
case pcmk__client_ipc:
return "IPC";
case pcmk__client_tcp:
return "TCP";
#ifdef HAVE_GNUTLS_GNUTLS_H
case pcmk__client_tls:
return "TLS";
#endif
default:
return "unknown";
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 23, 4:33 PM (17 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1018905
Default Alt Text
(3 KB)
Attached To
Mode
rP Pacemaker
Attached
Detach File
Event Timeline
Log In to Comment