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
fed9f63e
Commit
fed9f63e
authored
Aug 10, 2007
by
Bradley C. Kuszmaul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More log stuff
git-svn-id:
file:///svn/tokudb@107
c7de825b-a66e-492c-adef-691d508d4ae1
parent
326da930
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
5 deletions
+45
-5
newbrt/log-internal.h
newbrt/log-internal.h
+3
-2
newbrt/log.c
newbrt/log.c
+42
-3
No files found.
newbrt/log-internal.h
View file @
fed9f63e
...
@@ -6,8 +6,9 @@ typedef struct tokulogger *TOKULOGGER;
...
@@ -6,8 +6,9 @@ typedef struct tokulogger *TOKULOGGER;
struct
tokulogger
{
struct
tokulogger
{
enum
typ_tag
tag
;
enum
typ_tag
tag
;
char
*
directory
;
char
*
directory
;
FILE
*
f
;
int
fd
;
int
next_log_file_number
;
int
n_in_file
;
long
long
next_log_file_number
;
char
buf
[
LOGGER_BUF_SIZE
];
char
buf
[
LOGGER_BUF_SIZE
];
int
n_in_buf
;
int
n_in_buf
;
};
};
...
...
newbrt/log.c
View file @
fed9f63e
#include "log-internal.h"
#include "log-internal.h"
#include "memory.h"
#include "memory.h"
#include <sys/types.h>
#include <dirent.h>
#include <dirent.h>
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
int
tokulogger_find_next_unused_log_file
(
const
char
*
directory
,
long
long
*
result
)
{
int
tokulogger_find_next_unused_log_file
(
const
char
*
directory
,
long
long
*
result
)
{
DIR
*
d
=
opendir
(
directory
);
DIR
*
d
=
opendir
(
directory
);
...
@@ -20,7 +25,7 @@ int tokulogger_find_next_unused_log_file(const char *directory, long long *resul
...
@@ -20,7 +25,7 @@ int tokulogger_find_next_unused_log_file(const char *directory, long long *resul
return
0
;
return
0
;
}
}
int
tokulogger_create_and_open_logger
(
const
char
*
directory
)
{
int
tokulogger_create_and_open_logger
(
const
char
*
directory
,
TOKULOGGER
*
resultp
)
{
TAGMALLOC
(
TOKULOGGER
,
result
);
TAGMALLOC
(
TOKULOGGER
,
result
);
if
(
result
==
0
)
return
-
1
;
if
(
result
==
0
)
return
-
1
;
int
r
;
int
r
;
...
@@ -33,8 +38,42 @@ int tokulogger_create_and_open_logger (const char *directory) {
...
@@ -33,8 +38,42 @@ int tokulogger_create_and_open_logger (const char *directory) {
}
}
result
->
directory
=
toku_strdup
(
directory
);
result
->
directory
=
toku_strdup
(
directory
);
if
(
result
->
directory
!=
0
)
goto
died0
;
if
(
result
->
directory
!=
0
)
goto
died0
;
result
->
f
=
0
;
result
->
f
d
=
-
1
;
result
->
next_log_file_number
=
nexti
;
result
->
next_log_file_number
=
nexti
;
result
->
n_in_buf
=
0
;
result
->
n_in_buf
=
0
;
*
resultp
=
result
;
return
0
;
}
int
tokulogger_log_bytes
(
TOKULOGGER
logger
,
int
nbytes
,
char
*
bytes
)
{
int
r
;
if
(
logger
->
fd
==-
1
)
{
int
fnamelen
=
strlen
(
logger
->
directory
)
+
50
;
char
fname
[
fnamelen
];
snprintf
(
fname
,
fnamelen
,
"%s/log%012llu.tokulog"
,
logger
->
directory
,
logger
->
next_log_file_number
);
logger
->
fd
=
creat
(
fname
,
O_EXCL
|
0700
);
if
(
logger
->
fd
==-
1
)
return
errno
;
}
logger
->
next_log_file_number
++
;
if
(
logger
->
n_in_buf
+
nbytes
>
LOGGER_BUF_SIZE
)
{
struct
iovec
v
[
2
];
v
[
0
].
iov_base
=
logger
->
buf
;
v
[
0
].
iov_len
=
logger
->
n_in_buf
;
v
[
1
].
iov_base
=
bytes
;
v
[
1
].
iov_len
=
nbytes
;
r
=
writev
(
logger
->
fd
,
v
,
2
);
if
(
r
!=
logger
->
n_in_buf
+
nbytes
)
return
errno
;
logger
->
n_in_file
+=
logger
->
n_in_buf
+
nbytes
;
logger
->
n_in_buf
=
0
;
if
(
logger
->
n_in_file
>
100
<<
20
)
{
r
=
close
(
logger
->
fd
);
if
(
r
!=
0
)
return
errno
;
logger
->
fd
=
0
;
logger
->
n_in_file
=
0
;
}
}
else
{
memcpy
(
logger
->
buf
+
logger
->
n_in_buf
,
bytes
,
nbytes
);
logger
->
n_in_buf
+=
nbytes
;
}
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