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
L
lyskom-server-ceder-1616-generations-topgit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Per Cederqvist
lyskom-server-ceder-1616-generations-topgit
Commits
8903b938
Commit
8903b938
authored
Apr 18, 2010
by
Per Cederqvist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch refactor-cached_get_text-part-2.patch
parent
560a74da
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
55 deletions
+65
-55
.topdeps
.topdeps
+1
-1
.topmsg
.topmsg
+1
-1
src/server/dbck-cache.c
src/server/dbck-cache.c
+6
-26
src/server/simple-cache.c
src/server/simple-cache.c
+5
-26
src/server/text-store.c
src/server/text-store.c
+47
-0
src/server/text-store.h
src/server/text-store.h
+5
-1
No files found.
.topdeps
View file @
8903b938
introduce-generation_position
refactor-cached_get_text
.topmsg
View file @
8903b938
From: Per Cederqvist <ceder@lysator.liu.se>
From: Per Cederqvist <ceder@lysator.liu.se>
Subject: patch refactor-cached_get_text.patch
Subject: patch refactor-cached_get_text
-part-2
.patch
src/server/dbck-cache.c
View file @
8903b938
...
@@ -80,6 +80,7 @@
...
@@ -80,6 +80,7 @@
#include "local-to-global.h"
#include "local-to-global.h"
#include "unused.h"
#include "unused.h"
#include "eintr.h"
#include "eintr.h"
#include "text-store.h"
/*
/*
* All functions that can fail sets kom_errno to a suitable value
* All functions that can fail sets kom_errno to a suitable value
...
@@ -324,41 +325,20 @@ cached_conf_exists(Conf_no conf_no)
...
@@ -324,41 +325,20 @@ cached_conf_exists(Conf_no conf_no)
extern
String
extern
String
cached_get_text
(
Text_no
text
)
cached_get_text
(
Text_no
text
)
{
{
String
the_string
;
String
the_string
=
EMPTY_STRING
;
Text_stat
*
t_stat
;
Text_stat
*
t_stat
;
TRACE2
(
"cached_get_text %lu
\n
"
,
text
);
TRACE2
(
"cached_get_text %lu
\n
"
,
text
);
if
(
(
t_stat
=
cached_get_text_stat
(
text
))
==
NULL
)
if
(
(
t_stat
=
cached_get_text_stat
(
text
))
==
NULL
)
return
EMPTY_STRING
;
return
EMPTY_STRING
;
else
if
(
t_stat
->
text_store
.
generation
==
0
)
else
if
(
text_store_load_text
(
text
,
t_stat
,
&
the_string
,
text_file
)
!=
OK
)
{
the_string
.
string
=
tmp_alloc
(
t_stat
->
no_of_chars
);
the_string
.
len
=
t_stat
->
no_of_chars
;
if
(
fseek
(
text_file
,
t_stat
->
text_store
.
file_pos
,
SEEK_SET
)
!=
0
)
{
kom_log
(
"Failed to seek to %ld in text mass file: %s.
\n
"
,
t_stat
->
text_store
.
file_pos
,
strerror
(
errno
));
return
EMPTY_STRING
;
return
EMPTY_STRING
;
}
if
(
fread
(
the_string
.
string
,
sizeof
(
char
),
the_string
.
len
,
text_file
)
!=
(
size_t
)
the_string
.
len
)
{
kom_log
(
"WARNING: cached_get_text: premature end on text %lu
\n
"
,
text
);
return
EMPTY_STRING
;
}
return
the_string
;
return
the_string
;
}
else
{
#warning Generation > 0 not yet handled
restart_kom
(
"Only generation 0 is handled.
\n
"
);
}
}
}
extern
Text_stat
*
/* NULL on error */
extern
Text_stat
*
/* NULL on error */
cached_get_text_stat
(
Text_no
text
)
cached_get_text_stat
(
Text_no
text
)
{
{
...
...
src/server/simple-cache.c
View file @
8903b938
...
@@ -94,6 +94,7 @@
...
@@ -94,6 +94,7 @@
#include "stats.h"
#include "stats.h"
#include "services.h"
#include "services.h"
#include "manipulate.h"
#include "manipulate.h"
#include "text-store.h"
/*
/*
* Possible improvements:
* Possible improvements:
...
@@ -1045,7 +1046,7 @@ cached_conf_exists(Conf_no conf_no)
...
@@ -1045,7 +1046,7 @@ cached_conf_exists(Conf_no conf_no)
extern
String
extern
String
cached_get_text
(
Text_no
text
)
cached_get_text
(
Text_no
text
)
{
{
String
the_string
;
String
the_string
=
EMPTY_STRING
;
Text_stat
*
t_stat
;
Text_stat
*
t_stat
;
LOGACC
(
lt_text_mass
,
text
);
LOGACC
(
lt_text_mass
,
text
);
...
@@ -1053,32 +1054,10 @@ cached_get_text( Text_no text )
...
@@ -1053,32 +1054,10 @@ cached_get_text( Text_no text )
if
(
(
t_stat
=
cached_get_text_stat
(
text
))
==
NULL
)
if
(
(
t_stat
=
cached_get_text_stat
(
text
))
==
NULL
)
return
EMPTY_STRING
;
return
EMPTY_STRING
;
else
if
(
t_stat
->
text_store
.
generation
==
0
)
else
if
(
text_store_load_text
(
text
,
t_stat
,
&
the_string
,
text_file
)
!=
OK
)
{
the_string
.
string
=
tmp_alloc
(
t_stat
->
no_of_chars
);
the_string
.
len
=
t_stat
->
no_of_chars
;
if
(
fseek
(
text_file
,
t_stat
->
text_store
.
file_pos
,
SEEK_SET
)
!=
0
)
{
kom_log
(
"Failed to seek to %ld in text mass file: %s.
\n
"
,
t_stat
->
text_store
.
file_pos
,
strerror
(
errno
));
return
EMPTY_STRING
;
}
if
(
fread
(
the_string
.
string
,
sizeof
(
char
),
the_string
.
len
,
text_file
)
!=
(
size_t
)
the_string
.
len
)
{
kom_log
(
"WARNING: cached_get_text: premature end on text %lu
\n
"
,
text
);
return
EMPTY_STRING
;
return
EMPTY_STRING
;
}
return
the_string
;
return
the_string
;
}
else
{
#warning Generation > 0 not yet handled
restart_kom
(
"Only generation 0 is handled.
\n
"
);
}
}
}
...
...
src/server/text-store.c
View file @
8903b938
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include "log.h"
#include "server/smalloc.h"
#include "kom-types.h"
#include "lyskomd.h"
#include "text-store.h"
#include "text-store.h"
extern
Success
text_store_load_text
(
Text_no
tno
,
const
Text_stat
*
t_stat
,
String
*
res
,
FILE
*
text_file
)
{
if
(
t_stat
->
text_store
.
generation
==
0
)
{
if
(
fseek
(
text_file
,
t_stat
->
text_store
.
file_pos
,
SEEK_SET
)
!=
0
)
{
kom_log
(
"Failed to seek to %ld in text mass file: %s.
\n
"
,
t_stat
->
text_store
.
file_pos
,
strerror
(
errno
));
return
FAILURE
;
}
res
->
string
=
tmp_alloc
(
t_stat
->
no_of_chars
);
res
->
len
=
t_stat
->
no_of_chars
;
if
(
fread
(
res
->
string
,
sizeof
(
char
),
res
->
len
,
text_file
)
!=
(
size_t
)
res
->
len
)
{
kom_log
(
"WARNING: cached_get_text: premature end on text %lu
\n
"
,
tno
);
return
FAILURE
;
}
return
OK
;
}
else
{
#warning Generation > 0 not yet handled
restart_kom
(
"Only generation 0 is handled.
\n
"
);
}
}
src/server/text-store.h
View file @
8903b938
/* still empty */
extern
Success
text_store_load_text
(
Text_no
text
,
const
Text_stat
*
t_stat
,
String
*
res
,
FILE
*
text_file
);
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