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
2cff9d01
Commit
2cff9d01
authored
Dec 11, 2017
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't try ack writes for sockets with pending output, missing connect failure call #373
parent
d889b818
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
40 deletions
+61
-40
MQTTAsync.c
src/MQTTAsync.c
+24
-11
MQTTProtocolClient.c
src/MQTTProtocolClient.c
+18
-11
MQTTProtocolClient.h
src/MQTTProtocolClient.h
+8
-4
StackTrace.c
src/StackTrace.c
+6
-9
StackTrace.h
src/StackTrace.h
+5
-5
No files found.
src/MQTTAsync.c
View file @
2cff9d01
...
@@ -1298,8 +1298,21 @@ static int MQTTAsync_processCommand(void)
...
@@ -1298,8 +1298,21 @@ static int MQTTAsync_processCommand(void)
else
if
(
command
->
command
.
type
==
DISCONNECT
)
else
if
(
command
->
command
.
type
==
DISCONNECT
)
{
{
if
(
command
->
client
->
c
->
connect_state
!=
0
||
command
->
client
->
c
->
connected
!=
0
)
if
(
command
->
client
->
c
->
connect_state
!=
0
||
command
->
client
->
c
->
connected
!=
0
)
{
if
(
command
->
client
->
c
->
connect_state
!=
0
)
{
{
command
->
client
->
c
->
connect_state
=
-
2
;
command
->
client
->
c
->
connect_state
=
-
2
;
if
(
command
->
client
->
connect
.
onFailure
)
{
MQTTAsync_failureData
data
;
data
.
token
=
0
;
data
.
code
=
-
2
;
data
.
message
=
NULL
;
Log
(
TRACE_MIN
,
-
1
,
"Calling connect failure for client %s"
,
command
->
client
->
c
->
clientID
);
(
*
(
command
->
client
->
connect
.
onFailure
))(
command
->
client
->
connect
.
context
,
&
data
);
}
}
MQTTAsync_checkDisconnect
(
command
->
client
,
&
command
->
command
);
MQTTAsync_checkDisconnect
(
command
->
client
,
&
command
->
command
);
}
}
}
}
...
...
src/MQTTProtocolClient.c
View file @
2cff9d01
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2009, 201
3
IBM Corp.
* Copyright (c) 2009, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
* Ian Craggs - fix for bug 421103 - trying to write to same socket, in retry
* Ian Craggs - fix for bug 421103 - trying to write to same socket, in retry
* Rong Xiang, Ian Craggs - C++ compatibility
* Rong Xiang, Ian Craggs - C++ compatibility
* Ian Craggs - turn off DUP flag for PUBREL - MQTT 3.1.1
* Ian Craggs - turn off DUP flag for PUBREL - MQTT 3.1.1
* Ian Craggs - ensure that acks are not sent if write is outstanding on socket
*******************************************************************************/
*******************************************************************************/
/**
/**
...
@@ -275,6 +276,8 @@ int MQTTProtocol_handlePublishes(void* pack, int sock)
...
@@ -275,6 +276,8 @@ int MQTTProtocol_handlePublishes(void* pack, int sock)
if
(
publish
->
header
.
bits
.
qos
==
0
)
if
(
publish
->
header
.
bits
.
qos
==
0
)
Protocol_processPublication
(
publish
,
client
);
Protocol_processPublication
(
publish
,
client
);
else
if
(
!
Socket_noPendingWrites
(
sock
))
rc
=
SOCKET_ERROR
;
/* queue acks? */
else
if
(
publish
->
header
.
bits
.
qos
==
1
)
else
if
(
publish
->
header
.
bits
.
qos
==
1
)
{
{
/* send puback before processing the publications because a lot of return publications could fill up the socket buffer */
/* send puback before processing the publications because a lot of return publications could fill up the socket buffer */
...
@@ -420,6 +423,8 @@ int MQTTProtocol_handlePubrels(void* pack, int sock)
...
@@ -420,6 +423,8 @@ int MQTTProtocol_handlePubrels(void* pack, int sock)
{
{
if
(
pubrel
->
header
.
bits
.
dup
==
0
)
if
(
pubrel
->
header
.
bits
.
dup
==
0
)
Log
(
TRACE_MIN
,
3
,
NULL
,
"PUBREL"
,
client
->
clientID
,
pubrel
->
msgId
);
Log
(
TRACE_MIN
,
3
,
NULL
,
"PUBREL"
,
client
->
clientID
,
pubrel
->
msgId
);
else
if
(
!
Socket_noPendingWrites
(
sock
))
rc
=
SOCKET_ERROR
;
/* queue acks? */
else
else
/* Apparently this is "normal" behaviour, so we don't need to issue a warning */
/* Apparently this is "normal" behaviour, so we don't need to issue a warning */
rc
=
MQTTPacket_send_pubcomp
(
pubrel
->
msgId
,
&
client
->
net
,
client
->
clientID
);
rc
=
MQTTPacket_send_pubcomp
(
pubrel
->
msgId
,
&
client
->
net
,
client
->
clientID
);
...
@@ -431,6 +436,8 @@ int MQTTProtocol_handlePubrels(void* pack, int sock)
...
@@ -431,6 +436,8 @@ int MQTTProtocol_handlePubrels(void* pack, int sock)
Log
(
TRACE_MIN
,
4
,
NULL
,
"PUBREL"
,
client
->
clientID
,
pubrel
->
msgId
,
m
->
qos
);
Log
(
TRACE_MIN
,
4
,
NULL
,
"PUBREL"
,
client
->
clientID
,
pubrel
->
msgId
,
m
->
qos
);
else
if
(
m
->
nextMessageType
!=
PUBREL
)
else
if
(
m
->
nextMessageType
!=
PUBREL
)
Log
(
TRACE_MIN
,
5
,
NULL
,
"PUBREL"
,
client
->
clientID
,
pubrel
->
msgId
);
Log
(
TRACE_MIN
,
5
,
NULL
,
"PUBREL"
,
client
->
clientID
,
pubrel
->
msgId
);
else
if
(
!
Socket_noPendingWrites
(
sock
))
rc
=
SOCKET_ERROR
;
/* queue acks? */
else
else
{
{
Publish
publish
;
Publish
publish
;
...
...
src/MQTTProtocolClient.h
View file @
2cff9d01
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2009, 201
3
IBM Corp.
* Copyright (c) 2009, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
* Ian Craggs, Allan Stockdill-Mander - SSL updates
* Ian Craggs, Allan Stockdill-Mander - SSL updates
* Ian Craggs - MQTT 3.1.1 updates
* Ian Craggs - MQTT 3.1.1 updates
* Rong Xiang, Ian Craggs - C++ compatibility
* Rong Xiang, Ian Craggs - C++ compatibility
* Ian Craggs - add debug definition of MQTTStrdup for when needed
*******************************************************************************/
*******************************************************************************/
#if !defined(MQTTPROTOCOLCLIENT_H)
#if !defined(MQTTPROTOCOLCLIENT_H)
...
@@ -52,4 +53,7 @@ void MQTTProtocol_freeMessageList(List* msgList);
...
@@ -52,4 +53,7 @@ void MQTTProtocol_freeMessageList(List* msgList);
char
*
MQTTStrncpy
(
char
*
dest
,
const
char
*
src
,
size_t
num
);
char
*
MQTTStrncpy
(
char
*
dest
,
const
char
*
src
,
size_t
num
);
char
*
MQTTStrdup
(
const
char
*
src
);
char
*
MQTTStrdup
(
const
char
*
src
);
//#define MQTTStrdup(src) MQTTStrncpy(malloc(strlen(src)+1), src, strlen(src)+1)
#endif
#endif
src/StackTrace.c
View file @
2cff9d01
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2009, 201
4
IBM Corp.
* Copyright (c) 2009, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -170,13 +170,11 @@ void StackTrace_printStack(FILE* dest)
...
@@ -170,13 +170,11 @@ void StackTrace_printStack(FILE* dest)
}
}
char
*
StackTrace_get
(
thread_id_type
threadid
)
char
*
StackTrace_get
(
thread_id_type
threadid
,
char
*
buf
,
int
bufsize
)
{
{
int
bufsize
=
256
;
char
*
buf
=
NULL
;
int
t
=
0
;
int
t
=
0
;
if
(
(
buf
=
malloc
(
bufsize
))
==
NULL
)
if
(
bufsize
<
100
)
goto
exit
;
goto
exit
;
buf
[
0
]
=
'\0'
;
buf
[
0
]
=
'\0'
;
for
(
t
=
0
;
t
<
thread_count
;
++
t
)
for
(
t
=
0
;
t
<
thread_count
;
++
t
)
...
@@ -204,4 +202,3 @@ char* StackTrace_get(thread_id_type threadid)
...
@@ -204,4 +202,3 @@ char* StackTrace_get(thread_id_type threadid)
exit:
exit:
return
buf
;
return
buf
;
}
}
src/StackTrace.h
View file @
2cff9d01
/*******************************************************************************
/*******************************************************************************
* Copyright (c) 2009, 201
4
IBM Corp.
* Copyright (c) 2009, 201
7
IBM Corp.
*
*
* All rights reserved. This program and the accompanying materials
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* are made available under the terms of the Eclipse Public License v1.0
...
@@ -66,6 +66,6 @@ void StackTrace_entry(const char* name, int line, enum LOG_LEVELS trace);
...
@@ -66,6 +66,6 @@ void StackTrace_entry(const char* name, int line, enum LOG_LEVELS trace);
void
StackTrace_exit
(
const
char
*
name
,
int
line
,
void
*
return_value
,
enum
LOG_LEVELS
trace
);
void
StackTrace_exit
(
const
char
*
name
,
int
line
,
void
*
return_value
,
enum
LOG_LEVELS
trace
);
void
StackTrace_printStack
(
FILE
*
dest
);
void
StackTrace_printStack
(
FILE
*
dest
);
char
*
StackTrace_get
(
thread_id_type
);
char
*
StackTrace_get
(
thread_id_type
,
char
*
buf
,
int
bufsize
);
#endif
/* STACKTRACE_H_ */
#endif
/* STACKTRACE_H_ */
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