Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
paho.mqtt.c
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eclipse
paho.mqtt.c
Commits
b8b562c7
Commit
b8b562c7
authored
Nov 14, 2016
by
Jiri Zouhar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow user to disable openssl library init
Signed-off-by:
Jiri Zouhar
<
jzouhar@netio.eu
>
parent
d1538480
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
42 deletions
+91
-42
MQTTAsync.c
src/MQTTAsync.c
+12
-4
MQTTAsync.h
src/MQTTAsync.h
+7
-0
MQTTClient.c
src/MQTTClient.c
+7
-0
MQTTClient.h
src/MQTTClient.h
+7
-1
SSLSocket.c
src/SSLSocket.c
+55
-37
SSLSocket.h
src/SSLSocket.h
+3
-0
No files found.
src/MQTTAsync.c
View file @
b8b562c7
...
...
@@ -60,6 +60,13 @@
#include "VersionInfo.h"
void
MQTTAsync_global_init
(
int
handle_openssl_init
)
{
#if defined(OPENSSL)
SSLSocket_handleOpensslInit
(
handle_openssl_init
);
#endif
}
char
*
client_timestamp_eye
=
"MQTTAsyncV3_Timestamp "
BUILD_TIMESTAMP
;
char
*
client_version_eye
=
"MQTTAsyncV3_Version "
CLIENT_VERSION
;
...
...
@@ -1322,11 +1329,8 @@ void MQTTAsync_checkTimeouts()
MQTTAsyncs
*
m
=
(
MQTTAsyncs
*
)(
current
->
content
);
/* check disconnect timeout */
if
(
m
->
c
->
connect_state
==
-
2
)
MQTTAsync_checkDisconnect
(
m
,
&
m
->
disconnect
);
/* check connect timeout */
else
if
(
m
->
c
->
connect_state
!=
0
&&
MQTTAsync_elapsed
(
m
->
connect
.
start_time
)
>
(
m
->
connectTimeout
*
1000
))
if
(
m
->
c
->
connect_state
!=
0
&&
MQTTAsync_elapsed
(
m
->
connect
.
start_time
)
>
(
m
->
connectTimeout
*
1000
))
{
if
(
MQTTAsync_checkConn
(
&
m
->
connect
,
m
))
{
...
...
@@ -1359,6 +1363,10 @@ void MQTTAsync_checkTimeouts()
continue
;
}
/* check disconnect timeout */
if
(
m
->
c
->
connect_state
==
-
2
)
MQTTAsync_checkDisconnect
(
m
,
&
m
->
disconnect
);
timed_out_count
=
0
;
/* check response timeouts */
while
(
ListNextElement
(
m
->
responses
,
&
cur_response
))
...
...
src/MQTTAsync.h
View file @
b8b562c7
...
...
@@ -177,6 +177,13 @@
*/
#define MQTT_BAD_SUBSCRIBE 0x80
/**
* Global init of mqtt library. Call once on program start to set global behaviour.
* handle_openssl_init - if mqtt library should handle openssl init (1) or rely on the caller to init it before using mqtt (0)
*/
void
MQTTAsync_global_init
(
int
handle_openssl_init
);
/**
* A handle representing an MQTT client. A valid client handle is available
* following a successful call to MQTTAsync_create().
...
...
src/MQTTClient.c
View file @
b8b562c7
...
...
@@ -64,6 +64,13 @@
#include "VersionInfo.h"
void
MQTTClient_global_init
(
int
handle_openssl_init
)
{
#if defined(OPENSSL)
SSLSocket_handleOpensslInit
(
handle_openssl_init
);
#endif
}
char
*
client_timestamp_eye
=
"MQTTClientV3_Timestamp "
BUILD_TIMESTAMP
;
char
*
client_version_eye
=
"MQTTClientV3_Version "
CLIENT_VERSION
;
...
...
src/MQTTClient.h
View file @
b8b562c7
...
...
@@ -184,6 +184,12 @@
*/
#define MQTT_BAD_SUBSCRIBE 0x80
/**
* Global init of mqtt library. Call once on program start to set global behaviour.
* handle_openssl_init - if mqtt library should handle openssl init (1) or rely on the caller to init it before using mqtt (0)
*/
void
MQTTClient_global_init
(
int
handle_openssl_init
);
/**
* A handle representing an MQTT client. A valid client handle is available
* following a successful call to MQTTClient_create().
...
...
@@ -628,7 +634,7 @@ typedef struct
}
returned
;
}
MQTTClient_connectOptions
;
#define MQTTClient_connectOptions_initializer { {'M', 'Q', 'T', 'C'}, 4, 60, 1, 1, NULL, NULL, NULL, 30, 20, NULL, 0, NULL, 0}
#define MQTTClient_connectOptions_initializer { {'M', 'Q', 'T', 'C'}, 4, 60, 1, 1, NULL, NULL, NULL, 30, 20, NULL, 0, NULL, 0
, {NULL, 0, 0}
}
/**
* MQTTClient_libraryInfo is used to store details relating to the currently used
...
...
src/SSLSocket.c
View file @
b8b562c7
...
...
@@ -43,6 +43,8 @@ extern Sockets s;
void
SSLSocket_addPendingRead
(
int
sock
);
/// 1 ~ we are responsible for initializing openssl; 0 ~ openssl init is done externally
static
int
handle_openssl_init
=
1
;
static
ssl_mutex_type
*
sslLocks
=
NULL
;
static
ssl_mutex_type
sslCoreMutex
;
...
...
@@ -392,6 +394,11 @@ extern void SSLLocks_callback(int mode, int n, const char *file, int line)
}
}
void
SSLSocket_handleOpensslInit
(
int
bool_value
)
{
handle_openssl_init
=
bool_value
;
}
int
SSLSocket_initialize
()
{
int
rc
=
0
;
...
...
@@ -401,6 +408,8 @@ int SSLSocket_initialize()
FUNC_ENTRY
;
if
(
handle_openssl_init
)
{
if
((
rc
=
SSL_library_init
())
!=
1
)
rc
=
-
1
;
...
...
@@ -436,6 +445,8 @@ int SSLSocket_initialize()
#endif
CRYPTO_set_locking_callback
(
SSLLocks_callback
);
}
SSL_create_mutex
(
&
sslCoreMutex
);
exit:
...
...
@@ -446,6 +457,9 @@ exit:
void
SSLSocket_terminate
()
{
FUNC_ENTRY
;
if
(
handle_openssl_init
)
{
EVP_cleanup
();
ERR_free_strings
();
CRYPTO_set_locking_callback
(
NULL
);
...
...
@@ -459,6 +473,10 @@ void SSLSocket_terminate()
}
free
(
sslLocks
);
}
}
SSL_destroy_mutex
(
&
sslCoreMutex
);
FUNC_EXIT
;
}
...
...
src/SSLSocket.h
View file @
b8b562c7
...
...
@@ -30,6 +30,9 @@
#define URI_SSL "ssl://"
/** if we should handle openssl initialization (bool_value == 1) or depend on it to be initalized externally (bool_value == 0) */
void
SSLSocket_handleOpensslInit
(
int
bool_value
);
int
SSLSocket_initialize
();
void
SSLSocket_terminate
();
int
SSLSocket_setSocketForSSL
(
networkHandles
*
net
,
MQTTClient_SSLOptions
*
opts
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment