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
82275178
Commit
82275178
authored
Dec 01, 2017
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some corrections for failing socket writes #385
parent
6fa19a82
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
MQTTAsync.c
src/MQTTAsync.c
+6
-3
Socket.c
src/Socket.c
+10
-4
No files found.
src/MQTTAsync.c
View file @
82275178
...
@@ -1082,7 +1082,7 @@ static void MQTTAsync_writeComplete(int socket)
...
@@ -1082,7 +1082,7 @@ static void MQTTAsync_writeComplete(int socket)
if
(
cur_response
)
/* we found a response */
if
(
cur_response
)
/* we found a response */
{
{
if
(
command
->
onSuccess
)
if
(
command
->
type
==
PUBLISH
&&
command
->
onSuccess
)
{
{
MQTTAsync_successData
data
;
MQTTAsync_successData
data
;
...
@@ -1095,8 +1095,11 @@ static void MQTTAsync_writeComplete(int socket)
...
@@ -1095,8 +1095,11 @@ static void MQTTAsync_writeComplete(int socket)
Log
(
TRACE_MIN
,
-
1
,
"Calling publish success for client %s"
,
m
->
c
->
clientID
);
Log
(
TRACE_MIN
,
-
1
,
"Calling publish success for client %s"
,
m
->
c
->
clientID
);
(
*
(
command
->
onSuccess
))(
command
->
context
,
&
data
);
(
*
(
command
->
onSuccess
))(
command
->
context
,
&
data
);
}
}
ListDetach
(
m
->
responses
,
com
);
if
(
com
)
MQTTAsync_freeCommand
(
com
);
{
ListDetach
(
m
->
responses
,
com
);
MQTTAsync_freeCommand
(
com
);
}
}
}
m
->
pending_write
=
NULL
;
m
->
pending_write
=
NULL
;
}
}
...
...
src/Socket.c
View file @
82275178
...
@@ -431,9 +431,9 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
...
@@ -431,9 +431,9 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
//#define TESTING
//#define TESTING
#if defined(TESTING)
#if defined(TESTING)
static
int
i
=
0
;
static
int
i
=
0
;
if
(
++
i
==
100
)
if
(
++
i
%
100
==
1
)
{
{
if
(
0
)
if
(
1
)
{
{
printf
(
"Deliberately simulating TCPSOCKET_INTERRUPTED
\n
"
);
printf
(
"Deliberately simulating TCPSOCKET_INTERRUPTED
\n
"
);
rc
=
TCPSOCKET_INTERRUPTED
;
/* simulate a network wait */
rc
=
TCPSOCKET_INTERRUPTED
;
/* simulate a network wait */
...
@@ -807,10 +807,14 @@ int Socket_continueWrite(int socket)
...
@@ -807,10 +807,14 @@ int Socket_continueWrite(int socket)
if
(
pw
->
frees
[
i
])
if
(
pw
->
frees
[
i
])
free
(
pw
->
iovecs
[
i
].
iov_base
);
free
(
pw
->
iovecs
[
i
].
iov_base
);
}
}
rc
=
1
;
/* signal complete */
Log
(
TRACE_MIN
,
-
1
,
"ContinueWrite: partial write now complete for socket %d"
,
socket
);
Log
(
TRACE_MIN
,
-
1
,
"ContinueWrite: partial write now complete for socket %d"
,
socket
);
}
}
else
else
{
rc
=
0
;
/* signal not complete */
Log
(
TRACE_MIN
,
-
1
,
"ContinueWrite wrote +%lu bytes on socket %d"
,
bytes
,
socket
);
Log
(
TRACE_MIN
,
-
1
,
"ContinueWrite wrote +%lu bytes on socket %d"
,
bytes
,
socket
);
}
}
}
else
/* if we got SOCKET_ERROR we need to clean up anyway - a partial write is no good anymore */
else
/* if we got SOCKET_ERROR we need to clean up anyway - a partial write is no good anymore */
{
{
...
@@ -842,7 +846,9 @@ int Socket_continueWrites(fd_set* pwset)
...
@@ -842,7 +846,9 @@ int Socket_continueWrites(fd_set* pwset)
while
(
curpending
)
while
(
curpending
)
{
{
int
socket
=
*
(
int
*
)(
curpending
->
content
);
int
socket
=
*
(
int
*
)(
curpending
->
content
);
if
(
FD_ISSET
(
socket
,
pwset
)
&&
Socket_continueWrite
(
socket
))
int
rc
=
0
;
if
(
FD_ISSET
(
socket
,
pwset
)
&&
(
rc
=
Socket_continueWrite
(
socket
)))
{
{
if
(
!
SocketBuffer_writeComplete
(
socket
))
if
(
!
SocketBuffer_writeComplete
(
socket
))
Log
(
LOG_SEVERE
,
-
1
,
"Failed to remove pending write from socket buffer list"
);
Log
(
LOG_SEVERE
,
-
1
,
"Failed to remove pending write from socket buffer list"
);
...
@@ -854,7 +860,7 @@ int Socket_continueWrites(fd_set* pwset)
...
@@ -854,7 +860,7 @@ int Socket_continueWrites(fd_set* pwset)
}
}
curpending
=
s
.
write_pending
->
current
;
curpending
=
s
.
write_pending
->
current
;
if
(
writecomplete
)
if
(
rc
==
1
&&
writecomplete
)
(
*
writecomplete
)(
socket
);
(
*
writecomplete
)(
socket
);
}
}
else
else
...
...
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