Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
308466b5
Commit
308466b5
authored
May 23, 2014
by
Rich Prohaska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#247 fix loader->close fd leak when NOFILE limit exceeded
parent
5804e1f7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
28 deletions
+20
-28
ft/ftloader.cc
ft/ftloader.cc
+4
-0
src/tests/loader-close-nproc-limit.cc
src/tests/loader-close-nproc-limit.cc
+5
-8
src/tests/loader-create-close.cc
src/tests/loader-create-close.cc
+4
-10
src/tests/loader-create-commit-nproc-limit.cc
src/tests/loader-create-commit-nproc-limit.cc
+2
-2
src/tests/loader-create-nproc-limit.cc
src/tests/loader-create-nproc-limit.cc
+5
-8
No files found.
ft/ftloader.cc
View file @
308466b5
...
@@ -356,6 +356,8 @@ int ft_loader_open_temp_file (FTLOADER bl, FIDX *file_idx)
...
@@ -356,6 +356,8 @@ int ft_loader_open_temp_file (FTLOADER bl, FIDX *file_idx)
*/
*/
{
{
int
result
=
0
;
int
result
=
0
;
if
(
result
)
// debug hack
return
result
;
FILE
*
f
=
NULL
;
FILE
*
f
=
NULL
;
int
fd
=
-
1
;
int
fd
=
-
1
;
char
*
fname
=
toku_strdup
(
bl
->
temp_file_template
);
char
*
fname
=
toku_strdup
(
bl
->
temp_file_template
);
...
@@ -2430,6 +2432,8 @@ static int toku_loader_write_ft_from_q (FTLOADER bl,
...
@@ -2430,6 +2432,8 @@ static int toku_loader_write_ft_from_q (FTLOADER bl,
if
(
r
)
{
if
(
r
)
{
result
=
r
;
result
=
r
;
drain_writer_q
(
q
);
drain_writer_q
(
q
);
r
=
toku_os_close
(
fd
);
assert_zero
(
r
);
return
result
;
return
result
;
}
}
FILE
*
pivots_stream
=
toku_bl_fidx2file
(
bl
,
pivots_file
);
FILE
*
pivots_stream
=
toku_bl_fidx2file
(
bl
,
pivots_file
);
...
...
src/tests/loader-close-nproc-limit.cc
View file @
308466b5
...
@@ -85,6 +85,9 @@ PATENT RIGHTS GRANT:
...
@@ -85,6 +85,9 @@ PATENT RIGHTS GRANT:
under this License.
under this License.
*/
*/
// Verify that loader->close works correctly (does not crash, does not leak memory, returns the right error code)
// when the NPROC limit is exceeded.
#ident "Copyright (c) 2010-2013 Tokutek Inc. All rights reserved."
#ident "Copyright (c) 2010-2013 Tokutek Inc. All rights reserved."
#ident "$Id$"
#ident "$Id$"
...
@@ -95,11 +98,7 @@ PATENT RIGHTS GRANT:
...
@@ -95,11 +98,7 @@ PATENT RIGHTS GRANT:
static
int
loader_flags
=
0
;
static
int
loader_flags
=
0
;
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
int
put_multiple_generate
(
DB
*
UU
(
dest_db
),
DB
*
UU
(
src_db
),
DBT_ARRAY
*
UU
(
dest_keys
),
DBT_ARRAY
*
UU
(
dest_vals
),
const
DBT
*
UU
(
src_key
),
const
DBT
*
UU
(
src_val
))
{
static
void
run_test
(
int
ndb
)
{
return
ENOMEM
;
}
static
void
loader_open_close
(
int
ndb
)
{
int
r
;
int
r
;
char
rmcmd
[
32
+
strlen
(
envdir
)];
char
rmcmd
[
32
+
strlen
(
envdir
)];
...
@@ -109,8 +108,6 @@ static void loader_open_close(int ndb) {
...
@@ -109,8 +108,6 @@ static void loader_open_close(int ndb) {
DB_ENV
*
env
;
DB_ENV
*
env
;
r
=
db_env_create
(
&
env
,
0
);
CKERR
(
r
);
r
=
db_env_create
(
&
env
,
0
);
CKERR
(
r
);
r
=
env
->
set_generate_row_callback_for_put
(
env
,
put_multiple_generate
);
CKERR
(
r
);
int
envflags
=
DB_INIT_LOCK
|
DB_INIT_LOG
|
DB_INIT_MPOOL
|
DB_INIT_TXN
|
DB_CREATE
|
DB_PRIVATE
;
int
envflags
=
DB_INIT_LOCK
|
DB_INIT_LOG
|
DB_INIT_MPOOL
|
DB_INIT_TXN
|
DB_CREATE
|
DB_PRIVATE
;
r
=
env
->
open
(
env
,
envdir
,
envflags
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
CKERR
(
r
);
r
=
env
->
open
(
env
,
envdir
,
envflags
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
CKERR
(
r
);
env
->
set_errfile
(
env
,
stderr
);
env
->
set_errfile
(
env
,
stderr
);
...
@@ -196,6 +193,6 @@ static void do_args(int argc, char * const argv[]) {
...
@@ -196,6 +193,6 @@ static void do_args(int argc, char * const argv[]) {
int
test_main
(
int
argc
,
char
*
const
*
argv
)
{
int
test_main
(
int
argc
,
char
*
const
*
argv
)
{
do_args
(
argc
,
argv
);
do_args
(
argc
,
argv
);
loader_open_close
(
1
);
run_test
(
1
);
return
0
;
return
0
;
}
}
src/tests/loader-create-close.cc
View file @
308466b5
...
@@ -97,11 +97,7 @@ PATENT RIGHTS GRANT:
...
@@ -97,11 +97,7 @@ PATENT RIGHTS GRANT:
static
int
loader_flags
=
0
;
static
int
loader_flags
=
0
;
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
int
put_multiple_generate
(
DB
*
UU
(
dest_db
),
DB
*
UU
(
src_db
),
DBT_ARRAY
*
UU
(
dest_keys
),
DBT_ARRAY
*
UU
(
dest_vals
),
const
DBT
*
UU
(
src_key
),
const
DBT
*
UU
(
src_val
))
{
static
void
test_loader_create_close
(
int
ndb
)
{
return
ENOMEM
;
}
static
void
loader_open_abort
(
int
ndb
)
{
int
r
;
int
r
;
char
rmcmd
[
32
+
strlen
(
envdir
)];
char
rmcmd
[
32
+
strlen
(
envdir
)];
...
@@ -111,8 +107,6 @@ static void loader_open_abort(int ndb) {
...
@@ -111,8 +107,6 @@ static void loader_open_abort(int ndb) {
DB_ENV
*
env
;
DB_ENV
*
env
;
r
=
db_env_create
(
&
env
,
0
);
CKERR
(
r
);
r
=
db_env_create
(
&
env
,
0
);
CKERR
(
r
);
r
=
env
->
set_generate_row_callback_for_put
(
env
,
put_multiple_generate
);
CKERR
(
r
);
int
envflags
=
DB_INIT_LOCK
|
DB_INIT_LOG
|
DB_INIT_MPOOL
|
DB_INIT_TXN
|
DB_CREATE
|
DB_PRIVATE
;
int
envflags
=
DB_INIT_LOCK
|
DB_INIT_LOG
|
DB_INIT_MPOOL
|
DB_INIT_TXN
|
DB_CREATE
|
DB_PRIVATE
;
r
=
env
->
open
(
env
,
envdir
,
envflags
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
CKERR
(
r
);
r
=
env
->
open
(
env
,
envdir
,
envflags
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
CKERR
(
r
);
env
->
set_errfile
(
env
,
stderr
);
env
->
set_errfile
(
env
,
stderr
);
...
@@ -181,8 +175,8 @@ static void do_args(int argc, char * const argv[]) {
...
@@ -181,8 +175,8 @@ static void do_args(int argc, char * const argv[]) {
int
test_main
(
int
argc
,
char
*
const
*
argv
)
{
int
test_main
(
int
argc
,
char
*
const
*
argv
)
{
do_args
(
argc
,
argv
);
do_args
(
argc
,
argv
);
loader_open_abort
(
0
);
test_loader_create_close
(
0
);
loader_open_abort
(
1
);
test_loader_create_close
(
1
);
loader_open_abort
(
2
);
test_loader_create_close
(
2
);
return
0
;
return
0
;
}
}
src/tests/loader-create-commit-nproc-limit.cc
View file @
308466b5
...
@@ -99,7 +99,7 @@ PATENT RIGHTS GRANT:
...
@@ -99,7 +99,7 @@ PATENT RIGHTS GRANT:
static
int
loader_flags
=
0
;
static
int
loader_flags
=
0
;
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
void
loader_create_commi
t
(
int
ndb
)
{
static
void
run_tes
t
(
int
ndb
)
{
int
r
;
int
r
;
char
rmcmd
[
32
+
strlen
(
envdir
)];
char
rmcmd
[
32
+
strlen
(
envdir
)];
...
@@ -206,6 +206,6 @@ static void do_args(int argc, char * const argv[]) {
...
@@ -206,6 +206,6 @@ static void do_args(int argc, char * const argv[]) {
int
test_main
(
int
argc
,
char
*
const
*
argv
)
{
int
test_main
(
int
argc
,
char
*
const
*
argv
)
{
do_args
(
argc
,
argv
);
do_args
(
argc
,
argv
);
loader_create_commi
t
(
1
);
run_tes
t
(
1
);
return
0
;
return
0
;
}
}
src/tests/loader-create-nproc-limit.cc
View file @
308466b5
...
@@ -85,6 +85,9 @@ PATENT RIGHTS GRANT:
...
@@ -85,6 +85,9 @@ PATENT RIGHTS GRANT:
under this License.
under this License.
*/
*/
// Verify that env->create_loader works correctly (does not crash, does not leak memory, returns the right error code)
// when the NPROC limit is exceeded.
#ident "Copyright (c) 2010-2013 Tokutek Inc. All rights reserved."
#ident "Copyright (c) 2010-2013 Tokutek Inc. All rights reserved."
#ident "$Id$"
#ident "$Id$"
...
@@ -95,11 +98,7 @@ PATENT RIGHTS GRANT:
...
@@ -95,11 +98,7 @@ PATENT RIGHTS GRANT:
static
int
loader_flags
=
0
;
static
int
loader_flags
=
0
;
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
const
char
*
envdir
=
TOKU_TEST_FILENAME
;
static
int
put_multiple_generate
(
DB
*
UU
(
dest_db
),
DB
*
UU
(
src_db
),
DBT_ARRAY
*
UU
(
dest_keys
),
DBT_ARRAY
*
UU
(
dest_vals
),
const
DBT
*
UU
(
src_key
),
const
DBT
*
UU
(
src_val
))
{
static
void
run_test
(
int
ndb
)
{
return
ENOMEM
;
}
static
void
loader_open_close
(
int
ndb
)
{
int
r
;
int
r
;
char
rmcmd
[
32
+
strlen
(
envdir
)];
char
rmcmd
[
32
+
strlen
(
envdir
)];
...
@@ -109,8 +108,6 @@ static void loader_open_close(int ndb) {
...
@@ -109,8 +108,6 @@ static void loader_open_close(int ndb) {
DB_ENV
*
env
;
DB_ENV
*
env
;
r
=
db_env_create
(
&
env
,
0
);
CKERR
(
r
);
r
=
db_env_create
(
&
env
,
0
);
CKERR
(
r
);
r
=
env
->
set_generate_row_callback_for_put
(
env
,
put_multiple_generate
);
CKERR
(
r
);
int
envflags
=
DB_INIT_LOCK
|
DB_INIT_LOG
|
DB_INIT_MPOOL
|
DB_INIT_TXN
|
DB_CREATE
|
DB_PRIVATE
;
int
envflags
=
DB_INIT_LOCK
|
DB_INIT_LOG
|
DB_INIT_MPOOL
|
DB_INIT_TXN
|
DB_CREATE
|
DB_PRIVATE
;
r
=
env
->
open
(
env
,
envdir
,
envflags
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
CKERR
(
r
);
r
=
env
->
open
(
env
,
envdir
,
envflags
,
S_IRWXU
+
S_IRWXG
+
S_IRWXO
);
CKERR
(
r
);
env
->
set_errfile
(
env
,
stderr
);
env
->
set_errfile
(
env
,
stderr
);
...
@@ -197,6 +194,6 @@ static void do_args(int argc, char * const argv[]) {
...
@@ -197,6 +194,6 @@ static void do_args(int argc, char * const argv[]) {
int
test_main
(
int
argc
,
char
*
const
*
argv
)
{
int
test_main
(
int
argc
,
char
*
const
*
argv
)
{
do_args
(
argc
,
argv
);
do_args
(
argc
,
argv
);
loader_open_close
(
1
);
run_test
(
1
);
return
0
;
return
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