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
690c5ad9
Commit
690c5ad9
authored
May 16, 2015
by
Tom Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PR feedback #1
parent
562f5417
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
71 deletions
+39
-71
Makefile.am
c++/Makefile.am
+1
-2
async-io.c++
c++/src/kj/async-io.c++
+3
-3
io.c++
c++/src/kj/io.c++
+1
-2
iovmax.h
c++/src/kj/iovmax.h
+0
-64
miniposix.h
c++/src/kj/miniposix.h
+34
-0
No files found.
c++/Makefile.am
View file @
690c5ad9
...
@@ -109,7 +109,7 @@ pkgconfigdir = $(libdir)/pkgconfig
...
@@ -109,7 +109,7 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA
=
capnp.pc capnp-rpc.pc
pkgconfig_DATA
=
capnp.pc capnp-rpc.pc
noinst_HEADERS
=
\
noinst_HEADERS
=
\
src/kj/
iovma
x.h
src/kj/
miniposi
x.h
includekj_HEADERS
=
\
includekj_HEADERS
=
\
src/kj/common.h
\
src/kj/common.h
\
...
@@ -123,7 +123,6 @@ includekj_HEADERS = \
...
@@ -123,7 +123,6 @@ includekj_HEADERS = \
src/kj/exception.h
\
src/kj/exception.h
\
src/kj/debug.h
\
src/kj/debug.h
\
src/kj/arena.h
\
src/kj/arena.h
\
src/kj/miniposix.h
\
src/kj/io.h
\
src/kj/io.h
\
src/kj/tuple.h
\
src/kj/tuple.h
\
src/kj/one-of.h
\
src/kj/one-of.h
\
...
...
c++/src/kj/async-io.c++
View file @
690c5ad9
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include "debug.h"
#include "debug.h"
#include "thread.h"
#include "thread.h"
#include "io.h"
#include "io.h"
#include "
iovma
x.h"
#include "
miniposi
x.h"
#include <unistd.h>
#include <unistd.h>
#include <sys/uio.h>
#include <sys/uio.h>
#include <errno.h>
#include <errno.h>
...
@@ -299,7 +299,7 @@ private:
...
@@ -299,7 +299,7 @@ private:
Promise
<
void
>
writeInternal
(
ArrayPtr
<
const
byte
>
firstPiece
,
Promise
<
void
>
writeInternal
(
ArrayPtr
<
const
byte
>
firstPiece
,
ArrayPtr
<
const
ArrayPtr
<
const
byte
>>
morePieces
)
{
ArrayPtr
<
const
ArrayPtr
<
const
byte
>>
morePieces
)
{
const
size_t
iovmax
=
iovMax
(
1
+
morePieces
.
size
());
const
size_t
iovmax
=
kj
::
miniposix
::
iovMax
(
1
+
morePieces
.
size
());
// If there are more than IOV_MAX pieces, we'll only write the first IOV_MAX for now, and
// If there are more than IOV_MAX pieces, we'll only write the first IOV_MAX for now, and
// then we'll loop later.
// then we'll loop later.
KJ_STACK_ARRAY
(
struct
iovec
,
iov
,
kj
::
min
(
1
+
morePieces
.
size
(),
iovmax
),
16
,
128
);
KJ_STACK_ARRAY
(
struct
iovec
,
iov
,
kj
::
min
(
1
+
morePieces
.
size
(),
iovmax
),
16
,
128
);
...
@@ -1110,7 +1110,7 @@ Promise<size_t> DatagramPortImpl::send(
...
@@ -1110,7 +1110,7 @@ Promise<size_t> DatagramPortImpl::send(
msg
.
msg_name
=
const_cast
<
void
*>
(
implicitCast
<
const
void
*>
(
addr
.
getRaw
()));
msg
.
msg_name
=
const_cast
<
void
*>
(
implicitCast
<
const
void
*>
(
addr
.
getRaw
()));
msg
.
msg_namelen
=
addr
.
getRawSize
();
msg
.
msg_namelen
=
addr
.
getRawSize
();
const
size_t
iovmax
=
iovMax
(
pieces
.
size
());
const
size_t
iovmax
=
kj
::
miniposix
::
iovMax
(
pieces
.
size
());
KJ_STACK_ARRAY
(
struct
iovec
,
iov
,
kj
::
min
(
pieces
.
size
(),
iovmax
),
16
,
64
);
KJ_STACK_ARRAY
(
struct
iovec
,
iov
,
kj
::
min
(
pieces
.
size
(),
iovmax
),
16
,
64
);
for
(
size_t
i
:
kj
::
indices
(
pieces
))
{
for
(
size_t
i
:
kj
::
indices
(
pieces
))
{
...
...
c++/src/kj/io.c++
View file @
690c5ad9
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include "io.h"
#include "io.h"
#include "debug.h"
#include "debug.h"
#include "miniposix.h"
#include "miniposix.h"
#include "iovmax.h"
#include <algorithm>
#include <algorithm>
#include <errno.h>
#include <errno.h>
...
@@ -290,7 +289,7 @@ void FdOutputStream::write(ArrayPtr<const ArrayPtr<const byte>> pieces) {
...
@@ -290,7 +289,7 @@ void FdOutputStream::write(ArrayPtr<const ArrayPtr<const byte>> pieces) {
}
}
#else
#else
const
size_t
iovmax
=
iovMax
(
pieces
.
size
());
const
size_t
iovmax
=
miniposix
::
iovMax
(
pieces
.
size
());
while
(
pieces
.
size
()
>
iovmax
)
{
while
(
pieces
.
size
()
>
iovmax
)
{
write
(
pieces
.
slice
(
0
,
iovmax
));
write
(
pieces
.
slice
(
0
,
iovmax
));
pieces
=
pieces
.
slice
(
iovmax
,
pieces
.
size
());
pieces
=
pieces
.
slice
(
iovmax
,
pieces
.
size
());
...
...
c++/src/kj/iovmax.h
deleted
100644 → 0
View file @
562f5417
// Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#ifndef KJ_IOVMAX_H_
#define KJ_IOVMAX_H_
#if !_WIN32
#include <limits.h>
#include <errno.h>
// Apparently, there is a maximum number of iovecs allowed per call. I don't understand why.
// Most platforms define IOV_MAX but Linux defines only UIO_MAXIOV and others, like Hurd,
// define neither.
//
// On platforms where both IOV_MAX and UIO_MAXIOV are undefined, we poke sysconf(_SC_IOV_MAX),
// try to fall back to the POSIX-mandated minimum of _XOPEN_IOV_MAX if that fails.
//
// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html#tag_13_23_03_01
inline
size_t
iovMax
(
size_t
count
)
{
#if defined(IOV_MAX)
// Solaris (and others?)
return
IOV_MAX
;
#elif defined(UIO_MAXIOV)
// Linux
return
UIO_MAXIOV
;
#else
// POSIX mystery meat
long
iovmax
;
errno
=
0
;
if
((
iovmax
=
sysconf
(
_SC_IOV_MAX
))
==
-
1
)
{
// assume iovmax == -1 && errno == 0 means "unbounded"
return
errno
?
_XOPEN_IOV_MAX
:
count
;
}
else
{
return
(
size_t
)
iovmax
;
}
#endif
}
#endif
#endif // KJ_IOVMAX_H_
c++/src/kj/miniposix.h
View file @
690c5ad9
...
@@ -32,6 +32,9 @@
...
@@ -32,6 +32,9 @@
#if _WIN32
#if _WIN32
#include <io.h>
#include <io.h>
#include <direct.h>
#include <direct.h>
#else
#include <limits.h>
#include <errno.h>
#endif
#endif
#if !_WIN32 || __MINGW32__
#if !_WIN32 || __MINGW32__
...
@@ -94,6 +97,37 @@ inline int mkdir(const char* path, int mode) {
...
@@ -94,6 +97,37 @@ inline int mkdir(const char* path, int mode) {
using
::
pipe
;
using
::
pipe
;
using
::
mkdir
;
using
::
mkdir
;
inline
size_t
iovMax
(
size_t
count
)
{
// Apparently, there is a maximum number of iovecs allowed per call. I don't understand why.
// Most platforms define IOV_MAX but Linux defines only UIO_MAXIOV and others, like Hurd,
// define neither.
//
// On platforms where both IOV_MAX and UIO_MAXIOV are undefined, we poke sysconf(_SC_IOV_MAX),
// then try to fall back to the POSIX-mandated minimum of _XOPEN_IOV_MAX if that fails.
//
// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html#tag_13_23_03_01
#if defined(IOV_MAX)
// Solaris (and others?)
return
IOV_MAX
;
#elif defined(UIO_MAXIOV)
// Linux
return
UIO_MAXIOV
;
#else
// POSIX mystery meat
long
iovmax
;
errno
=
0
;
if
((
iovmax
=
sysconf
(
_SC_IOV_MAX
))
==
-
1
)
{
// assume iovmax == -1 && errno == 0 means "unbounded"
return
errno
?
_XOPEN_IOV_MAX
:
count
;
}
else
{
return
(
size_t
)
iovmax
;
}
#endif
}
#endif
#endif
}
// namespace miniposix
}
// namespace miniposix
...
...
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