Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Assignment Parallel Firewall
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rareş-Andrei CELESCU
Assignment Parallel Firewall
Commits
c735947d
Unverified
Commit
c735947d
authored
4 months ago
by
celesq
Browse files
Options
Downloads
Patches
Plain Diff
70p - with coding style
parent
22cc1efc
No related branches found
No related tags found
No related merge requests found
Pipeline
#93483
passed
4 months ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/consumer.c
+4
-3
4 additions, 3 deletions
src/consumer.c
src/consumer.h
+1
-1
1 addition, 1 deletion
src/consumer.h
src/ring_buffer.c
+1
-0
1 addition, 0 deletions
src/ring_buffer.c
with
6 additions
and
4 deletions
src/consumer.c
+
4
−
3
View file @
c735947d
...
...
@@ -16,7 +16,7 @@ void consumer_thread(void *args)
so_packet_t
packet
;
so_consumer_ctx_t
*
ctx
=
(
so_consumer_ctx_t
*
)
args
;
while
(
1
)
{
while
(
true
)
{
pthread_mutex_lock
(
&
ctx
->
producer_rb
->
mutex
);
while
(
ctx
->
producer_rb
->
len
==
0
&&
ctx
->
producer_rb
->
stop
==
0
)
...
...
@@ -34,7 +34,7 @@ void consumer_thread(void *args)
continue
;
pthread_mutex_lock
(
&
ctx
->
timestamp
);
if
(
packet
.
hdr
.
timestamp
>=
(
unsigned
int
)
ctx
->
lasttimestamp
)
{
if
(
packet
.
hdr
.
timestamp
>=
ctx
->
lasttimestamp
)
{
ctx
->
lasttimestamp
=
packet
.
hdr
.
timestamp
;
pthread_mutex_lock
(
&
ctx
->
logs
);
...
...
@@ -58,7 +58,7 @@ int create_consumers(pthread_t *tids,
FILE
*
f
=
fopen
(
out_filename
,
"a"
);
if
(
!
f
)
{
p
error
(
"Failed to open output file"
);
p
rintf
(
"Failed to open output file
\n
"
);
return
-
1
;
}
...
...
@@ -89,6 +89,7 @@ int create_consumers(pthread_t *tids,
for
(
int
j
=
0
;
j
<
i
;
j
++
)
pthread_join
(
tids
[
j
],
NULL
);
pthread_mutex_destroy
(
&
ctx
->
logs
);
pthread_mutex_destroy
(
&
ctx
->
timestamp
);
free
(
ctx
);
fclose
(
f
);
return
-
1
;
...
...
This diff is collapsed.
Click to expand it.
src/consumer.h
+
1
−
1
View file @
c735947d
...
...
@@ -15,7 +15,7 @@ typedef struct so_consumer_ctx_t {
FILE
*
f
;
pthread_mutex_t
logs
;
pthread_mutex_t
timestamp
;
int
lasttimestamp
;
unsigned
long
lasttimestamp
;
}
so_consumer_ctx_t
;
int
create_consumers
(
pthread_t
*
tids
,
...
...
This diff is collapsed.
Click to expand it.
src/ring_buffer.c
+
1
−
0
View file @
c735947d
...
...
@@ -50,6 +50,7 @@ ssize_t ring_buffer_enqueue(so_ring_buffer_t *ring, void *data, size_t size)
memcpy
(
ring
->
data
+
ring
->
write_pos
,
data
,
sizeleft
);
memcpy
(
ring
->
data
,
(
char
*
)
data
+
sizeleft
,
size
-
sizeleft
);
}
ring
->
write_pos
=
(
ring
->
write_pos
+
size
)
%
ring
->
cap
;
ring
->
len
=
ring
->
len
+
size
;
...
...
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