Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
450
Issues
450
List
Boards
Labels
Service Desk
Milestones
Merge Requests
75
Merge Requests
75
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
003533bf
Commit
003533bf
authored
Jul 24, 2014
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Plain Diff
[master] Merge branch 'trac3461'
parents
f4c16c57
769cac66
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
src/lib/util/io/fd_share.cc
src/lib/util/io/fd_share.cc
+10
-6
src/lib/util/tests/memory_segment_local_unittest.cc
src/lib/util/tests/memory_segment_local_unittest.cc
+6
-1
No files found.
src/lib/util/io/fd_share.cc
View file @
003533bf
// Copyright (C) 2010
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2010
, 2014
Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
...
...
@@ -107,11 +107,15 @@ recv_fd(const int sock) {
std
::
memcpy
(
&
fd
,
CMSG_DATA
(
cmsg
),
sizeof
(
int
));
}
free
(
msghdr
.
msg_control
);
// It is strange, but the call can return the same file descriptor as
// one returned previously, even if that one is not closed yet. So,
// we just re-number every one we get, so they are unique.
int
new_fd
(
dup
(
fd
));
int
close_error
(
close
(
fd
));
int
new_fd
=
-
1
;
int
close_error
=
-
1
;
if
(
fd
>=
0
)
{
// It is strange, but the call can return the same file descriptor as
// one returned previously, even if that one is not closed yet. So,
// we just re-number every one we get, so they are unique.
new_fd
=
dup
(
fd
);
close_error
=
close
(
fd
);
}
if
(
close_error
==
-
1
||
new_fd
==
-
1
)
{
// We need to return an error, because something failed. But in case
// it was the previous close, we at least try to close the duped FD.
...
...
src/lib/util/tests/memory_segment_local_unittest.cc
View file @
003533bf
...
...
@@ -59,7 +59,12 @@ TEST(MemorySegmentLocal, TestLocal) {
TEST
(
MemorySegmentLocal
,
TestTooMuchMemory
)
{
auto_ptr
<
MemorySegment
>
segment
(
new
MemorySegmentLocal
());
EXPECT_THROW
(
segment
->
allocate
(
ULONG_MAX
),
bad_alloc
);
// Although it should be perfectly fine to use the ULONG_MAX
// instead of LONG_MAX as the size_t value should be unsigned,
// Valgrind appears to be using the signed value and hence the
// maximum positive value is LONG_MAX for Valgrind. But, this
// should be sufficient to test the "too much memory" conditions.
EXPECT_THROW
(
segment
->
allocate
(
LONG_MAX
),
bad_alloc
);
}
TEST
(
MemorySegmentLocal
,
TestBadDeallocate
)
{
...
...
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