Formatting: Spacing consistency

This commit is contained in:
Roger A. Light
2025-09-17 12:03:06 +01:00
parent 67ad22df0a
commit d743413ac3
73 changed files with 302 additions and 267 deletions
+3 -3
View File
@@ -177,7 +177,7 @@ static int dump__client_chunk_process(FILE *db_fd, uint32_t length)
if(do_json){
json_add_client(&chunk);
}
if(do_print) {
if(do_print){
print__client(&chunk, length);
}
free__client(&chunk);
@@ -222,7 +222,7 @@ static int dump__client_msg_chunk_process(FILE *db_fd, uint32_t length)
if(do_json){
json_add_client_msg(&chunk);
}
if(do_print) {
if(do_print){
print__client_msg(&chunk, length);
}
free__client_msg(&chunk);
@@ -381,7 +381,7 @@ static int dump__sub_chunk_process(FILE *db_fd, uint32_t length)
if(do_json){
json_add_subscription(&chunk);
}
if(do_print) {
if(do_print){
print__sub(&chunk, length);
}
free__sub(&chunk);
+1
View File
@@ -30,6 +30,7 @@ Contributors:
static struct completion_tree_root *commands_broker = NULL;
static void command_tree_create(void)
{
struct completion_tree_cmd *cmd;
+1
View File
@@ -72,6 +72,7 @@ int ctrl_shell__connect(void)
return 0;
}
void ctrl_shell__disconnect(void)
{
if(!data.mosq) return;
@@ -26,6 +26,7 @@ Contributors:
#define UNUSED(A) (void)(A)
void completion_tree_arg_list_args_free(struct completion_tree_arg_list *arg_list)
{
struct completion_tree_arg *arg, *next;
@@ -101,6 +102,7 @@ struct completion_tree_arg_list *completion_tree_cmd_new_arg_list(void)
return calloc(1, sizeof(struct completion_tree_arg_list));
}
void completion_tree_cmd_append_arg_list(struct completion_tree_cmd *cmd, struct completion_tree_arg_list *new_list)
{
struct completion_tree_arg_list **arg_list;
@@ -127,6 +129,7 @@ struct completion_tree_arg_list *completion_tree_cmd_add_arg_list(struct complet
return new_list;
}
void completion_tree_arg_list_add_arg(struct completion_tree_arg_list *arg_list, const char *name)
{
if(!arg_list || !name) return;
+1 -1
View File
@@ -773,7 +773,7 @@ static void print_json_array(cJSON *j_list, const char *label, const char *eleme
ctrl_shell_print_value(1, "%s", stmp);
if(optional_element_name){
ctrl_shell_print_value(0, " (%s: ", optional_element_name);
print_json_value(cJSON_GetObjectItem(j_elem,optional_element_name),optional_element_null_value);
print_json_value(cJSON_GetObjectItem(j_elem, optional_element_name), optional_element_null_value);
ctrl_shell_print_value(0, ")");
}
}else if(cJSON_IsString(j_elem) && j_elem->valuestring){
+4 -4
View File
@@ -137,11 +137,11 @@ static void line_callback(char *line)
}else if(!strcasecmp(command, "connect")){
char *url = strtok_r(NULL, " ", &saveptr);
if(url){
if(!strncasecmp(url, "mqtt://", 7)) {
if(!strncasecmp(url, "mqtt://", 7)){
url += 7;
data.port = 1883;
data.url_scheme = "mqtt";
} else if(!strncasecmp(url, "mqtts://", 8)) {
}else if(!strncasecmp(url, "mqtts://", 8)){
#ifdef WITH_TLS
url += 8;
data.port = 8883;
@@ -151,12 +151,12 @@ static void line_callback(char *line)
free(line);
return;
#endif
} else if(!strncasecmp(url, "ws://", 5)) {
}else if(!strncasecmp(url, "ws://", 5)){
url += 5;
data.port = 1883;
data.transport = MOSQ_T_WEBSOCKETS;
data.url_scheme = "ws";
} else if(!strncasecmp(url, "wss://", 6)) {
}else if(!strncasecmp(url, "wss://", 6)){
#ifdef WITH_TLS
url += 6;
data.port = 8883;
+4 -3
View File
@@ -146,7 +146,7 @@ static void print_json_value(cJSON *value, const char *null_value)
printf("%s", buffer);
}
}else if(null_value){
printf("%s",null_value);
printf("%s", null_value);
}
}
@@ -166,7 +166,7 @@ static void print_json_array(cJSON *j_list, int slen, const char *label, const c
printf("%-*s %s", (int)slen, label, stmp);
if(optional_element_name){
printf(" (%s: ", optional_element_name);
print_json_value(cJSON_GetObjectItem(j_elem,optional_element_name),optional_element_null_value);
print_json_value(cJSON_GetObjectItem(j_elem, optional_element_name), optional_element_null_value);
printf(")");
}
}else if(cJSON_IsString(j_elem) && j_elem->valuestring){
@@ -184,7 +184,7 @@ static void print_json_array(cJSON *j_list, int slen, const char *label, const c
static void print_client(cJSON *j_response)
{
cJSON *j_data, *j_client, *jtmp;
const int label_width = strlen( "Connections:");
const int label_width = strlen("Connections:");
j_data = cJSON_GetObjectItem(j_response, "data");
if(j_data == NULL || !cJSON_IsObject(j_data)){
@@ -514,6 +514,7 @@ static int dynsec__get_default_acl_access(int argc, char *argv[], cJSON *j_comma
* #
* ################################################################ */
static cJSON *init_add_acl_to_role(cJSON *j_acls, const char *type, const char *topic)
{
cJSON *j_acl;
+9 -9
View File
@@ -248,19 +248,19 @@ static int client_config_line_proc(struct mosq_config *cfg, int *argc, char **ar
if((*argc) == 1){
fprintf(stderr, "Error: -L argument given but no URL specified.\n\n");
return 1;
} else {
}else{
char *url = argv[1];
char *topic;
char *tmp;
if(!strncasecmp(url, "mqtt://", 7)) {
if(!strncasecmp(url, "mqtt://", 7)){
url += 7;
cfg->port = 1883;
} else if(!strncasecmp(url, "mqtts://", 8)) {
}else if(!strncasecmp(url, "mqtts://", 8)){
url += 8;
cfg->port = 8883;
cfg->tls_use_os_certs = true;
} else {
}else{
fprintf(stderr, "Error: Unsupported URL scheme.\n\n");
return 1;
}
@@ -272,10 +272,10 @@ static int client_config_line_proc(struct mosq_config *cfg, int *argc, char **ar
*topic++ = 0;
tmp = strchr(url, '@');
if(tmp) {
if(tmp){
*tmp++ = 0;
char *colon = strchr(url, ':');
if(colon) {
if(colon){
*colon = 0;
cfg->password = strdup(colon + 1);
}
@@ -289,7 +289,7 @@ static int client_config_line_proc(struct mosq_config *cfg, int *argc, char **ar
cfg->host = url;
tmp = strchr(url, ':');
if(tmp) {
if(tmp){
*tmp++ = 0;
if(strlen(tmp) == 0){
cfg->host = NULL; /* Prevent free of non-heap memory later */
@@ -474,7 +474,7 @@ static int client_config_line_proc(struct mosq_config *cfg, int *argc, char **ar
return MOSQ_ERR_SUCCESS;
unknown_option:
fprintf(stderr, "Error: Unknown option '%s'.\n",argv[0]);
fprintf(stderr, "Error: Unknown option '%s'.\n", argv[0]);
return 1;
}
@@ -631,7 +631,7 @@ int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg)
return 1;
}
# ifdef FINAL_WITH_TLS_PSK
}else if (cfg->psk){
}else if(cfg->psk){
if(mosquitto_tls_psk_set(mosq, cfg->psk, cfg->psk_identity, NULL)){
fprintf(stderr, "Error: Problem setting TLS-PSK options.\n");
mosquitto_lib_cleanup();
+14 -13
View File
@@ -757,15 +757,15 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
if(i==argc-1){
fprintf(stderr, "Error: -L argument given but no URL specified.\n\n");
return 1;
} else {
}else{
char *url = argv[i+1];
char *topic;
char *tmp;
if(!strncasecmp(url, "mqtt://", 7)) {
if(!strncasecmp(url, "mqtt://", 7)){
url += 7;
cfg->port = 1883;
} else if(!strncasecmp(url, "mqtts://", 8)) {
}else if(!strncasecmp(url, "mqtts://", 8)){
#ifdef WITH_TLS
url += 8;
cfg->port = 8883;
@@ -774,11 +774,11 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
fprintf(stderr, "Error: TLS support not available.\n\n");
return 1;
#endif
} else if(!strncasecmp(url, "ws://", 5)) {
}else if(!strncasecmp(url, "ws://", 5)){
url += 5;
cfg->port = 1883;
cfg->transport = MOSQ_T_WEBSOCKETS;
} else if(!strncasecmp(url, "wss://", 6)) {
}else if(!strncasecmp(url, "wss://", 6)){
#ifdef WITH_TLS
url += 6;
cfg->port = 8883;
@@ -788,7 +788,7 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
fprintf(stderr, "Error: TLS support not available.\n\n");
return 1;
#endif
} else {
}else{
fprintf(stderr, "Error: Unsupported URL scheme.\n\n");
return 1;
}
@@ -803,11 +803,11 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
return 1;
tmp = strchr(url, '@');
if(tmp) {
if(tmp){
char *colon;
*tmp++ = 0;
colon = strchr(url, ':');
if(colon) {
if(colon){
*colon = 0;
cfg->password = strdup(colon + 1);
}
@@ -817,7 +817,7 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
cfg->host = url;
tmp = strchr(url, ':');
if(tmp) {
if(tmp){
*tmp++ = 0;
cfg->port = atoi(tmp);
}
@@ -1052,11 +1052,11 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
fprintf(stderr, "Error: --retain-handling argument given but no option specified.\n\n");
return 1;
}else{
if(!strcmp(argv[i+1],"always")){
if(!strcmp(argv[i+1], "always")){
MQTT_SUB_OPT_SET_RETAIN_HANDLING(cfg->sub_opts, MQTT_SUB_OPT_SEND_RETAIN_ALWAYS);
}else if(!strcmp(argv[i+1],"new")){
}else if(!strcmp(argv[i+1], "new")){
MQTT_SUB_OPT_SET_RETAIN_HANDLING(cfg->sub_opts, MQTT_SUB_OPT_SEND_RETAIN_NEW);
}else if(!strcmp(argv[i+1],"never")){
}else if(!strcmp(argv[i+1], "never")){
MQTT_SUB_OPT_SET_RETAIN_HANDLING(cfg->sub_opts, MQTT_SUB_OPT_SEND_RETAIN_NEVER);
}else{
fprintf(stderr, "Error: Unknown value '%s' for --retain-handling.\n\n", argv[i+1]);
@@ -1330,7 +1330,7 @@ int client_config_line_proc(struct mosq_config *cfg, int pub_or_sub, int argc, c
return MOSQ_ERR_SUCCESS;
unknown_option:
fprintf(stderr, "Error: Unknown option '%s'.\n",argv[i]);
fprintf(stderr, "Error: Unknown option '%s'.\n", argv[i]);
return 1;
}
@@ -1769,6 +1769,7 @@ cleanup:
}
#endif
void err_printf(const struct mosq_config *cfg, const char *fmt, ...)
{
va_list va;
+5 -4
View File
@@ -51,16 +51,17 @@ static HANDLE timeout_h = NULL;
#endif
#ifdef WIN32
void CALLBACK timeout_cb(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
{
UNUSED(lpParameter);
UNUSED(TimerOrWaitFired);
if (connack_received) {
if(connack_received){
process_messages = false;
mosquitto_disconnect_v5(g_mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
}
else {
}else{
exit(-1);
}
@@ -464,7 +465,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
Sleep(1000);
#else
struct timespec ts = {1,0};
struct timespec ts = {1, 0};
nanosleep(&ts, NULL);
#endif
int message_count = message_rate_msg_count;
+1 -1
View File
@@ -734,7 +734,7 @@ static void formatted_print(const struct mosq_config *lcfg, const struct mosquit
}
}
char strf[3] = {0, 0 ,0};
char strf[3] = {0, 0, 0};
strf[0] = '%';
strf[1] = lcfg->format[i];
strf[2] = 0;
+2
View File
@@ -34,11 +34,13 @@ int mosquitto_unsubscribe(struct mosquitto *mosq, int *mid, const char *sub)
return mosquitto_unsubscribe_multiple(mosq, mid, 1, (char *const *const)&sub, NULL);
}
int mosquitto_unsubscribe_v5(struct mosquitto *mosq, int *mid, const char *sub, const mosquitto_property *properties)
{
return mosquitto_unsubscribe_multiple(mosq, mid, 1, (char *const *const)&sub, properties);
}
int mosquitto_unsubscribe_multiple(struct mosquitto *mosq, int *mid, int sub_count, char *const *const sub, const mosquitto_property *properties)
{
const mosquitto_property *outgoing_properties = NULL;
+7 -5
View File
@@ -43,6 +43,7 @@ static unsigned int init_refcount = 0;
void mosquitto__destroy(struct mosquitto *mosq);
int mosquitto_lib_version(int *major, int *minor, int *revision)
{
if(major) *major = LIBMOSQUITTO_MAJOR;
@@ -51,18 +52,19 @@ int mosquitto_lib_version(int *major, int *minor, int *revision)
return LIBMOSQUITTO_VERSION_NUMBER;
}
int mosquitto_lib_init(void)
{
int rc;
if (init_refcount == 0) {
if(init_refcount == 0){
mosquitto_time_init();
#ifdef WIN32
srand((unsigned int)GetTickCount64());
#elif _POSIX_TIMERS>0 && defined(_POSIX_MONOTONIC_CLOCK)
struct timespec tp;
#ifdef CLOCK_BOOTTIME
if (clock_gettime(CLOCK_BOOTTIME, &tp) != 0)
if(clock_gettime(CLOCK_BOOTTIME, &tp) != 0)
#endif
clock_gettime(CLOCK_MONOTONIC, &tp);
srand((unsigned int)tp.tv_nsec);
@@ -79,7 +81,7 @@ int mosquitto_lib_init(void)
#endif
rc = net__init();
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
return rc;
}
}
@@ -91,11 +93,11 @@ int mosquitto_lib_init(void)
int mosquitto_lib_cleanup(void)
{
if (init_refcount == 1) {
if(init_refcount == 1){
net__cleanup();
}
if (init_refcount > 0) {
if(init_refcount > 0){
--init_refcount;
}
+2 -1
View File
@@ -29,6 +29,7 @@ Contributors:
#include "send_mosq.h"
#include "util_mosq.h"
void message__cleanup(struct mosquitto_message_all **message)
{
struct mosquitto_message_all *msg;
@@ -172,7 +173,7 @@ void message__reconnect_reset(struct mosquitto *mosq, bool update_quota_only)
if(mosq->msgs_out.inflight_quota != 0){
util__decrement_send_quota(mosq);
if (update_quota_only == false){
if(update_quota_only == false){
if(message->msg.qos == 1){
message->state = mosq_ms_publish_qos1;
}else if(message->msg.qos == 2){
+13 -15
View File
@@ -142,7 +142,7 @@ int net__init(void)
{
#ifdef WIN32
WSADATA wsaData;
if(WSAStartup(MAKEWORD(2,2), &wsaData) != 0){
if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0){
return MOSQ_ERR_UNKNOWN;
}
#endif
@@ -233,8 +233,7 @@ int net__socket_close(struct mosquitto *mosq)
#endif
#if defined(WITH_BROKER) && defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS
if(mosq->wsi)
{
if(mosq->wsi){
if(mosq->state != mosq_cs_disconnecting){
mosquitto__set_state(mosq, mosq_cs_disconnect_ws);
}
@@ -301,7 +300,7 @@ static unsigned int psk_client_callback(SSL *ssl, const char *hint,
snprintf(identity, max_identity_len, "%s", mosq->tls_psk_identity);
len = mosquitto__hex2bin(mosq->tls_psk, psk, (int)max_psk_len);
if (len < 0) return 0;
if(len < 0) return 0;
return (unsigned int)len;
}
#endif
@@ -586,17 +585,17 @@ int net__socket_connect_tls(struct mosquitto *mosq)
long res;
ERR_clear_error();
if (mosq->tls_ocsp_required) {
if(mosq->tls_ocsp_required){
/* Note: OCSP is available in all currently supported OpenSSL versions. */
if ((res=SSL_set_tlsext_status_type(mosq->ssl, TLSEXT_STATUSTYPE_ocsp)) != 1) {
if((res=SSL_set_tlsext_status_type(mosq->ssl, TLSEXT_STATUSTYPE_ocsp)) != 1){
log__printf(mosq, MOSQ_LOG_ERR, "Could not activate OCSP (error: %ld)", res);
return MOSQ_ERR_OCSP;
}
if ((res=SSL_CTX_set_tlsext_status_cb(mosq->ssl_ctx, mosquitto__verify_ocsp_status_cb)) != 1) {
if((res=SSL_CTX_set_tlsext_status_cb(mosq->ssl_ctx, mosquitto__verify_ocsp_status_cb)) != 1){
log__printf(mosq, MOSQ_LOG_ERR, "Could not activate OCSP (error: %ld)", res);
return MOSQ_ERR_OCSP;
}
if ((res=SSL_CTX_set_tlsext_status_arg(mosq->ssl_ctx, mosq)) != 1) {
if((res=SSL_CTX_set_tlsext_status_arg(mosq->ssl_ctx, mosq)) != 1){
log__printf(mosq, MOSQ_LOG_ERR, "Could not activate OCSP (error: %ld)", res);
return MOSQ_ERR_OCSP;
}
@@ -733,8 +732,8 @@ static int net__init_ssl_ctx(struct mosquitto *mosq)
SSL_CTX_set_options(mosq->ssl_ctx, SSL_OP_NO_COMPRESSION);
/* Set ALPN */
if(mosq->tls_alpn) {
tls_alpn_len = (uint8_t) strnlen(mosq->tls_alpn, 254);
if(mosq->tls_alpn){
tls_alpn_len = (uint8_t)strnlen(mosq->tls_alpn, 254);
tls_alpn_wire[0] = tls_alpn_len; /* first byte is length of string */
memcpy(tls_alpn_wire + 1, mosq->tls_alpn, tls_alpn_len);
SSL_CTX_set_alpn_protos(mosq->ssl_ctx, tls_alpn_wire, tls_alpn_len + 1U);
@@ -924,7 +923,7 @@ int net__socket_connect_step3(struct mosquitto *mosq, const char *host)
/*
* required for the SNI resolving
*/
if(SSL_set_tlsext_host_name(mosq->ssl, host) != 1) {
if(SSL_set_tlsext_host_name(mosq->ssl, host) != 1){
net__socket_close(mosq);
return MOSQ_ERR_TLS;
}
@@ -958,7 +957,7 @@ int net__socket_connect(struct mosquitto *mosq, const char *host, uint16_t port,
if(mosq->tcp_nodelay && port){
int flag = 1;
if(setsockopt(mosq->sock, IPPROTO_TCP, TCP_NODELAY, (const void*)&flag, sizeof(int)) != 0){
if(setsockopt(mosq->sock, IPPROTO_TCP, TCP_NODELAY, (const void *)&flag, sizeof(int)) != 0){
log__printf(mosq, MOSQ_LOG_WARNING, "Warning: Unable to set TCP_NODELAY.");
}
}
@@ -983,10 +982,9 @@ static void net__handle_ssl(struct mosquitto *mosq, int ret)
int err;
err = SSL_get_error(mosq->ssl, ret);
if (err == SSL_ERROR_WANT_READ) {
if(err == SSL_ERROR_WANT_READ){
errno = EAGAIN;
}
else if (err == SSL_ERROR_WANT_WRITE) {
}else if(err == SSL_ERROR_WANT_WRITE){
#ifdef WITH_BROKER
mux__add_out(mosq);
#else
+13 -13
View File
@@ -75,33 +75,33 @@ int mosquitto__verify_ocsp_status_cb(SSL *ssl, void *arg)
/* the following functions expect a const pointer */
cp = (const unsigned char *)p;
if (!cp || len <= 0) {
if(!cp || len <= 0){
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: no response");
goto end;
}
rsp = d2i_OCSP_RESPONSE(NULL, &cp, len);
if (rsp==NULL) {
if(rsp==NULL){
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: invalid response");
goto end;
}
ocsp_status = OCSP_response_status(rsp);
if(ocsp_status != OCSP_RESPONSE_STATUS_SUCCESSFUL) {
if(ocsp_status != OCSP_RESPONSE_STATUS_SUCCESSFUL){
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: invalid status: %s (%d)",
OCSP_response_status_str(ocsp_status), ocsp_status);
goto end;
}
br = OCSP_response_get1_basic(rsp);
if (!br) {
if(!br){
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: invalid response");
goto end;
}
ch = SSL_get_peer_cert_chain(mosq->ssl);
if (sk_X509_num(ch) <= 0) {
if(sk_X509_num(ch) <= 0){
log__printf(mosq, MOSQ_LOG_ERR, "OCSP: we did not receive certificates of the server (num: %d)", sk_X509_num(ch));
goto end;
}
@@ -113,12 +113,12 @@ int mosquitto__verify_ocsp_status_cb(SSL *ssl, void *arg)
* For all currently supported versions of the OpenSSL project, this is not needed anymore.
*/
if ((result2=OCSP_basic_verify(br, ch, st, 0)) <= 0) {
if((result2=OCSP_basic_verify(br, ch, st, 0)) <= 0){
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: response verification failed (error: %d)", result2);
goto end;
}
for(i = 0; i < OCSP_resp_count(br); i++) {
for(i = 0; i < OCSP_resp_count(br); i++){
int cert_status, crl_reason;
OCSP_SINGLERESP *single = NULL;
@@ -133,10 +133,10 @@ int mosquitto__verify_ocsp_status_cb(SSL *ssl, void *arg)
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: SSL certificate status: %s (%d)",
OCSP_cert_status_str(cert_status), cert_status);
switch(cert_status) {
switch(cert_status){
case V_OCSP_CERTSTATUS_GOOD:
/* Note: A OCSP stapling result will be accepted up to 5 minutes after it expired! */
if(!OCSP_check_validity(thisupd, nextupd, 300L, -1L)) {
if(!OCSP_check_validity(thisupd, nextupd, 300L, -1L)){
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: OCSP response has expired");
goto end;
}
@@ -156,13 +156,13 @@ int mosquitto__verify_ocsp_status_cb(SSL *ssl, void *arg)
}
}
if (br!=NULL) OCSP_BASICRESP_free(br);
if (rsp!=NULL) OCSP_RESPONSE_free(rsp);
if(br!=NULL) OCSP_BASICRESP_free(br);
if(rsp!=NULL) OCSP_RESPONSE_free(rsp);
return 1; /* OK */
end:
if (br!=NULL) OCSP_BASICRESP_free(br);
if (rsp!=NULL) OCSP_RESPONSE_free(rsp);
if(br!=NULL) OCSP_BASICRESP_free(br);
if(rsp!=NULL) OCSP_RESPONSE_free(rsp);
return 0; /* Not OK */
}
#endif
+2 -2
View File
@@ -314,7 +314,7 @@ int mosquitto_string_option(struct mosquitto *mosq, enum mosq_opt_t option, cons
if(!value) return MOSQ_ERR_INVAL;
if(!strcasecmp(value, "pem")){
mosq->tls_keyform = mosq_k_pem;
}else if (!strcasecmp(value, "engine")){
}else if(!strcasecmp(value, "engine")){
mosq->tls_keyform = mosq_k_engine;
}else{
return MOSQ_ERR_INVAL;
@@ -329,7 +329,7 @@ int mosquitto_string_option(struct mosquitto *mosq, enum mosq_opt_t option, cons
case MOSQ_OPT_TLS_ENGINE_KPASS_SHA1:
#if defined(WITH_TLS) && !defined(OPENSSL_NO_ENGINE) && OPENSSL_API_LEVEL < 30000
mosquitto_FREE(mosq->tls_engine_kpass_sha1);
if(mosquitto__hex2bin_sha1(value, (unsigned char**)&str) != MOSQ_ERR_SUCCESS){
if(mosquitto__hex2bin_sha1(value, (unsigned char **)&str) != MOSQ_ERR_SUCCESS){
return MOSQ_ERR_INVAL;
}
mosq->tls_engine_kpass_sha1 = str;
+1 -1
View File
@@ -343,7 +343,7 @@ int packet__write(struct mosquitto *mosq)
#endif
}
#ifdef WITH_BROKER
if (mosq->out_packet == NULL) {
if(mosq->out_packet == NULL){
mux__remove_out(mosq);
}
#endif
+9 -9
View File
@@ -64,12 +64,12 @@ int send__publish(struct mosquitto *mosq, uint16_t mid, const char *topic, uint3
{
struct mosquitto_base_msg tmp_msg;
tmp_msg.topic = (char *) topic;
tmp_msg.topic = (char *)topic;
tmp_msg.payloadlen = payloadlen;
tmp_msg.payload = (void *) payload;
tmp_msg.payload = (void *)payload;
tmp_msg.qos = qos;
tmp_msg.retain = retain;
tmp_msg.properties = (mosquitto_property *) store_props;
tmp_msg.properties = (mosquitto_property *)store_props;
rc = plugin__handle_message_out(mosq, &tmp_msg);
@@ -95,9 +95,9 @@ int send__publish(struct mosquitto *mosq, uint16_t mid, const char *topic, uint3
"Rejected PUBLISH to %s, quota exceeded.", mosq->id);
}
if(payload_changed) mosquitto_free((void *) payload);
if(topic_changed) mosquitto_free((char *) topic);
if(properties_changed) mosquitto_property_free_all((mosquitto_property **) &store_props);
if(payload_changed) mosquitto_free((void *)payload);
if(topic_changed) mosquitto_free((char *)topic);
if(properties_changed) mosquitto_property_free_all((mosquitto_property **)&store_props);
return MOSQ_ERR_SUCCESS;
}
@@ -175,9 +175,9 @@ int send__publish(struct mosquitto *mosq, uint16_t mid, const char *topic, uint3
#ifdef WITH_BROKER
rc = send__real_publish(mosq, mid, topic, payloadlen, payload, qos, retain, dup, subscription_identifier, store_props, expiry_interval);
if(payload_changed) mosquitto_free((void *) payload);
if(topic_changed) mosquitto_free((char *) topic);
if(properties_changed) mosquitto_property_free_all((mosquitto_property **) &store_props);
if(payload_changed) mosquitto_free((void *)payload);
if(topic_changed) mosquitto_free((char *)topic);
if(properties_changed) mosquitto_property_free_all((mosquitto_property **)&store_props);
return rc;
#else
return send__real_publish(mosq, mid, topic, payloadlen, payload, qos, retain, dup, subscription_identifier, store_props, expiry_interval);
+2 -2
View File
@@ -230,7 +230,7 @@ int socks5__send(struct mosquitto *mosq)
if(!packet) return MOSQ_ERR_NOMEM;
packet->payload[3 + WS_PACKET_OFFSET] = SOCKS_ATYPE_IP_V4;
memcpy(&(packet->payload[4 + WS_PACKET_OFFSET]), (const void*)&addr_ipv4, 4);
memcpy(&(packet->payload[4 + WS_PACKET_OFFSET]), (const void *)&addr_ipv4, 4);
packet->payload[4+4 + WS_PACKET_OFFSET] = MOSQ_MSB(mosq->port);
packet->payload[4+4+1 + WS_PACKET_OFFSET] = MOSQ_LSB(mosq->port);
}else if(ipv6_pton_result == 1){
@@ -240,7 +240,7 @@ int socks5__send(struct mosquitto *mosq)
if(!packet) return MOSQ_ERR_NOMEM;
packet->payload[3 + WS_PACKET_OFFSET] = SOCKS_ATYPE_IP_V6;
memcpy(&(packet->payload[4 + WS_PACKET_OFFSET]), (const void*)&addr_ipv6, 16);
memcpy(&(packet->payload[4 + WS_PACKET_OFFSET]), (const void *)&addr_ipv6, 16);
packet->payload[4+16 + WS_PACKET_OFFSET] = MOSQ_MSB(mosq->port);
packet->payload[4+16+1 + WS_PACKET_OFFSET] = MOSQ_LSB(mosq->port);
}else{
+2 -2
View File
@@ -180,8 +180,8 @@ int mosquitto__hex2bin(const char *hex, unsigned char *bin, int bin_max_len)
size_t i = 0;
/* Count the number of leading zero */
for(i=0; i<strlen(hex); i=i+2) {
if(strncmp(hex + i, "00", 2) == 0) {
for(i=0; i<strlen(hex); i=i+2){
if(strncmp(hex + i, "00", 2) == 0){
if(leading_zero >= bin_max_len){
return 0;
}
+2 -2
View File
@@ -134,7 +134,7 @@ FILE *mosquitto_fopen(const char *path, const char *mode, bool restrict_read)
}
return fptr;
}else {
}else{
return fopen(buf, mode);
}
}
@@ -304,7 +304,7 @@ char *mosquitto_fgets(char **buf, int *buflen, FILE *stream)
} \
}while (0)
int mosquitto_write_file(const char* target_path, bool restrict_read, int (*write_fn)(FILE* fptr, void* user_data), void* user_data, void (*log_fn)(const char* msg))
int mosquitto_write_file(const char *target_path, bool restrict_read, int (*write_fn)(FILE *fptr, void *user_data), void *user_data, void (*log_fn)(const char *msg))
{
int rc = 0;
FILE *fptr = NULL;
+2
View File
@@ -634,11 +634,13 @@ int mosquitto_pw_decode(struct mosquitto_pw *pw, const char *password)
}
}
const char *mosquitto_pw_get_encoded(struct mosquitto_pw *pw)
{
return pw?pw->encoded_password:NULL;
}
int mosquitto_pw_set_param(struct mosquitto_pw *pw, int param, int value)
{
if(!pw) return MOSQ_ERR_INVAL;
+3 -3
View File
@@ -982,7 +982,7 @@ BROKER_EXPORT int mosquitto_property_copy_all(mosquitto_property **dest, const m
case MQTT_PROP_TYPE_STRING:
pnew->value.s.len = src->value.s.len;
pnew->value.s.v = src->value.s.v ? mosquitto_strdup(src->value.s.v) : (char*)mosquitto_calloc(1,1);
pnew->value.s.v = src->value.s.v ? mosquitto_strdup(src->value.s.v) : (char *)mosquitto_calloc(1, 1);
if(!pnew->value.s.v){
mosquitto_property_free_all(dest);
return MOSQ_ERR_NOMEM;
@@ -1003,14 +1003,14 @@ BROKER_EXPORT int mosquitto_property_copy_all(mosquitto_property **dest, const m
case MQTT_PROP_TYPE_STRING_PAIR:
pnew->value.s.len = src->value.s.len;
pnew->value.s.v = src->value.s.v ? mosquitto_strdup(src->value.s.v) : (char*)mosquitto_calloc(1,1);
pnew->value.s.v = src->value.s.v ? mosquitto_strdup(src->value.s.v) : (char *)mosquitto_calloc(1, 1);
if(!pnew->value.s.v){
mosquitto_property_free_all(dest);
return MOSQ_ERR_NOMEM;
}
pnew->name.len = src->name.len;
pnew->name.v = src->name.v ? mosquitto_strdup(src->name.v) : (char*)mosquitto_calloc(1,1);
pnew->name.v = src->name.v ? mosquitto_strdup(src->name.v) : (char *)mosquitto_calloc(1, 1);
if(!pnew->name.v){
mosquitto_property_free_all(dest);
return MOSQ_ERR_NOMEM;
+5 -2
View File
@@ -28,6 +28,7 @@ Contributors:
#include "mosquitto.h"
#include "mosquitto/mqtt_protocol.h"
const char *mosquitto_strerror(int mosq_errno)
{
switch(mosq_errno){
@@ -135,16 +136,17 @@ const char *mosquitto_strerror(int mosq_errno)
case MOSQ_ERR_CONNECTION_RATE_EXCEEDED:
return "Connection rate exceeded";
default:
if(mosq_errno >= 128) {
if(mosq_errno >= 128){
// If mosq_errno is greater than 127,
// a mqtt5_return_code error was used
return mosquitto_reason_string(mosq_errno);
} else {
}else{
return "Unknown error";
}
}
}
const char *mosquitto_connack_string(int connack_code)
{
switch(connack_code){
@@ -165,6 +167,7 @@ const char *mosquitto_connack_string(int connack_code)
}
}
const char *mosquitto_reason_string(int reason_code)
{
switch(reason_code){
+4 -4
View File
@@ -47,9 +47,9 @@ void mosquitto_time_init(void)
struct timespec tp;
#ifdef CLOCK_BOOTTIME
if (clock_gettime(CLOCK_BOOTTIME, &tp) == 0) {
if(clock_gettime(CLOCK_BOOTTIME, &tp) == 0){
time_clock = CLOCK_BOOTTIME;
} else {
}else{
time_clock = CLOCK_MONOTONIC;
}
#else
@@ -66,10 +66,10 @@ time_t mosquitto_time(void)
#elif _POSIX_TIMERS>0 && defined(_POSIX_MONOTONIC_CLOCK)
struct timespec tp;
if (clock_gettime(time_clock, &tp) == 0)
if(clock_gettime(time_clock, &tp) == 0)
return tp.tv_sec;
return (time_t) -1;
return (time_t)-1;
#elif defined(__APPLE__)
static mach_timebase_info_data_t tb;
uint64_t ticks;
+1
View File
@@ -153,6 +153,7 @@ BROKER_EXPORT int mosquitto_sub_topic_check2(const char *str, size_t len)
return MOSQ_ERR_SUCCESS;
}
static int topic_matches_sub(const char *sub, const char *topic, const char *clientid, const char *username, bool match_patterns, bool *result)
{
size_t spos;
+1 -1
View File
@@ -893,7 +893,7 @@ static int dynsec__remove_client_from_all_groups(struct dynsec__data *data, cons
static int dynsec__add_client_address(const struct mosquitto *client, void *context_ptr)
{
struct connection_array_context *functor_context = (struct connection_array_context*)context_ptr;
struct connection_array_context *functor_context = (struct connection_array_context *)context_ptr;
const char *username = mosquitto_client_username(client);
if((username == NULL && functor_context->username == NULL)
+1 -1
View File
@@ -196,7 +196,7 @@ int dynsec__write_json_config(FILE *fptr, void *user_data)
}
json_str_len = strlen(json_str);
if (fwrite(json_str, 1, json_str_len, fptr) != json_str_len){
if(fwrite(json_str, 1, json_str_len, fptr) != json_str_len){
mosquitto_log_printf(MOSQ_LOG_ERR, "Error saving Dynamic security plugin config: Cannot write whole config (%ld) bytes to file %s", json_str_len, data->config_file);
rc = MOSQ_ERR_UNKNOWN;
}
@@ -52,8 +52,7 @@ static int basic_auth_callback(int event, void *event_data, void *userdata)
if(!strcmp(ed->password, environment_password)){
/* Password matched MOSQUITTO_PASSWORD */
return MOSQ_ERR_SUCCESS;
}
else{
}else{
return MOSQ_ERR_PLUGIN_DEFER;
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ Contributors:
#include "persist_sqlite.h"
int persist_sqlite__client_msg_remove(struct mosquitto_sqlite *ms, const char* clientid, int64_t store_id, int direction)
int persist_sqlite__client_msg_remove(struct mosquitto_sqlite *ms, const char *clientid, int64_t store_id, int direction)
{
int rc = 1;
+14 -15
View File
@@ -26,31 +26,30 @@ Contributors:
#include "mosquitto/broker.h"
static int extract_version_numbers(void *data_ptr, int num_columns, char** values, char** column_names)
static int extract_version_numbers(void *data_ptr, int num_columns, char **values, char **column_names)
{
unsigned int found = 0;
int *version_array = (int*)data_ptr;
int *version_array = (int *)data_ptr;
for (int i = 0; i < num_columns; ++i) {
if (!sqlite3_stricmp(column_names[i], "MAJOR")){
for(int i = 0; i < num_columns; ++i){
if(!sqlite3_stricmp(column_names[i], "MAJOR")){
version_array[0] = values[i] ? atoi(values[i]) : 0;
found |= 0x4;
}
else if (!sqlite3_stricmp(column_names[i], "MINOR")){
}else if(!sqlite3_stricmp(column_names[i], "MINOR")){
version_array[1] = values[i] ? atoi(values[i]) : 0;
found |= 0x2;
}
else if (!sqlite3_stricmp(column_names[i], "PATCH")){
}else if(!sqlite3_stricmp(column_names[i], "PATCH")){
version_array[2] = values[i] ? atoi(values[i]) : 0;
found |= 0x1;
}
}
if (found != 0x7){
if(found != 0x7){
return SQLITE_MISMATCH;
}
return SQLITE_OK;
}
static int create_tables_1_1(struct mosquitto_sqlite *ms)
{
int rc;
@@ -206,7 +205,7 @@ static int create_tables(struct mosquitto_sqlite *ms)
&extract_version_numbers, db_schema_version, NULL);
if(rc) goto fail;
if (db_schema_version[0] == 0){
if(db_schema_version[0] == 0){
rc = sqlite3_exec((*ms).db,
"INSERT INTO version_info(component,major,minor,patch) "
"VALUES ('database_schema','1','0','0');",
@@ -214,7 +213,7 @@ static int create_tables(struct mosquitto_sqlite *ms)
if(rc) goto fail;
memcpy(db_schema_version, (int[3]){1, 0, 0}, sizeof(db_schema_version));
}
if (db_schema_version[0] == 1){
if(db_schema_version[0] == 1){
/* 1.0.x needs to be upgraded to 1.1 */
if (db_schema_version[1] == 0){
rc = create_tables_1_1(ms);
@@ -438,7 +437,7 @@ void persist_sqlite__cleanup(struct mosquitto_sqlite *ms)
{
if(ms->db){
int rc = sqlite3_exec(ms->db, "END;", NULL, NULL, NULL);
if (rc != SQLITE_OK){
if(rc != SQLITE_OK){
mosquitto_log_printf(MOSQ_LOG_ERR, "Error: Sqlite persistence: Closing final transaction %s", sqlite3_errstr(rc));
}
}
@@ -464,12 +463,12 @@ void persist_sqlite__cleanup(struct mosquitto_sqlite *ms)
sqlite3_finalize(ms->will_remove_stmt);
if(ms->db){
int rc = sqlite3_wal_checkpoint_v2(ms->db,NULL,SQLITE_CHECKPOINT_TRUNCATE,NULL,NULL);
if (rc != SQLITE_OK){
int rc = sqlite3_wal_checkpoint_v2(ms->db, NULL, SQLITE_CHECKPOINT_TRUNCATE, NULL, NULL);
if(rc != SQLITE_OK){
mosquitto_log_printf(MOSQ_LOG_WARNING, "Warning: Sqlite persistence: Final wal_checkpoint %s", sqlite3_errstr(rc));
}
rc = sqlite3_close(ms->db);
if (rc != SQLITE_OK){
if(rc != SQLITE_OK){
mosquitto_log_printf(MOSQ_LOG_WARNING, "Warning: Sqlite persistence: Error closing database: %s", sqlite3_errstr(rc));
}
ms->db = NULL;
+1 -1
View File
@@ -105,7 +105,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
UNUSED(user_data);
memset(&plg_data, 0,sizeof(struct mosquitto_sqlite));
memset(&plg_data, 0, sizeof(struct mosquitto_sqlite));
set_defaults();
if(get_db_file(options, option_count)){
+8 -6
View File
@@ -435,33 +435,35 @@ static int retain_restore(struct mosquitto_sqlite *ms)
return MOSQ_ERR_SUCCESS;
}
static int publish_will_msg(const char *topic, int payloadlen, const void *payload, int qos, bool retain, mosquitto_property *properties)
{
void *payload_mosq = NULL;
int rc;
if (payloadlen){
if(payloadlen){
payload_mosq = mosquitto_malloc((size_t)payloadlen);
if (!payload_mosq){
if(!payload_mosq){
return MOSQ_ERR_NOMEM;
}
memcpy(payload_mosq, payload, (size_t)payloadlen);
}
rc = mosquitto_broker_publish(NULL, topic, payloadlen, payload_mosq, qos, retain, properties);
if (rc != MOSQ_ERR_SUCCESS){
if(rc != MOSQ_ERR_SUCCESS){
mosquitto_free(payload_mosq);
}
return rc;
}
static int will_restore(struct mosquitto_sqlite *ms)
{
sqlite3_stmt *stmt;
int rc;
long count = 0, failed = 0;
const char *clientid, *topic;
const void* payload;
const void *payload;
mosquitto_property *properties;
int payloadlen, qos, retain;
@@ -487,10 +489,10 @@ static int will_restore(struct mosquitto_sqlite *ms)
properties = json_to_properties((const char *)sqlite3_column_text(stmt, 6));
rc = mosquitto_client_will_set(clientid, topic, payloadlen, payload, qos, retain, properties);
if (rc == MOSQ_ERR_NOT_FOUND){
if(rc == MOSQ_ERR_NOT_FOUND){
/* If the client does not exist this is the will message of a non-persistent client. */
rc = publish_will_msg(topic, payloadlen, payload, qos, retain, properties);
} else if (rc == MOSQ_ERR_SUCCESS && (sqlite3_column_int64(stmt, 7) == 0 && sqlite3_column_int64(stmt, 8) == 0)) {
}else if(rc == MOSQ_ERR_SUCCESS && (sqlite3_column_int64(stmt, 7) == 0 && sqlite3_column_int64(stmt, 8) == 0)){
/* If the client is a persistent client and was connected at the moment of a crash
and has no will delay we publish it's will message now, but need a new copy of the properties. */
properties = json_to_properties((const char *)sqlite3_column_text(stmt, 6));
+7 -6
View File
@@ -30,13 +30,13 @@ int persist_sqlite__will_add_cb(int event, void *event_data, void *userdata)
char *propties_json_str = NULL;
UNUSED(event);
if (!ed->data.clientid || !ed->data.topic){
if(!ed->data.clientid || !ed->data.topic){
return MOSQ_ERR_INVAL;
}
if(ed->data.properties){
propties_json_str = properties_to_json_str(ed->data.properties);
if (!propties_json_str){
if(!propties_json_str){
return MOSQ_ERR_NOMEM;
}
}
@@ -53,10 +53,11 @@ int persist_sqlite__will_add_cb(int event, void *event_data, void *userdata)
rc = sqlite3_single_step_stmt(rc, ms, ms->will_add_stmt);
sqlite3_reset(ms->will_add_stmt);
mosquitto_free(propties_json_str);
return rc;
}
int persist_sqlite__will_remove_cb(int event, void *event_data, void *userdata)
{
struct mosquitto_evt_persist_will_msg *ed = event_data;
@@ -64,11 +65,11 @@ int persist_sqlite__will_remove_cb(int event, void *event_data, void *userdata)
int rc = MOSQ_ERR_SUCCESS;
UNUSED(event);
if(sqlite3_bind_text_from_c_str( ms->will_remove_stmt, 1, ed->data.clientid) != SQLITE_OK){
if(sqlite3_bind_text_from_c_str(ms->will_remove_stmt, 1, ed->data.clientid) != SQLITE_OK){
rc = MOSQ_ERR_UNKNOWN;
}
rc = sqlite3_single_step_stmt(rc, ms, ms->will_remove_stmt);
sqlite3_reset(ms->will_remove_stmt);
return rc;
}
+1
View File
@@ -69,6 +69,7 @@ int broker_acl_file__init(void)
return MOSQ_ERR_SUCCESS;
}
void broker_acl_file__cleanup(void)
{
if(db.config->per_listener_settings){
+11 -11
View File
@@ -205,12 +205,12 @@ static int bridge__set_tcp_keepalive(struct mosquitto *context)
setsockopt(context->sock, IPPROTO_TCP, TCP_KEEPCNT, (char *)&counter, sizeof(counter));
#else
ret =
setsockopt(context->sock, SOL_SOCKET, SO_KEEPALIVE, (const void*)&enabled, sizeof(enabled)) ||
setsockopt(context->sock, SOL_SOCKET, SO_KEEPALIVE, (const void *)&enabled, sizeof(enabled)) ||
#ifndef __APPLE__
setsockopt(context->sock, IPPROTO_TCP, TCP_KEEPIDLE, (const void*)&idle, sizeof(idle)) ||
setsockopt(context->sock, IPPROTO_TCP, TCP_KEEPIDLE, (const void *)&idle, sizeof(idle)) ||
#endif
setsockopt(context->sock, IPPROTO_TCP, TCP_KEEPINTVL, (const void*)&interval, sizeof(interval)) ||
setsockopt(context->sock, IPPROTO_TCP, TCP_KEEPCNT, (const void*)&counter, sizeof(counter));
setsockopt(context->sock, IPPROTO_TCP, TCP_KEEPINTVL, (const void *)&interval, sizeof(interval)) ||
setsockopt(context->sock, IPPROTO_TCP, TCP_KEEPCNT, (const void *)&counter, sizeof(counter));
#endif
if(ret) return MOSQ_ERR_UNKNOWN;
@@ -224,8 +224,8 @@ static int bridge__set_tcp_keepalive(struct mosquitto *context)
static int bridge__set_tcp_user_timeout(struct mosquitto *context)
{
int timeout = context->bridge->tcp_user_timeout;
if(timeout >= 0) {
if(setsockopt(context->sock, IPPROTO_TCP, TCP_USER_TIMEOUT, (char *)&timeout, sizeof(timeout))) {
if(timeout >= 0){
if(setsockopt(context->sock, IPPROTO_TCP, TCP_USER_TIMEOUT, (char *)&timeout, sizeof(timeout))){
return MOSQ_ERR_UNKNOWN;
}
}
@@ -329,7 +329,7 @@ static int bridge__connect_step1(struct mosquitto *context)
log__printf(NULL, MOSQ_LOG_NOTICE, "Connecting bridge (step 1) %s (%s:%d)", context->bridge->name, context->bridge->addresses[context->bridge->cur_address].address, context->bridge->addresses[context->bridge->cur_address].port);
rc = net__try_connect_step1(context, context->bridge->addresses[context->bridge->cur_address].address);
if(rc > 0 ){
if(rc > 0){
if(rc == MOSQ_ERR_TLS){
mux__delete(context);
net__socket_close(context);
@@ -582,7 +582,7 @@ int bridge__connect(struct mosquitto *context)
HASH_ADD(hh_sock, db.contexts_by_sock, sock, sizeof(context->sock), context);
if (bridge__set_tcp_keepalive(context) != MOSQ_ERR_SUCCESS) return MOSQ_ERR_UNKNOWN;
if(bridge__set_tcp_keepalive(context) != MOSQ_ERR_SUCCESS) return MOSQ_ERR_UNKNOWN;
#ifdef WITH_TCP_USER_TIMEOUT
if(bridge__set_tcp_user_timeout(context)) return MOSQ_ERR_UNKNOWN;
#endif
@@ -819,7 +819,7 @@ void bridge__cleanup(struct mosquitto *context)
if(db.bridge_count == 0){
mosquitto_FREE(db.bridges);
}else{
db.bridges = mosquitto_realloc(db.bridges, (unsigned) db.bridge_count * sizeof(db.bridges[0]));
db.bridges = mosquitto_realloc(db.bridges, (unsigned)db.bridge_count * sizeof(db.bridges[0]));
}
mosquitto_FREE(context->bridge->name);
@@ -915,10 +915,10 @@ static void bridge__update_backoff(struct mosquitto__bridge *bridge)
if(!bridge) return;
if(!bridge->backoff_cap) return; /* skip if not using jitter */
if (bridge->connected_at && db.now_s - bridge->connected_at >= bridge->stable_connection_period) {
if(bridge->connected_at && db.now_s - bridge->connected_at >= bridge->stable_connection_period){
log__printf(NULL, MOSQ_LOG_INFO, "Bridge %s connection was stable enough, resetting backoff", bridge->name);
bridge__backoff_reset(bridge);
} else {
}else{
bridge__backoff_step(bridge);
}
+15 -14
View File
@@ -221,6 +221,7 @@ static int config__create_default_listener(struct mosquitto__config *config, con
return MOSQ_ERR_SUCCESS;
}
static void conf__set_cur_security_options(struct mosquitto__config *config, struct mosquitto__listener **cur_listener, struct mosquitto__security_options **security_options, const char *option_name)
{
if(config->per_listener_settings){
@@ -628,7 +629,7 @@ int config__parse_args(struct mosquitto__config *config, int argc, char *argv[])
}else if(!strcmp(argv[i], "--test-config")){
config->test_configuration = true;
}else{
fprintf(stderr, "Error: Unknown option '%s'.\n",argv[i]);
fprintf(stderr, "Error: Unknown option '%s'.\n", argv[i]);
print_usage();
return MOSQ_ERR_INVAL;
}
@@ -1036,7 +1037,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
return MOSQ_ERR_INVAL;
}
while((token = strtok_r(NULL, " ", &saveptr))){
if (token[0] == '#'){
if(token[0] == '#'){
break;
}
struct bridge_address *new_addresses = mosquitto_realloc(cur_bridge->addresses, sizeof(struct bridge_address)*(size_t)(cur_bridge->address_count+1));
@@ -1429,21 +1430,21 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
REQUIRE_BRIDGE(token);
if(conf__parse_int(&token, "bridge_tcp_keepalive_idle", &tmp_int, &saveptr)) return MOSQ_ERR_INVAL;
if(tmp_int <= 0) {
if(tmp_int <= 0){
log__printf(NULL, MOSQ_LOG_ERR, "Error: invalid TCP keepalive idle value.");
return MOSQ_ERR_INVAL;
}
cur_bridge->tcp_keepalive_idle = (unsigned int)tmp_int;
if(conf__parse_int(&token, "bridge_tcp_keepalive_interval", &tmp_int, &saveptr)) return MOSQ_ERR_INVAL;
if(tmp_int <= 0) {
if(tmp_int <= 0){
log__printf(NULL, MOSQ_LOG_ERR, "Error: invalid TCP keepalive interval value.");
return MOSQ_ERR_INVAL;
}
cur_bridge->tcp_keepalive_interval = (unsigned int)tmp_int;
if(conf__parse_int(&token, "bridge_tcp_keepalive_counter", &tmp_int, &saveptr)) return MOSQ_ERR_INVAL;
if(tmp_int <= 0) {
if(tmp_int <= 0){
log__printf(NULL, MOSQ_LOG_ERR, "Error: invalid TCP keepalive counter value.");
return MOSQ_ERR_INVAL;
}
@@ -1456,7 +1457,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
REQUIRE_BRIDGE(token);
#ifdef WITH_TCP_USER_TIMEOUT
if(conf__parse_int(&token, "bridge_tcp_user_timeout", &tmp_int, &saveptr)) return MOSQ_ERR_INVAL;
if(tmp_int < 0) {
if(tmp_int < 0){
log__printf(NULL, MOSQ_LOG_ERR, "Error: invalid TCP user timeout value.");
return MOSQ_ERR_INVAL;
}
@@ -1548,7 +1549,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
}else if(!strcmp(token, "local_cleansession")){
#ifdef WITH_BRIDGE
REQUIRE_BRIDGE(token);
if(conf__parse_bool(&token, "local_cleansession", (bool *) &cur_bridge->clean_start_local, &saveptr)) return MOSQ_ERR_INVAL;
if(conf__parse_bool(&token, "local_cleansession", (bool *)&cur_bridge->clean_start_local, &saveptr)) return MOSQ_ERR_INVAL;
#else
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available.");
#endif
@@ -1759,7 +1760,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
/* Look for bind address / unix socket path */
token = strtok_r(NULL, " ", &saveptr);
if (token != NULL && token[0] == '#'){
if(token != NULL && token[0] == '#'){
token = NULL;
}
@@ -2372,7 +2373,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
char *kpass_sha = NULL, *kpass_sha_bin = NULL;
REQUIRE_LISTENER_OR_DEFAULT_LISTENER(token);
if(conf__parse_string(&token, "tls_engine_kpass_sha1", &kpass_sha, &saveptr)) return MOSQ_ERR_INVAL;
if(mosquitto__hex2bin_sha1(kpass_sha, (unsigned char**)&kpass_sha_bin) != MOSQ_ERR_SUCCESS){
if(mosquitto__hex2bin_sha1(kpass_sha, (unsigned char **)&kpass_sha_bin) != MOSQ_ERR_SUCCESS){
mosquitto_FREE(kpass_sha);
return MOSQ_ERR_INVAL;
}
@@ -2418,7 +2419,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
// Check if the topic is quoted (e.g. for spaces within topic names), but not the
// special case of ""
if(token[0] == '"' && token [1] != '"'){
if (strchr(saveptr, '"') == NULL) {
if(strchr(saveptr, '"') == NULL){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Missing closing quote in topic value (%s).", saveptr);
return MOSQ_ERR_INVAL;
}
@@ -2430,7 +2431,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
}
topic = mosquitto_malloc(strlen(token) + slen + 1);
if (!topic) {
if(!topic){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
return MOSQ_ERR_NOMEM;
}
@@ -2442,7 +2443,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
}
}else{
topic = mosquitto_strdup(token);
if (!topic) {
if(!topic){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
return MOSQ_ERR_NOMEM;
}
@@ -2463,7 +2464,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
}
token = strtok_r(NULL, " ", &saveptr);
if(token){
if (token[0] == '#'){
if(token[0] == '#'){
(void)strtok_r(NULL, "", &saveptr);
}
qos = (uint8_t)atoi(token);
@@ -2477,7 +2478,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
if(token){
if(!strcmp(token, "\"\"") || token[0] == '#'){
local_prefix = NULL;
if (token[0] == '#'){
if(token[0] == '#'){
(void)strtok_r(NULL, "", &saveptr);
}
}else{
+3 -2
View File
@@ -234,7 +234,7 @@ void context__send_will(struct mosquitto *ctxt)
&ctxt->will->properties);
}
}
will__clear(ctxt);
}
@@ -249,7 +249,8 @@ void context__disconnect(struct mosquitto *context, int reason)
if(context->transport == mosq_t_ws){
uint8_t buf[4] = {0x88, 0x02, 0x03, context->wsd.disconnect_reason};
/* Send the disconnect reason, but don't care if it fails */
if(send(context->sock, buf, 4, 0)){};
if(send(context->sock, buf, 4, 0)){
}
}
#endif
+5 -4
View File
@@ -614,7 +614,7 @@ int db__message_insert_outgoing(struct mosquitto *context, uint64_t cmsg_id, uin
return 2;
}
}else{
if (db__ready_for_queue(context, qos, msg_data)){
if(db__ready_for_queue(context, qos, msg_data)){
state = mosq_ms_queued;
}else{
metrics__int_inc(mosq_counter_mqtt_publish_dropped, 1);
@@ -735,12 +735,13 @@ static inline int db__message_update_outgoing_state(struct mosquitto *context, s
return MOSQ_ERR_NOT_FOUND;
}
int db__message_update_outgoing(struct mosquitto *context, uint16_t mid, enum mosquitto_msg_state state, int qos, bool persist)
{
int rc;
rc = db__message_update_outgoing_state(context, context->msgs_out.inflight, mid, state, qos, persist);
if (!persist && rc == MOSQ_ERR_NOT_FOUND){
if(!persist && rc == MOSQ_ERR_NOT_FOUND){
rc = db__message_update_outgoing_state(context, context->msgs_out.queued, mid, state, qos, persist);
}
return rc;
@@ -1145,14 +1146,14 @@ int db__message_reconnect_reset(struct mosquitto *context)
}
int db__message_remove_incoming(struct mosquitto* context, uint16_t mid)
int db__message_remove_incoming(struct mosquitto *context, uint16_t mid)
{
struct mosquitto__client_msg *client_msg, *tmp;
if(!context) return MOSQ_ERR_INVAL;
DL_FOREACH_SAFE(context->msgs_in.inflight, client_msg, tmp){
if(client_msg->data.mid == mid) {
if(client_msg->data.mid == mid){
if(client_msg->base_msg->data.qos != 2){
return MOSQ_ERR_PROTOCOL;
}
+26 -26
View File
@@ -313,7 +313,7 @@ int connect__on_authorised(struct mosquitto *context, void *auth_data_out, uint1
if(context->session_expiry_interval != 0){
plugin_persist__handle_client_add(context);
}else if (context->will){
}else if(context->will){
plugin_persist__handle_will_add(context);
}
}
@@ -597,7 +597,7 @@ static int read_and_verify_v5_connect_properties(struct mosquitto *context, mosq
}else if(rc == MOSQ_ERR_MALFORMED_PACKET){
send__connack(context, 0, MQTT_RC_MALFORMED_PACKET, NULL);
}
if(rc) {
if(rc){
return rc;
}
}
@@ -698,13 +698,13 @@ static int read_and_verify_clientid_from_packet(struct mosquitto *context, char*
if(slen == 0){
rc = handle_zero_length_clientid(context, clientid, allow_zero_length_clientid, clean_start);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
return rc;
}
}
rc = check_clientid_prefixes(context, *clientid);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
return rc;
}
@@ -763,7 +763,7 @@ static int read_and_verify_client_credentials_from_packet(struct mosquitto *cont
if(username_flag){
rc = set_username_from_packet(context, username);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
return rc;
}
}else{
@@ -777,7 +777,7 @@ static int read_and_verify_client_credentials_from_packet(struct mosquitto *cont
}
if(password_flag){
rc = set_password_from_packet(context, password);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
return rc;
}
}
@@ -839,7 +839,7 @@ static int set_username_from_cert_identity(struct mosquitto *context)
X509 *client_cert = NULL;
X509_NAME *name = NULL;
if(get_client_cert_and_subject_name(context, &client_cert, &name)) {
if(get_client_cert_and_subject_name(context, &client_cert, &name)){
return MOSQ_ERR_AUTH;
}
@@ -857,11 +857,11 @@ static int set_username_from_cert_identity(struct mosquitto *context)
ASN1_STRING *name_asn1 = NULL;
name_asn1 = X509_NAME_ENTRY_get_data(name_entry);
if (name_asn1 == NULL) {
if(name_asn1 == NULL){
return free_x509_and_send_connack_error(context, client_cert, MOSQ_ERR_AUTH);
}
const char *cert_identity = NULL;
cert_identity = (char *) ASN1_STRING_get0_data(name_asn1);
cert_identity = (char *)ASN1_STRING_get0_data(name_asn1);
if(mosquitto_validate_utf8(cert_identity, (int)strlen(cert_identity))){
return free_x509_and_send_connack_error(context, client_cert, MOSQ_ERR_AUTH);
}
@@ -871,7 +871,7 @@ static int set_username_from_cert_identity(struct mosquitto *context)
return free_x509_and_send_connack_error(context, client_cert, MOSQ_ERR_NOMEM);
}
/* Make sure there isn't an embedded NUL character in the CN */
if ((size_t)ASN1_STRING_length(name_asn1) != strlen(context->username)) {
if((size_t)ASN1_STRING_length(name_asn1) != strlen(context->username)){
return free_x509_and_send_connack_error(context, client_cert, MOSQ_ERR_AUTH);
}
@@ -887,7 +887,7 @@ static int set_username_from_cert_subject_name(struct mosquitto *context)
X509 *client_cert = NULL;
X509_NAME *name = NULL;
if(get_client_cert_and_subject_name(context, &client_cert, &name)) {
if(get_client_cert_and_subject_name(context, &client_cert, &name)){
return MOSQ_ERR_AUTH;
}
@@ -947,12 +947,12 @@ static int handle_username_from_cert_options(struct mosquitto *context, char **u
}else
#endif /* FINAL_WITH_TLS_PSK */
{
if (context->listener->use_identity_as_username) {
if(context->listener->use_identity_as_username){
rc = set_username_from_cert_identity(context);
} else { /* use_subject_as_username */
}else{ /* use_subject_as_username */
rc = set_username_from_cert_subject_name(context);
}
if(rc) {
if(rc){
return rc;
}
}
@@ -1037,20 +1037,20 @@ int handle__connect(struct mosquitto *context)
}
rc = read_protocol_name(context, protocol_name);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
goto handle_connect_error;
}
rc = read_and_verify_protocol_version(context, protocol_name, &protocol_version);
if (rc != MOSQ_ERR_SUCCESS) {
if (rc == MOSQ_ERR_MALFORMED_PACKET) {
if(rc != MOSQ_ERR_SUCCESS){
if(rc == MOSQ_ERR_MALFORMED_PACKET){
return rc;
}
goto handle_connect_error;
}
rc = read_and_verify_connect_flags(context, &connect_flags);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
goto handle_connect_error;
}
@@ -1058,12 +1058,12 @@ int handle__connect(struct mosquitto *context)
set_session_expiry_interval(context, clean_start, protocol_version);
rc = read_and_reset_keepalive(context);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
goto handle_connect_error;
}
rc = read_and_verify_v5_connect_properties(context, &properties, protocol_version);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
goto handle_connect_error;
}
@@ -1071,7 +1071,7 @@ int handle__connect(struct mosquitto *context)
will_qos = (connect_flags & 0x18) >> 3;
will_retain = ((connect_flags & 0x20) == 0x20);
rc = verify_will_options(context, will, will_qos, will_retain, protocol_version);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
goto handle_connect_error;
}
@@ -1086,7 +1086,7 @@ int handle__connect(struct mosquitto *context)
}
rc = read_and_verify_clientid_from_packet(context, &clientid, &allow_zero_length_clientid, clean_start);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
goto handle_connect_error;
}
@@ -1115,12 +1115,12 @@ int handle__connect(struct mosquitto *context)
password_flag = connect_flags & 0x40;
username_flag = connect_flags & 0x80;
rc = read_and_verify_client_credentials_from_packet(context, &username, username_flag, &password, password_flag, clientid);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
goto handle_connect_error;
}
rc = check_additional_trailing_data(context, protocol_version);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
goto handle_connect_error;
}
@@ -1132,14 +1132,14 @@ int handle__connect(struct mosquitto *context)
/* use_identity_as_username or use_subject_as_username */
rc = handle_username_from_cert_options(context, &username, &password);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
goto handle_connect_error;
}
/* use_username_as_clientid */
if(context->listener->use_username_as_clientid){
rc = handle_username_as_clientid_option(context);
if (rc != MOSQ_ERR_SUCCESS) {
if(rc != MOSQ_ERR_SUCCESS){
goto handle_connect_error;
}
}
+1 -1
View File
@@ -299,7 +299,7 @@ static enum MHD_Result http_api__process_file(struct mosquitto__listener *listen
if(!S_ISREG(statbuf.st_mode)){
fclose(fptr);
http_api__send_error_response(connection, "Not found.\n", 404);
return MHD_YES;
return MHD_YES;
}
uint64_t flen = (uint64_t )statbuf.st_size;
+4 -4
View File
@@ -46,7 +46,7 @@ HANDLE syslog_h;
#ifdef ANDROID
#include <android/log.h>
static const char* LOG_TAG = "mosquitto";
static const char *LOG_TAG = "mosquitto";
#endif
static char log_fptr_buffer[BUFSIZ];
@@ -144,7 +144,7 @@ int log__init(struct mosquitto__config *config)
if(log_destinations & MQTT3_LOG_DLT){
dlt_fifo_check();
if(dlt_allowed){
DLT_REGISTER_APP("MQTT","mosquitto log");
DLT_REGISTER_APP("MQTT", "mosquitto log");
dlt_register_context(&dltContext, "MQTT", "mosquitto DLT context");
}
}
@@ -184,7 +184,7 @@ int log__close(struct mosquitto__config *config)
DltLogLevelType get_dlt_level(unsigned int priority)
{
switch (priority) {
switch(priority){
case MOSQ_LOG_ERR:
return DLT_LOG_ERROR;
case MOSQ_LOG_WARNING:
@@ -208,7 +208,7 @@ DltLogLevelType get_dlt_level(unsigned int priority)
android_LogPriority get_android_level(unsigned int priority)
{
switch (priority) {
switch(priority){
case MOSQ_LOG_ERR:
return ANDROID_LOG_ERROR;
case MOSQ_LOG_WARNING:
+1
View File
@@ -65,6 +65,7 @@ void lws__sul_callback(struct lws_sorted_usec_list *l)
static struct lws_sorted_usec_list sul;
#endif
static int single_publish(struct mosquitto *context, struct mosquitto__message_v5 *pub_msg, uint32_t message_expiry)
{
struct mosquitto__base_msg *base_msg;
+10 -10
View File
@@ -48,7 +48,7 @@ int mux_epoll__init(void)
memset(&ep_events, 0, sizeof(struct epoll_event)*MAX_EVENTS);
db.epollfd = 0;
if ((db.epollfd = epoll_create(MAX_EVENTS)) == -1) {
if((db.epollfd = epoll_create(MAX_EVENTS)) == -1){
log__printf(NULL, MOSQ_LOG_ERR, "Error in epoll creating: %s", strerror(errno));
return MOSQ_ERR_UNKNOWN;
}
@@ -65,7 +65,7 @@ int mux_epoll__add_listeners(struct mosquitto__listener_sock *listensock, int li
memset(&ev, 0, sizeof(struct epoll_event));
ev.data.ptr = &listensock[i];
ev.events = EPOLLIN;
if (epoll_ctl(db.epollfd, EPOLL_CTL_ADD, listensock[i].sock, &ev) == -1) {
if(epoll_ctl(db.epollfd, EPOLL_CTL_ADD, listensock[i].sock, &ev) == -1){
log__printf(NULL, MOSQ_LOG_ERR, "Error in epoll initial registering: %s", strerror(errno));
return MOSQ_ERR_UNKNOWN;
}
@@ -78,7 +78,7 @@ int mux_epoll__add_listeners(struct mosquitto__listener_sock *listensock, int li
int mux_epoll__delete_listeners(struct mosquitto__listener_sock *listensock, int listensock_count)
{
for(int i=0; i<listensock_count; i++){
if (epoll_ctl(db.epollfd, EPOLL_CTL_DEL, listensock[i].sock, NULL) == -1) {
if(epoll_ctl(db.epollfd, EPOLL_CTL_DEL, listensock[i].sock, NULL) == -1){
return MOSQ_ERR_UNKNOWN;
}
}
@@ -89,14 +89,14 @@ int mux_epoll__delete_listeners(struct mosquitto__listener_sock *listensock, int
int mux_epoll__add_out(struct mosquitto *context)
{
if(!(context->events & EPOLLOUT)) {
if(!(context->events & EPOLLOUT)){
struct epoll_event ev;
memset(&ev, 0, sizeof(struct epoll_event));
ev.data.ptr = context;
ev.events = EPOLLIN | EPOLLOUT;
if(epoll_ctl(db.epollfd, EPOLL_CTL_MOD, context->sock, &ev) == -1) {
if((errno != ENOENT)||(epoll_ctl(db.epollfd, EPOLL_CTL_ADD, context->sock, &ev) == -1)) {
if(epoll_ctl(db.epollfd, EPOLL_CTL_MOD, context->sock, &ev) == -1){
if((errno != ENOENT)||(epoll_ctl(db.epollfd, EPOLL_CTL_ADD, context->sock, &ev) == -1)){
log__printf(NULL, MOSQ_LOG_DEBUG, "Error in epoll re-registering to EPOLLOUT: %s", strerror(errno));
}
}
@@ -108,14 +108,14 @@ int mux_epoll__add_out(struct mosquitto *context)
int mux_epoll__remove_out(struct mosquitto *context)
{
if(context->events & EPOLLOUT) {
if(context->events & EPOLLOUT){
struct epoll_event ev;
memset(&ev, 0, sizeof(struct epoll_event));
ev.data.ptr = context;
ev.events = EPOLLIN;
if(epoll_ctl(db.epollfd, EPOLL_CTL_MOD, context->sock, &ev) == -1) {
if((errno != ENOENT)||(epoll_ctl(db.epollfd, EPOLL_CTL_ADD, context->sock, &ev) == -1)) {
if(epoll_ctl(db.epollfd, EPOLL_CTL_MOD, context->sock, &ev) == -1){
if((errno != ENOENT)||(epoll_ctl(db.epollfd, EPOLL_CTL_ADD, context->sock, &ev) == -1)){
log__printf(NULL, MOSQ_LOG_DEBUG, "Error in epoll re-registering to EPOLLIN: %s", strerror(errno));
}
}
@@ -132,7 +132,7 @@ int mux_epoll__new(struct mosquitto *context)
memset(&ev, 0, sizeof(struct epoll_event));
ev.events = EPOLLIN;
ev.data.ptr = context;
if (epoll_ctl(db.epollfd, EPOLL_CTL_ADD, context->sock, &ev) == -1) {
if(epoll_ctl(db.epollfd, EPOLL_CTL_ADD, context->sock, &ev) == -1){
if(errno != EEXIST){
log__printf(NULL, MOSQ_LOG_ERR, "Error in epoll accepting: %s", strerror(errno));
}
+1 -1
View File
@@ -40,7 +40,7 @@ int mux_kqueue__init(void)
memset(&event_list, 0, sizeof(struct kevent)*MAX_EVENTS);
db.kqueuefd = 0;
if ((db.kqueuefd = kqueue()) == -1) {
if((db.kqueuefd = kqueue()) == -1){
log__printf(NULL, MOSQ_LOG_ERR, "Error in kqueue creating: %s", strerror(errno));
return MOSQ_ERR_UNKNOWN;
}
+4 -4
View File
@@ -74,7 +74,7 @@ int mux_poll__init(void)
return MOSQ_ERR_NOMEM;
}
memset(pollfds, 0, sizeof(struct pollfd)*pollfd_max);
for(size_t i=0; i<pollfd_max; i++) {
for(size_t i=0; i<pollfd_max; i++){
pollfds[i].fd = INVALID_SOCKET;
}
@@ -117,7 +117,7 @@ int mux_poll__delete_listeners(struct mosquitto__listener_sock *listensock, int
}
static int mux_poll__add(struct mosquitto* context, uint16_t evt)
static int mux_poll__add(struct mosquitto *context, uint16_t evt)
{
if(context->events == evt){
return MOSQ_ERR_SUCCESS;
@@ -128,7 +128,7 @@ static int mux_poll__add(struct mosquitto* context, uint16_t evt)
pollfds[context->pollfd_index].events = (short int)evt;
pollfds[context->pollfd_index].revents = 0;
}else{
for(size_t i=0; i<pollfd_max; i++) {
for(size_t i=0; i<pollfd_max; i++){
if(pollfds[i].fd == INVALID_SOCKET){
pollfds[i].fd = context->sock;
pollfds[i].events = POLLIN;
@@ -155,7 +155,7 @@ int mux_poll__add_out(struct mosquitto *context)
int mux_poll__remove_out(struct mosquitto *context)
{
if(context->events & POLLOUT) {
if(context->events & POLLOUT){
return mux_poll__new(context);
}else{
return MOSQ_ERR_SUCCESS;
+3 -3
View File
@@ -176,7 +176,7 @@ struct mosquitto *net__socket_accept(struct mosquitto__listener_sock *listensock
if(db.config->set_tcp_nodelay && listensock->listener->port){
int flag = 1;
#ifdef WIN32
if (setsockopt(new_sock, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)) != 0) {
if(setsockopt(new_sock, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)) != 0){
#else
if(setsockopt(new_sock, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int)) != 0){
#endif
@@ -330,7 +330,7 @@ static unsigned int psk_server_callback(SSL *ssl, const char *identity, unsigned
}
len = mosquitto__hex2bin(psk_key, psk, (int)max_psk_len);
if (len < 0){
if(len < 0){
mosquitto_FREE(psk_key);
return 0;
}
@@ -777,7 +777,7 @@ static int net__socket_listen_tcp(struct mosquitto__listener *listener)
hints.ai_socktype = SOCK_STREAM;
rc = getaddrinfo(listener->host, service, &hints, &ainfo);
if (rc){
if(rc){
log__printf(NULL, MOSQ_LOG_ERR, "Error creating listener: %s.", gai_strerror(rc));
return INVALID_SOCKET;
}
+1
View File
@@ -64,6 +64,7 @@ int broker_password_file__init(void)
return MOSQ_ERR_SUCCESS;
}
void broker_password_file__cleanup(void)
{
if(db.config->per_listener_settings){
+1 -1
View File
@@ -38,7 +38,7 @@ Contributors:
uint32_t db_version;
const unsigned char magic[15] = {0x00, 0xB5, 0x00, 'm','o','s','q','u','i','t','t','o',' ','d','b'};
const unsigned char magic[15] = {0x00, 0xB5, 0x00, 'm', 'o', 's', 'q', 'u', 'i', 't', 't', 'o', ' ', 'd', 'b'};
static long base_msg_count = 0;
static long retained_count = 0;
static long client_count = 0;

Some files were not shown because too many files have changed in this diff Show More