Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
57b27ca1
Commit
57b27ca1
authored
22 years ago
by
tewk
Browse files
Options
Downloads
Patches
Plain Diff
Added missing includes and fixed a few issues
added more assert checks
parent
c70edac9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/slurmd/circular_buffer.c
+31
-8
31 additions, 8 deletions
src/slurmd/circular_buffer.c
src/slurmd/circular_buffer.h
+2
-1
2 additions, 1 deletion
src/slurmd/circular_buffer.h
with
33 additions
and
9 deletions
src/slurmd/circular_buffer.c
+
31
−
8
View file @
57b27ca1
#include
<assert.h>
#include
<assert.h>
#include
<stdlib.h>
#include
<string.h>
#include
<src/common/log.h>
#include
<src/common/log.h>
#include
<src/common/xmalloc.h>
#include
<src/common/xmalloc.h>
#include
<src/common/slurm_errno.h>
#include
<src/common/slurm_errno.h>
...
@@ -10,6 +12,7 @@
...
@@ -10,6 +12,7 @@
#define MAX_BUFFER_SIZE ( ( 8192 * 10 ) )
#define MAX_BUFFER_SIZE ( ( 8192 * 10 ) )
static
int
assert_checks
(
circular_buffer_t
*
buf
)
;
static
int
assert_checks
(
circular_buffer_t
*
buf
)
;
static
int
assert_checks_2
(
circular_buffer_t
*
buf
)
;
static
int
expand_buffer
(
circular_buffer_t
*
buf
)
;
static
int
expand_buffer
(
circular_buffer_t
*
buf
)
;
static
int
shrink_buffer
(
circular_buffer_t
*
buf
)
;
static
int
shrink_buffer
(
circular_buffer_t
*
buf
)
;
...
@@ -56,6 +59,7 @@ int read_update ( circular_buffer_t * buf , unsigned int size )
...
@@ -56,6 +59,7 @@ int read_update ( circular_buffer_t * buf , unsigned int size )
/* before modifing the buffer lets do some sanity checks*/
/* before modifing the buffer lets do some sanity checks*/
assert
(
size
<=
buf
->
read_size
)
;
assert
(
size
<=
buf
->
read_size
)
;
assert_checks
(
buf
)
;
assert_checks
(
buf
)
;
assert_checks_2
(
buf
)
;
/*modify headning position of the buffer*/
/*modify headning position of the buffer*/
buf
->
head
=
buf
->
head
+
size
;
buf
->
head
=
buf
->
head
+
size
;
...
@@ -96,6 +100,7 @@ int read_update ( circular_buffer_t * buf , unsigned int size )
...
@@ -96,6 +100,7 @@ int read_update ( circular_buffer_t * buf , unsigned int size )
/* final sanity check */
/* final sanity check */
assert_checks
(
buf
)
;
assert_checks
(
buf
)
;
assert_checks_2
(
buf
)
;
return
SLURM_SUCCESS
;
return
SLURM_SUCCESS
;
}
}
...
@@ -111,6 +116,7 @@ int write_update ( circular_buffer_t * buf , unsigned int size )
...
@@ -111,6 +116,7 @@ int write_update ( circular_buffer_t * buf , unsigned int size )
/* before modifing the buffer lets do some sanity checks*/
/* before modifing the buffer lets do some sanity checks*/
assert
(
size
<=
buf
->
write_size
)
;
assert
(
size
<=
buf
->
write_size
)
;
assert_checks
(
buf
)
;
assert_checks
(
buf
)
;
assert_checks_2
(
buf
)
;
/*modify headning position of the buffer*/
/*modify headning position of the buffer*/
buf
->
tail
=
buf
->
tail
+
size
;
buf
->
tail
=
buf
->
tail
+
size
;
...
@@ -151,25 +157,21 @@ int write_update ( circular_buffer_t * buf , unsigned int size )
...
@@ -151,25 +157,21 @@ int write_update ( circular_buffer_t * buf , unsigned int size )
/* final sanity check */
/* final sanity check */
assert_checks
(
buf
)
;
assert_checks
(
buf
)
;
assert_checks_2
(
buf
)
;
return
SLURM_SUCCESS
;
return
SLURM_SUCCESS
;
}
}
static
int
assert_checks
(
circular_buffer_t
*
buf
)
static
int
assert_checks
_2
(
circular_buffer_t
*
buf
)
{
{
/* sanity checks */
/* sanity checks */
assert
(
buf
!=
NULL
)
;
/* buf struct is not null */
assert
(
buf
->
start
==
buf
->
buffer
);
/* stat hasn't moved */
assert
(
(
buf
->
start
)
<
(
buf
->
end
)
);
/* buf_end is after start */
assert
(
buf
->
end
-
buf
->
start
==
buf
->
buf_size
)
;
/* buffer start and end haven't moved */
/* head pointer is between start and end */
/* head pointer is between start and end */
assert
(
buf
->
head
>=
buf
->
start
)
;
assert
(
buf
->
head
>=
buf
->
start
)
;
assert
(
buf
->
head
<
=
buf
->
end
)
;
assert
(
buf
->
head
<
buf
->
end
)
;
/* tail pointer is between start and end */
/* tail pointer is between start and end */
assert
(
buf
->
tail
>=
buf
->
start
)
;
assert
(
buf
->
tail
>=
buf
->
start
)
;
assert
(
buf
->
tail
<
=
buf
->
end
)
;
assert
(
buf
->
tail
<
buf
->
end
)
;
if
(
buf
->
tail
>
buf
->
head
)
if
(
buf
->
tail
>
buf
->
head
)
{
{
...
@@ -186,6 +188,27 @@ static int assert_checks ( circular_buffer_t * buf )
...
@@ -186,6 +188,27 @@ static int assert_checks ( circular_buffer_t * buf )
assert
(
buf
->
write_size
==
buf
->
buf_size
)
;
assert
(
buf
->
write_size
==
buf
->
buf_size
)
;
assert
(
buf
->
read_size
==
0
)
;
assert
(
buf
->
read_size
==
0
)
;
}
}
return
SLURM_SUCCESS
;
}
static
int
assert_checks
(
circular_buffer_t
*
buf
)
{
/* sanity checks */
assert
(
buf
!=
NULL
)
;
/* buf struct is not null */
assert
(
buf
->
start
==
buf
->
buffer
);
/* stat hasn't moved */
assert
(
(
buf
->
start
)
<
(
buf
->
end
)
);
/* buf_end is after start */
assert
(
buf
->
end
-
buf
->
start
==
buf
->
buf_size
)
;
/* buffer start and end haven't moved */
/* head pointer is between start and end */
assert
(
buf
->
head
>=
buf
->
start
)
;
assert
(
buf
->
head
<=
buf
->
end
)
;
/* tail pointer is between start and end */
assert
(
buf
->
tail
>=
buf
->
start
)
;
assert
(
buf
->
tail
<=
buf
->
end
)
;
return
SLURM_SUCCESS
;
return
SLURM_SUCCESS
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/slurmd/circular_buffer.h
+
2
−
1
View file @
57b27ca1
...
@@ -12,7 +12,8 @@ typedef struct circular_buffer
...
@@ -12,7 +12,8 @@ typedef struct circular_buffer
char
*
tail
;
/* end of the used portion of the buffer */
char
*
tail
;
/* end of the used portion of the buffer */
}
circular_buffer_t
;
}
circular_buffer_t
;
int
init_cir_buf
(
circular_buffer_t
**
buf_ptr
)
;
int
init_circular_buffer
(
circular_buffer_t
**
buf_ptr
)
;
void
free_circular_buffer
(
circular_buffer_t
*
buf_ptr
)
;
int
read_update
(
circular_buffer_t
*
buf
,
unsigned
int
size
)
;
int
read_update
(
circular_buffer_t
*
buf
,
unsigned
int
size
)
;
int
write_update
(
circular_buffer_t
*
buf
,
unsigned
int
size
)
;
int
write_update
(
circular_buffer_t
*
buf
,
unsigned
int
size
)
;
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment