Skip to content

Commit 9f834df

Browse files
replace mosquitto_delay_puback() with MOSQ_OPT_DELAYED_ACK opt
Signed-off-by: Linus Basig <[email protected]> Co-authored-by: Fabrizio Lazzaretti <[email protected]> Signed-off-by: Fabrizio Lazzaretti <[email protected]>
1 parent d2004ed commit 9f834df

File tree

7 files changed

+12
-35
lines changed

7 files changed

+12
-35
lines changed

include/mosquitto.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ enum mosq_opt_t {
138138
MOSQ_OPT_TCP_NODELAY = 11,
139139
MOSQ_OPT_BIND_ADDRESS = 12,
140140
MOSQ_OPT_TLS_USE_OS_CERTS = 13,
141+
MOSQ_OPT_DELAYED_ACK = 14,
141142
};
142143

143144

@@ -1474,6 +1475,9 @@ libmosq_EXPORT int mosquitto_opts_set(struct mosquitto *mosq, enum mosq_opt_t op
14741475
* MOSQ_OPT_TLS_USE_OS_CERTS - Set to 1 to instruct the client to load and
14751476
* trust OS provided CA certificates for use with TLS connections.
14761477
* Set to 0 (the default) to only use manually specified CA certs.
1478+
*
1479+
* MOSQ_OPT_DELAYED_ACK - Set to 1 to instruct the client to acknowledge QoS 1
1480+
* messages after the on_message callback is called.
14771481
*/
14781482
libmosq_EXPORT int mosquitto_int_option(struct mosquitto *mosq, enum mosq_opt_t option, int value);
14791483

@@ -1672,22 +1676,6 @@ libmosq_EXPORT void mosquitto_user_data_set(struct mosquitto *mosq, void *obj);
16721676
*/
16731677
libmosq_EXPORT void *mosquitto_userdata(struct mosquitto *mosq);
16741678

1675-
/*
1676-
* Function: mosquitto_delay_puback
1677-
*
1678-
* Per Default, the library will acknowledge a QoS 1 message before it calls the
1679-
* on_message callback. After <mosquitto_delay_puback> is called, the library
1680-
* delays the acknowledgment until after the on_message callback has returned.
1681-
*
1682-
* Parameters:
1683-
* mosq - a valid mosquitto instance.
1684-
*
1685-
* Returns:
1686-
* MOSQ_ERR_SUCCESS - on success.
1687-
* MOSQ_ERR_INVAL - if the input parameters were invalid.
1688-
*/
1689-
libmosq_EXPORT int mosquitto_delay_puback(struct mosquitto *mosq);
1690-
16911679

16921680
/* ======================================================================
16931681
*

lib/cpp/mosquittopp.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,6 @@ void mosquittopp::user_data_set(void *userdata)
352352
mosquitto_user_data_set(m_mosq, userdata);
353353
}
354354

355-
int mosquittopp::delay_puback()
356-
{
357-
mosquitto_delay_puback(m_mosq);
358-
}
359-
360355
int mosquittopp::socks5_set(const char *host, int port, const char *username, const char *password)
361356
{
362357
return mosquitto_socks5_set(m_mosq, host, port, username, password);

lib/cpp/mosquittopp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ class mosqpp_EXPORT mosquittopp {
107107
int max_inflight_messages_set(unsigned int max_inflight_messages);
108108
void message_retry_set(unsigned int message_retry);
109109
void user_data_set(void *userdata);
110-
int delay_puback();
111110
int tls_set(const char *cafile, const char *capath=NULL, const char *certfile=NULL, const char *keyfile=NULL, int (*pw_callback)(char *buf, int size, int rwflag, void *userdata)=NULL);
112111
int tls_opts_set(int cert_reqs, const char *tls_version=NULL, const char *ciphers=NULL);
113112
int tls_insecure_set(bool value);

lib/handle_publish.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ int handle__publish(struct mosquitto *mosq)
135135
return MOSQ_ERR_SUCCESS;
136136
case 1:
137137
util__decrement_receive_quota(mosq);
138-
if(!mosq->delayed_puback){
138+
if(!mosq->delayed_ack){
139139
rc = send__puback(mosq, mid, 0, NULL);
140140
}
141141
pthread_mutex_lock(&mosq->callback_mutex);
@@ -150,7 +150,7 @@ int handle__publish(struct mosquitto *mosq)
150150
mosq->in_callback = false;
151151
}
152152
pthread_mutex_unlock(&mosq->callback_mutex);
153-
if(mosq->delayed_puback){
153+
if(mosq->delayed_ack){
154154
rc = send__puback(mosq, mid, 0, NULL);
155155
}
156156
message__cleanup(&message);

lib/mosquitto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ int mosquitto_reinitialise(struct mosquitto *mosq, const char *id, bool clean_st
193193
mosq->reconnect_delay_max = 1;
194194
mosq->reconnect_exponential_backoff = false;
195195
mosq->threaded = mosq_ts_none;
196-
mosq->delayed_puback = false;
196+
mosq->delayed_ack = false;
197197
#ifdef WITH_TLS
198198
mosq->ssl = NULL;
199199
mosq->ssl_ctx = NULL;

lib/mosquitto_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ struct mosquitto {
353353
#ifdef WITH_EPOLL
354354
uint32_t events;
355355
#endif
356-
bool delayed_puback;
356+
bool delayed_ack;
357357
};
358358

359359
#define STREMPTY(str) (str[0] == '\0')

lib/options.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,10 @@ int mosquitto_int_option(struct mosquitto *mosq, enum mosq_opt_t option, int val
486486
mosq->tcp_nodelay = (bool)value;
487487
break;
488488

489+
case MOSQ_OPT_DELAYED_ACK:
490+
mosq->delayed_ack = (bool)value;
491+
break;
492+
489493
default:
490494
return MOSQ_ERR_INVAL;
491495
}
@@ -530,12 +534,3 @@ void *mosquitto_userdata(struct mosquitto *mosq)
530534
{
531535
return mosq->userdata;
532536
}
533-
534-
int mosquitto_delay_puback(struct mosquitto *mosq)
535-
{
536-
if(!mosq) return MOSQ_ERR_INVAL;
537-
538-
mosq->delayed_puback = true;
539-
540-
return MOSQ_ERR_SUCCESS;
541-
}

0 commit comments

Comments
 (0)