Checking return code of persistence creation

Testing against Paho C 1.2.1
This commit is contained in:
fmp 2018-04-15 09:32:40 -04:00
parent 25ffc2a178
commit 32b1d4ae7f
3 changed files with 16 additions and 12 deletions

View File

@ -12,7 +12,8 @@
# is rather meant to be a quick test to use during development.
#
COMPILERS="g++-4.8 g++-4.9 g++-5 g++-6 clang++-3.6 clang++-3.8"
#COMPILERS="g++-4.8 g++-4.9 g++-5 g++-6 clang++-3.6 clang++-3.8"
COMPILERS="g++-5 g++-6 clang++-3.8 clang++-4.0"
[ "$#" -gt 0 ] && COMPILERS="$@"
[ -z "${BUILD_JOBS}" ] && BUILD_JOBS=4

View File

@ -4,8 +4,9 @@
#
git clone https://github.com/eclipse/paho.mqtt.c.git
pushd paho.mqtt.c
#git checkout develop
git checkout v1.2.1
mkdir build_cmake && cd build_cmake
cmake -DPAHO_WITH_SSL=ON ..
make

View File

@ -57,15 +57,14 @@ async_client::async_client(const string& serverURI, const string& clientId,
opts->maxBufferedMessages = maxBufferedMessages;
}
auto rc = MQTTAsync_createWithOptions(&cli_, serverURI.c_str(), clientId.c_str(),
int rc = MQTTAsync_createWithOptions(&cli_, serverURI.c_str(), clientId.c_str(),
MQTTCLIENT_PERSISTENCE_DEFAULT,
const_cast<char*>(persistDir.c_str()),
opts.get());
if (rc != 0) {
if (rc != 0)
throw exception(rc);
}
}
async_client::async_client(const string& serverURI, const string& clientId,
int maxBufferedMessages, iclient_persistence* persistence /*=nullptr*/)
@ -96,9 +95,11 @@ async_client::async_client(const string& serverURI, const string& clientId,
&iclient_persistence::persistence_containskey
});
MQTTAsync_createWithOptions(&cli_, serverURI.c_str(), clientId.c_str(),
int rc = MQTTAsync_createWithOptions(&cli_, serverURI.c_str(), clientId.c_str(),
MQTTCLIENT_PERSISTENCE_USER, persist_.get(),
opts.get());
if (rc != 0)
throw exception(rc);
}
}
@ -270,6 +271,7 @@ void async_client::disable_callbacks()
int rc = MQTTAsync_setCallbacks(cli_, this, nullptr,
[](void*,char*,int,MQTTAsync_message*) -> int {return !0;},
nullptr);
if (rc != MQTTASYNC_SUCCESS)
throw exception(rc);
}