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
edab27ad
Commit
edab27ad
authored
Dec 15, 2017
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some cleanup of testing code
parent
993ecc7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
14 deletions
+12
-14
Socket.c
src/Socket.c
+11
-14
SocketBuffer.c
src/SocketBuffer.c
+1
-0
No files found.
src/Socket.c
View file @
edab27ad
...
@@ -429,8 +429,11 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
...
@@ -429,8 +429,11 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
rc
=
TCPSOCKET_INTERRUPTED
;
rc
=
TCPSOCKET_INTERRUPTED
;
}
}
#else
#else
//#define TESTING
/*#define TCPSOCKET_INTERRUPTED_TESTING
#if defined(TESTING)
This section forces the occasional return of TCPSOCKET_INTERRUPTED,
for testing purposes only!
*/
#if defined(TCPSOCKET_INTERRUPTED_TESTING)
static
int
i
=
0
;
static
int
i
=
0
;
if
(
++
i
>=
10
&&
i
<
21
)
if
(
++
i
>=
10
&&
i
<
21
)
{
{
...
@@ -463,7 +466,7 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
...
@@ -463,7 +466,7 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
}
}
else
else
*
bytes
=
rc
;
*
bytes
=
rc
;
#if defined(TESTING)
#if defined(T
CPSOCKET_INTERRUPTED_T
ESTING)
}
}
#endif
#endif
#endif
#endif
...
@@ -525,7 +528,6 @@ int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** bu
...
@@ -525,7 +528,6 @@ int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** bu
#if defined(OPENSSL)
#if defined(OPENSSL)
SocketBuffer_pendingWrite
(
socket
,
NULL
,
count
+
1
,
iovecs
,
frees1
,
total
,
bytes
);
SocketBuffer_pendingWrite
(
socket
,
NULL
,
count
+
1
,
iovecs
,
frees1
,
total
,
bytes
);
#else
#else
//printf("Partial write for socket %d pending write created\n", socket);
StackTrace_printStack
(
stdout
);
StackTrace_printStack
(
stdout
);
SocketBuffer_pendingWrite
(
socket
,
count
+
1
,
iovecs
,
frees1
,
total
,
bytes
);
SocketBuffer_pendingWrite
(
socket
,
count
+
1
,
iovecs
,
frees1
,
total
,
bytes
);
#endif
#endif
...
@@ -600,7 +602,6 @@ int Socket_close_only(int socket)
...
@@ -600,7 +602,6 @@ int Socket_close_only(int socket)
void
Socket_close
(
int
socket
)
void
Socket_close
(
int
socket
)
{
{
FUNC_ENTRY
;
FUNC_ENTRY
;
//printf("Closing socket %d\n", socket);
Socket_close_only
(
socket
);
Socket_close_only
(
socket
);
FD_CLR
(
socket
,
&
(
s
.
rset_saved
));
FD_CLR
(
socket
,
&
(
s
.
rset_saved
));
if
(
FD_ISSET
(
socket
,
&
(
s
.
pending_wset
)))
if
(
FD_ISSET
(
socket
,
&
(
s
.
pending_wset
)))
...
@@ -713,8 +714,11 @@ int Socket_new(char* addr, int port, int* sock)
...
@@ -713,8 +714,11 @@ int Socket_new(char* addr, int port, int* sock)
if
(
setsockopt
(
*
sock
,
SOL_SOCKET
,
SO_NOSIGPIPE
,
(
void
*
)
&
opt
,
sizeof
(
opt
))
!=
0
)
if
(
setsockopt
(
*
sock
,
SOL_SOCKET
,
SO_NOSIGPIPE
,
(
void
*
)
&
opt
,
sizeof
(
opt
))
!=
0
)
Log
(
LOG_ERROR
,
-
1
,
"Could not set SO_NOSIGPIPE for socket %d"
,
*
sock
);
Log
(
LOG_ERROR
,
-
1
,
"Could not set SO_NOSIGPIPE for socket %d"
,
*
sock
);
#endif
#endif
//#define TESTING1
/*#define SMALL_TCP_BUFFER_TESTING
#if defined(TESTING1)
This section sets the TCP send buffer to a small amount to provoke TCPSOCKET_INTERRUPTED
return codes from send, for testing only!
*/
#if defined(SMALL_TCP_BUFFER_TESTING)
if
(
1
)
if
(
1
)
{
{
int
optsend
=
100
;
//2 * 1440;
int
optsend
=
100
;
//2 * 1440;
...
@@ -825,7 +829,6 @@ int Socket_continueWrite(int socket)
...
@@ -825,7 +829,6 @@ int Socket_continueWrite(int socket)
free
(
pw
->
iovecs
[
i
].
iov_base
);
free
(
pw
->
iovecs
[
i
].
iov_base
);
}
}
rc
=
1
;
/* signal complete */
rc
=
1
;
/* signal complete */
//printf("Partial write complete for socket %d\n", socket);
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
...
@@ -841,7 +844,6 @@ int Socket_continueWrite(int socket)
...
@@ -841,7 +844,6 @@ 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
);
}
}
//printf("Partial write aborted for socket %d\n", socket);
}
}
#if defined(OPENSSL)
#if defined(OPENSSL)
exit:
exit:
...
@@ -863,16 +865,12 @@ int Socket_abortWrite(int socket)
...
@@ -863,16 +865,12 @@ int Socket_abortWrite(int socket)
pending_writes
*
pw
;
pending_writes
*
pw
;
FUNC_ENTRY
;
FUNC_ENTRY
;
//printf("In abortWrite for socket %d\n", socket);
if
((
pw
=
SocketBuffer_getWrite
(
socket
))
==
NULL
)
if
((
pw
=
SocketBuffer_getWrite
(
socket
))
==
NULL
)
goto
exit
;
goto
exit
;
#if defined(OPENSSL)
#if defined(OPENSSL)
if
(
pw
->
ssl
)
if
(
pw
->
ssl
)
{
//rc = SSLSocket_continueWrite(pw);
goto
exit
;
goto
exit
;
}
#endif
#endif
for
(
i
=
0
;
i
<
pw
->
count
;
i
++
)
for
(
i
=
0
;
i
<
pw
->
count
;
i
++
)
...
@@ -884,7 +882,6 @@ int Socket_abortWrite(int socket)
...
@@ -884,7 +882,6 @@ int Socket_abortWrite(int socket)
}
}
}
}
exit:
exit:
//printf("Exit abortWrite for socket %d\n", socket);
FUNC_EXIT_RC
(
rc
);
FUNC_EXIT_RC
(
rc
);
return
rc
;
return
rc
;
}
}
...
...
src/SocketBuffer.c
View file @
edab27ad
...
@@ -318,6 +318,7 @@ void SocketBuffer_queueChar(int socket, char c)
...
@@ -318,6 +318,7 @@ void SocketBuffer_queueChar(int socket, char c)
* @param socket the socket for which the write was interrupted
* @param socket the socket for which the write was interrupted
* @param count the number of iovec buffers
* @param count the number of iovec buffers
* @param iovecs buffer array
* @param iovecs buffer array
* @param frees a set of flags indicating which of the iovecs array should be freed
* @param total total data length to be written
* @param total total data length to be written
* @param bytes actual data length that was written
* @param bytes actual data length that was written
*/
*/
...
...
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