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
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
Kirill Smelkov
mariadb
Commits
09fc3594
Commit
09fc3594
authored
May 05, 2004
by
marko@hundin.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InnoDB: os0file.c: Lock files exclusively (Bug #3608)
parent
10db9f4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
7 deletions
+48
-7
innobase/os/os0file.c
innobase/os/os0file.c
+48
-7
No files found.
innobase/os/os0file.c
View file @
09fc3594
...
@@ -302,7 +302,7 @@ os_file_handle_error(
...
@@ -302,7 +302,7 @@ os_file_handle_error(
/* out: TRUE if we should retry the
/* out: TRUE if we should retry the
operation */
operation */
os_file_t
file
,
/* in: file pointer */
os_file_t
file
,
/* in: file pointer */
c
har
*
name
,
/* in: name of a file or NULL */
c
onst
char
*
name
,
/* in: name of a file or NULL */
const
char
*
operation
)
/* in: operation */
const
char
*
operation
)
/* in: operation */
{
{
ulint
err
;
ulint
err
;
...
@@ -358,6 +358,32 @@ os_file_handle_error(
...
@@ -358,6 +358,32 @@ os_file_handle_error(
return
(
FALSE
);
return
(
FALSE
);
}
}
#if !defined(__WIN__) && !defined(UNIV_HOTBACKUP)
/********************************************************************
Obtain an exclusive lock on a file. */
static
int
os_file_lock
(
/*=========*/
/* out: 0 on success */
int
fd
,
/* in: file descriptor */
const
char
*
name
)
/* in: file name */
{
struct
flock
lk
;
lk
.
l_type
=
F_WRLCK
;
lk
.
l_whence
=
SEEK_SET
;
lk
.
l_start
=
lk
.
l_len
=
0
;
if
(
fcntl
(
fd
,
F_SETLK
,
&
lk
)
==
-
1
)
{
fprintf
(
stderr
,
"InnoDB: Unable to lock %s"
,
name
);
perror
(
": fcntl"
);
close
(
fd
);
return
(
-
1
);
}
return
0
;
}
#endif
/* !defined(__WIN__) && !defined(UNIV_HOTBACKUP) */
/********************************************************************
/********************************************************************
Creates the seek mutexes used in positioned reads and writes. */
Creates the seek mutexes used in positioned reads and writes. */
...
@@ -441,7 +467,7 @@ try_again:
...
@@ -441,7 +467,7 @@ try_again:
}
}
return
(
file
);
return
(
file
);
#else
#else
/* __WIN__ */
os_file_t
file
;
os_file_t
file
;
int
create_flag
;
int
create_flag
;
ibool
retry
;
ibool
retry
;
...
@@ -478,12 +504,17 @@ try_again:
...
@@ -478,12 +504,17 @@ try_again:
if
(
retry
)
{
if
(
retry
)
{
goto
try_again
;
goto
try_again
;
}
}
#ifndef UNIV_HOTBACKUP
}
else
if
(
os_file_lock
(
file
,
name
))
{
*
success
=
FALSE
;
file
=
-
1
;
#endif
}
else
{
}
else
{
*
success
=
TRUE
;
*
success
=
TRUE
;
}
}
return
(
file
);
return
(
file
);
#endif
#endif
/* __WIN__ */
}
}
/********************************************************************
/********************************************************************
...
@@ -544,7 +575,7 @@ os_file_create_simple_no_error_handling(
...
@@ -544,7 +575,7 @@ os_file_create_simple_no_error_handling(
}
}
return
(
file
);
return
(
file
);
#else
#else
/* __WIN__ */
os_file_t
file
;
os_file_t
file
;
int
create_flag
;
int
create_flag
;
...
@@ -572,12 +603,17 @@ os_file_create_simple_no_error_handling(
...
@@ -572,12 +603,17 @@ os_file_create_simple_no_error_handling(
if
(
file
==
-
1
)
{
if
(
file
==
-
1
)
{
*
success
=
FALSE
;
*
success
=
FALSE
;
#ifndef UNIV_HOTBACKUP
}
else
if
(
os_file_lock
(
file
,
name
))
{
*
success
=
FALSE
;
file
=
-
1
;
#endif
}
else
{
}
else
{
*
success
=
TRUE
;
*
success
=
TRUE
;
}
}
return
(
file
);
return
(
file
);
#endif
#endif
/* __WIN__ */
}
}
/********************************************************************
/********************************************************************
...
@@ -689,7 +725,7 @@ try_again:
...
@@ -689,7 +725,7 @@ try_again:
}
}
return
(
file
);
return
(
file
);
#else
#else
/* __WIN__ */
os_file_t
file
;
os_file_t
file
;
int
create_flag
;
int
create_flag
;
ibool
retry
;
ibool
retry
;
...
@@ -772,12 +808,17 @@ try_again:
...
@@ -772,12 +808,17 @@ try_again:
if
(
retry
)
{
if
(
retry
)
{
goto
try_again
;
goto
try_again
;
}
}
#ifndef UNIV_HOTBACKUP
}
else
if
(
os_file_lock
(
file
,
name
))
{
*
success
=
FALSE
;
file
=
-
1
;
#endif
}
else
{
}
else
{
*
success
=
TRUE
;
*
success
=
TRUE
;
}
}
return
(
file
);
return
(
file
);
#endif
#endif
/* __WIN__ */
}
}
/***************************************************************************
/***************************************************************************
...
...
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