From d1cd99244f96bd95bbd67cc737248df346dec08b Mon Sep 17 00:00:00 2001 From: egor-tensin Date: Thu, 25 Apr 2024 03:50:51 +0000 Subject: =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20egor-tensin/cimp?= =?UTF-8?q?le@8e652dd2cb69928ea1596aa3e59845fef6854e2c=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...r_queue.c.aeb7258cd8f695c41a9aa8634701b38c.html | 755 +++++++++++++++++++++ 1 file changed, 755 insertions(+) create mode 100644 coverage/index.worker_queue.c.aeb7258cd8f695c41a9aa8634701b38c.html (limited to 'coverage/index.worker_queue.c.aeb7258cd8f695c41a9aa8634701b38c.html') diff --git a/coverage/index.worker_queue.c.aeb7258cd8f695c41a9aa8634701b38c.html b/coverage/index.worker_queue.c.aeb7258cd8f695c41a9aa8634701b38c.html new file mode 100644 index 0000000..9402dd1 --- /dev/null +++ b/coverage/index.worker_queue.c.aeb7258cd8f695c41a9aa8634701b38c.html @@ -0,0 +1,755 @@ + + + + + + GCC Code Coverage Report + + + + + +

GCC Code Coverage Report

+ +
+ +
+
+ + + + + + + + + + + + + +
Directory:src/
File:src/worker_queue.c
Date:2024-04-25 03:45:42
+
+
+ + + + + + + + + + + + + + + + + + + +
ExecTotalCoverage
Lines:323688.9%
Branches:51050.0%
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineBranchExecSource
1 + /*
2 + * Copyright (c) 2023 Egor Tensin <egor@tensin.name>
3 + * This file is part of the "cimple" project.
4 + * For details, see https://github.com/egor-tensin/cimple.
5 + * Distributed under the MIT License.
6 + */
7 +
8 + #include "worker_queue.h"
9 + #include "log.h"
10 + #include "net.h"
11 +
12 + #include <stdlib.h>
13 + #include <sys/queue.h>
14 +
15 + struct worker {
16 + int fd;
17 + SIMPLEQ_ENTRY(worker) entries;
18 + };
19 +
20 + 9234int worker_create(struct worker **_entry, int fd)
21 + {
22 + 9234 struct worker *entry = malloc(sizeof(struct worker));
23 +
+ 1/2 +
+
✗ Branch 0 not taken.
+
✓ Branch 1 taken 9234 times.
+
+
+
9234 if (!entry) {
24 + log_errno("malloc");
25 + return -1;
26 + }
27 +
28 + 9234 entry->fd = fd;
29 +
30 + 9234 *_entry = entry;
31 + 9234 return 0;
32 + }
33 +
34 + 9234void worker_destroy(struct worker *entry)
35 + {
36 + 9234 net_close(entry->fd);
37 + 9234 free(entry);
38 + 9234}
39 +
40 + 36774int worker_get_fd(const struct worker *entry)
41 + {
42 + 36774 return entry->fd;
43 + }
44 +
45 + 29void worker_queue_create(struct worker_queue *queue)
46 + {
47 + 29 SIMPLEQ_INIT(queue);
48 + 29}
49 +
50 + 29void worker_queue_destroy(struct worker_queue *queue)
51 + {
52 + 29 struct worker *entry1 = SIMPLEQ_FIRST(queue);
53 +
+ 2/2 +
+
✓ Branch 0 taken 54 times.
+
✓ Branch 1 taken 29 times.
+
+
+
83 while (entry1) {
54 + 54 struct worker *entry2 = SIMPLEQ_NEXT(entry1, entries);
55 + 54 worker_destroy(entry1);
56 + 54 entry1 = entry2;
57 + }
58 + 29 SIMPLEQ_INIT(queue);
59 + 29}
60 +
61 + 27255int worker_queue_is_empty(const struct worker_queue *queue)
62 + {
63 + 27255 return SIMPLEQ_EMPTY(queue);
64 + }
65 +
66 + void worker_queue_add_first(struct worker_queue *queue, struct worker *entry)
67 + {
68 + SIMPLEQ_INSERT_HEAD(queue, entry, entries);
69 + }
70 +
71 + 9234void worker_queue_add_last(struct worker_queue *queue, struct worker *entry)
72 + {
73 + 9234 SIMPLEQ_INSERT_TAIL(queue, entry, entries);
74 + 9234}
75 +
76 + 9180struct worker *worker_queue_remove_first(struct worker_queue *queue)
77 + {
78 + 9180 struct worker *entry = SIMPLEQ_FIRST(queue);
79 +
+ 2/2 +
+
✓ Branch 0 taken 9098 times.
+
✓ Branch 1 taken 82 times.
+
+
+
9180 SIMPLEQ_REMOVE_HEAD(queue, entries);
80 + 9180 return entry;
81 + }
82 +
+
+ +
+ + + + -- cgit v1.2.3