Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
100a84ed
Commit
100a84ed
authored
Nov 13, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a socketpair rather than a pipe in this test so that we can set the buffer size portably.
parent
1cf1a0c4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
serialize-async-test.c++
c++/src/capnp/serialize-async-test.c++
+11
-6
No files found.
c++/src/capnp/serialize-async-test.c++
View file @
100a84ed
...
@@ -29,6 +29,8 @@
...
@@ -29,6 +29,8 @@
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <unistd.h>
#include <fcntl.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "test-util.h"
#include "test-util.h"
#include <gtest/gtest.h>
#include <gtest/gtest.h>
...
@@ -90,13 +92,16 @@ protected:
...
@@ -90,13 +92,16 @@ protected:
int
fds
[
2
];
int
fds
[
2
];
SerializeAsyncTest
()
{
SerializeAsyncTest
()
{
KJ_SYSCALL
(
pipe
(
fds
));
// Use a socketpair rather than a pipe so that we can set the buffer size extremely small.
KJ_SYSCALL
(
socketpair
(
AF_UNIX
,
SOCK_STREAM
,
0
,
fds
));
#ifdef F_SETPIPE_SZ
KJ_SYSCALL
(
shutdown
(
fds
[
0
],
SHUT_WR
));
// Force pipe to be small, to test what happens when the write buffer fills up. Note that
KJ_SYSCALL
(
shutdown
(
fds
[
1
],
SHUT_RD
));
// Linux rounds this up to the page size, so we'll still need a large message to hit the limit.
KJ_SYSCALL
(
fcntl
(
fds
[
1
],
F_SETPIPE_SZ
,
(
int
)
64
));
// Request that the buffer size be as small as possible, to force the event loop to kick in.
#endif
uint
zero
=
0
;
KJ_SYSCALL
(
setsockopt
(
fds
[
0
],
SOL_SOCKET
,
SO_RCVBUF
,
&
zero
,
sizeof
(
zero
)));
KJ_SYSCALL
(
setsockopt
(
fds
[
1
],
SOL_SOCKET
,
SO_SNDBUF
,
&
zero
,
sizeof
(
zero
)));
}
}
~
SerializeAsyncTest
()
{
~
SerializeAsyncTest
()
{
close
(
fds
[
0
]);
close
(
fds
[
0
]);
...
...
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