Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
fab068cd
Commit
fab068cd
authored
Mar 16, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restructure flush_source and flush_old_sources.
Now flush_source itself checks for the source being flushable.
parent
d6b8ddd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
20 deletions
+19
-20
source.c
source.c
+18
-19
source.h
source.h
+1
-1
No files found.
source.c
View file @
fab068cd
...
...
@@ -88,14 +88,26 @@ find_source(const unsigned char *id, const unsigned char *p, unsigned char plen,
return
src
;
}
/* It is the caller's responsibility to check that no routes point at
this source. */
void
int
flush_source
(
struct
source
*
src
)
{
int
i
;
for
(
i
=
0
;
i
<
numroutes
;
i
++
)
{
if
(
routes
[
i
].
src
==
src
)
return
0
;
}
memset
(
src
,
0
,
sizeof
(
*
src
));
VALGRIND_MAKE_MEM_UNDEFINED
(
src
,
sizeof
(
*
src
));
src
->
valid
=
0
;
while
(
numsrcs
>
0
&&
!
srcs
[
numsrcs
-
1
].
valid
)
{
numsrcs
--
;
VALGRIND_MAKE_MEM_UNDEFINED
(
&
srcs
[
numsrcs
],
sizeof
(
srcs
[
numsrcs
]));
}
return
1
;
}
struct
source
*
...
...
@@ -147,7 +159,7 @@ update_source(struct source *src,
int
flush_old_sources
()
{
int
i
,
j
,
changed
;
int
i
,
changed
,
rc
;
changed
=
0
;
...
...
@@ -156,21 +168,8 @@ flush_old_sources()
continue
;
if
(
srcs
[
i
].
time
>=
now
.
tv_sec
-
SOURCE_GC_TIME
)
continue
;
for
(
j
=
0
;
j
<
numroutes
;
j
++
)
{
if
(
routes
[
j
].
src
==
&
srcs
[
i
])
goto
nocando
;
}
flush_source
(
&
srcs
[
i
]);
changed
=
1
;
nocando:
;
}
if
(
changed
)
{
while
(
numsrcs
>
0
&&
!
srcs
[
numsrcs
-
1
].
valid
)
{
numsrcs
--
;
VALGRIND_MAKE_MEM_UNDEFINED
(
&
srcs
[
numsrcs
],
sizeof
(
srcs
[
numsrcs
]));
}
rc
=
flush_source
(
&
srcs
[
i
]);
changed
=
changed
||
rc
;
}
return
changed
;
...
...
source.h
View file @
fab068cd
...
...
@@ -38,7 +38,7 @@ struct source *find_source(const unsigned char *id,
const
unsigned
char
*
p
,
unsigned
char
plen
,
int
create
,
unsigned
short
seqno
);
void
flush_source
(
struct
source
*
src
);
int
flush_source
(
struct
source
*
src
);
struct
source
*
find_recent_source
(
const
unsigned
char
*
p
,
unsigned
char
plen
);
void
update_source
(
struct
source
*
src
,
...
...
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