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
d5b74003
Commit
d5b74003
authored
Nov 30, 2017
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More memory cleanup on network errors - #373
parent
ad500799
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
MQTTAsync.c
src/MQTTAsync.c
+2
-1
Socket.c
src/Socket.c
+36
-0
No files found.
src/MQTTAsync.c
View file @
d5b74003
...
@@ -1268,7 +1268,8 @@ static int MQTTAsync_processCommand(void)
...
@@ -1268,7 +1268,8 @@ static int MQTTAsync_processCommand(void)
}
}
else
else
{
{
//command->command.details.pub.destinationName = NULL; /* this will be freed by the protocol code */
if
(
rc
!=
SOCKET_ERROR
)
command
->
command
.
details
.
pub
.
destinationName
=
NULL
;
/* this will be freed by the protocol code */
command
->
client
->
pending_write
=
&
command
->
command
;
command
->
client
->
pending_write
=
&
command
->
command
;
}
}
}
}
...
...
src/Socket.c
View file @
d5b74003
...
@@ -428,6 +428,31 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
...
@@ -428,6 +428,31 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
rc
=
TCPSOCKET_INTERRUPTED
;
rc
=
TCPSOCKET_INTERRUPTED
;
}
}
#else
#else
//#define TESTING
#if defined(TESTING)
static
int
i
=
0
;
if
(
++
i
==
100
)
{
if
(
0
)
{
printf
(
"Deliberately simulating TCPSOCKET_INTERRUPTED
\n
"
);
rc
=
TCPSOCKET_INTERRUPTED
;
/* simulate a network wait */
}
else
{
printf
(
"Deliberately simulating SOCKET_ERROR
\n
"
);
rc
=
SOCKET_ERROR
;
}
/* should *bytes always be 0? */
if
(
1
)
{
printf
(
"Shutdown socket
\n
"
);
shutdown
(
socket
,
SHUT_WR
);
}
}
else
{
#endif
rc
=
writev
(
socket
,
iovecs
,
count
);
rc
=
writev
(
socket
,
iovecs
,
count
);
if
(
rc
==
SOCKET_ERROR
)
if
(
rc
==
SOCKET_ERROR
)
{
{
...
@@ -437,6 +462,9 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
...
@@ -437,6 +462,9 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
}
}
else
else
*
bytes
=
rc
;
*
bytes
=
rc
;
#if defined(TESTING)
}
#endif
#endif
#endif
FUNC_EXIT_RC
(
rc
);
FUNC_EXIT_RC
(
rc
);
return
rc
;
return
rc
;
...
@@ -784,6 +812,14 @@ int Socket_continueWrite(int socket)
...
@@ -784,6 +812,14 @@ int Socket_continueWrite(int socket)
else
else
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 */
{
for
(
i
=
0
;
i
<
pw
->
count
;
i
++
)
{
if
(
pw
->
frees
[
i
])
free
(
pw
->
iovecs
[
i
].
iov_base
);
}
}
#if defined(OPENSSL)
#if defined(OPENSSL)
exit:
exit:
#endif
#endif
...
...
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