Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
34aa6b70
Commit
34aa6b70
authored
Aug 17, 2008
by
Michael Karcher
Committed by
Alexandre Julliard
Aug 20, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Fix profile cache logic and don't cache new files.
parent
af2d274f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
8 deletions
+67
-8
profile.c
dlls/kernel32/profile.c
+29
-8
profile.c
dlls/kernel32/tests/profile.c
+38
-0
No files found.
dlls/kernel32/profile.c
View file @
34aa6b70
...
...
@@ -702,6 +702,25 @@ static void PROFILE_ReleaseFile(void)
ZeroMemory
(
&
CurProfile
->
LastWriteTime
,
sizeof
(
CurProfile
->
LastWriteTime
));
}
/***********************************************************************
*
* Compares a file time with the current time. If the file time is
* at least 2.1 seconds in the past, return true.
*
* Intended as cache safety measure: The time resolution on FAT is
* two seconds, so files that are not at least two seconds old might
* keep their time even on modification, so don't cache them.
*/
static
BOOL
is_not_current
(
FILETIME
*
ft
)
{
FILETIME
Now
;
LONGLONG
ftll
,
nowll
;
GetSystemTimeAsFileTime
(
&
Now
);
ftll
=
((
LONGLONG
)
ft
->
dwHighDateTime
<<
32
)
+
ft
->
dwLowDateTime
;
nowll
=
((
LONGLONG
)
Now
.
dwHighDateTime
<<
32
)
+
Now
.
dwLowDateTime
;
TRACE
(
"%08x;%08x
\n
"
,(
unsigned
)
ftll
+
21000000
,(
unsigned
)
nowll
);
return
ftll
+
21000000
<
nowll
;
}
/***********************************************************************
* PROFILE_Open
...
...
@@ -780,15 +799,17 @@ static BOOL PROFILE_Open( LPCWSTR filename, BOOL write_access )
if
(
hFile
!=
INVALID_HANDLE_VALUE
)
{
if
(
TRACE_ON
(
profile
))
GetFileTime
(
hFile
,
NULL
,
NULL
,
&
LastWriteTime
);
if
(
!
memcmp
(
&
CurProfile
->
LastWriteTime
,
&
LastWriteTime
,
sizeof
(
FILETIME
)
)
&&
is_not_current
(
&
LastWriteTime
))
TRACE
(
"(%s): already opened (mru=%d)
\n
"
,
debugstr_w
(
buffer
),
i
);
else
{
GetFileTime
(
hFile
,
NULL
,
NULL
,
&
LastWriteTime
);
if
(
memcmp
(
&
CurProfile
->
LastWriteTime
,
&
LastWriteTime
,
sizeof
(
FILETIME
)))
TRACE
(
"(%s): already opened (mru=%d)
\n
"
,
debugstr_w
(
buffer
),
i
);
else
TRACE
(
"(%s): already opened, needs refreshing (mru=%d)
\n
"
,
debugstr_w
(
buffer
),
i
);
TRACE
(
"(%s): already opened, needs refreshing (mru=%d)
\n
"
,
debugstr_w
(
buffer
),
i
);
CurProfile
->
section
=
PROFILE_Load
(
hFile
,
&
CurProfile
->
encoding
);
CurProfile
->
LastWriteTime
=
LastWriteTime
;
}
CloseHandle
(
hFile
);
}
...
...
dlls/kernel32/tests/profile.c
View file @
34aa6b70
...
...
@@ -362,9 +362,42 @@ static void test_profile_delete_on_close()
ok
(
size
==
sizeof
contents
-
1
,
"Test file: partial write
\n
"
);
res
=
GetPrivateProfileInt
(
SECTION
,
KEY
,
0
,
testfile
);
ok
(
res
==
123
,
"Got %d instead of 123
\n
"
,
res
);
/* This also deletes the file */
CloseHandle
(
h
);
}
static
void
test_profile_refresh
(
void
)
{
static
CHAR
testfile
[]
=
".
\\
winetest4.ini"
;
HANDLE
h
;
DWORD
size
,
res
;
static
const
char
contents1
[]
=
"["
SECTION
"]
\n
"
KEY
"=123
\n
"
;
static
const
char
contents2
[]
=
"["
SECTION
"]
\n
"
KEY
"=124
\n
"
;
h
=
CreateFile
(
testfile
,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_DELETE_ON_CLOSE
,
NULL
);
ok
(
WriteFile
(
h
,
contents1
,
sizeof
contents1
-
1
,
&
size
,
NULL
),
"Cannot write test file: %x
\n
"
,
GetLastError
()
);
ok
(
size
==
sizeof
contents1
-
1
,
"Test file: partial write
\n
"
);
res
=
GetPrivateProfileInt
(
SECTION
,
KEY
,
0
,
testfile
);
ok
(
res
==
123
,
"Got %d instead of 123
\n
"
,
res
);
CloseHandle
(
h
);
/* Test proper invalidation of wine's profile file cache */
h
=
CreateFile
(
testfile
,
GENERIC_WRITE
,
FILE_SHARE_READ
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_DELETE_ON_CLOSE
,
NULL
);
ok
(
WriteFile
(
h
,
contents2
,
sizeof
contents2
-
1
,
&
size
,
NULL
),
"Cannot write test file: %x
\n
"
,
GetLastError
()
);
ok
(
size
==
sizeof
contents2
-
1
,
"Test file: partial write
\n
"
);
res
=
GetPrivateProfileInt
(
SECTION
,
KEY
,
0
,
testfile
);
ok
(
res
==
124
,
"Got %d instead of 124
\n
"
,
res
);
/* This also deletes the file */
CloseHandle
(
h
);
}
...
...
@@ -417,6 +450,10 @@ static void test_GetPrivateProfileString(void)
create_test_file
(
filename
,
content
,
sizeof
(
content
));
/* Run this test series with caching. Wine won't cache profile
files younger than 2.1 seconds. */
Sleep
(
2500
);
/* lpAppName is NULL */
lstrcpyA
(
buf
,
"kumquat"
);
ret
=
GetPrivateProfileStringA
(
NULL
,
"name1"
,
"default"
,
...
...
@@ -664,5 +701,6 @@ START_TEST(profile)
test_profile_sections_names
();
test_profile_existing
();
test_profile_delete_on_close
();
test_profile_refresh
();
test_GetPrivateProfileString
();
}
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