| line |
true |
false |
branch |
|
148
|
2 |
97 |
if (v < 2) return 2; |
|
149
|
0 |
97 |
if (v > 0x80000000U) return 0; |
|
166
|
161 |
28 |
if (needed <= h->copy_buf_cap) return 1; |
|
167
|
2 |
26 |
uint32_t ns = h->copy_buf_cap ? h->copy_buf_cap : 64; |
|
168
|
0 |
15 |
while (ns < needed) { uint32_t n2 = ns * 2; if (n2 <= ns) { ns = needed; break; } ns = n2; } |
|
|
15 |
28 |
while (ns < needed) { uint32_t n2 = ns * 2; if (n2 <= ns) { ns = needed; break; } ns = n2; } |
|
170
|
0 |
28 |
if (!nb) return 0; |
|
185
|
0 |
0 |
if (pid == 0) return 1; |
|
186
|
0 |
0 |
return !(kill((pid_t)pid, 0) == -1 && errno == ESRCH); |
|
|
0 |
0 |
return !(kill((pid_t)pid, 0) == -1 && errno == ESRCH); |
|
192
|
0 |
0 |
if (!__atomic_compare_exchange_n(&hdr->mutex, &observed, 0, |
|
196
|
0 |
0 |
if (__atomic_load_n(&hdr->mutex_waiters, __ATOMIC_RELAXED) > 0) |
|
204
|
419 |
5 |
if (__atomic_compare_exchange_n(&hdr->mutex, &expected, mypid, |
|
207
|
5 |
0 |
if (__builtin_expect(spin < QUEUE_SPIN_LIMIT, 1)) { |
|
213
|
0 |
0 |
if (cur != 0) { |
|
216
|
0 |
0 |
if (rc == -1 && errno == ETIMEDOUT) { |
|
|
0 |
0 |
if (rc == -1 && errno == ETIMEDOUT) { |
|
219
|
0 |
0 |
if (val >= QUEUE_MUTEX_WRITER_BIT) { |
|
221
|
0 |
0 |
if (!queue_pid_alive(pid)) |
|
235
|
1 |
418 |
if (__atomic_load_n(&hdr->mutex_waiters, __ATOMIC_RELAXED) > 0) |
|
241
|
0 |
448 |
if (__atomic_load_n(&hdr->pop_waiters, __ATOMIC_RELAXED) > 0) { |
|
249
|
0 |
628 |
if (__atomic_load_n(&hdr->push_waiters, __ATOMIC_RELAXED) > 0) { |
|
262
|
17 |
9 |
if (remaining->tv_nsec < 0) { |
|
274
|
0 |
25 |
if (deadline->tv_nsec >= 1000000000L) { |
|
303
|
41 |
49 |
if (mode == QUEUE_MODE_INT) INIT_SEQ(QueueIntSlot, cap); |
|
|
2276 |
41 |
if (mode == QUEUE_MODE_INT) INIT_SEQ(QueueIntSlot, cap); |
|
304
|
8 |
41 |
else if (mode == QUEUE_MODE_INT32) INIT_SEQ(QueueInt32Slot, cap); |
|
|
1448 |
8 |
else if (mode == QUEUE_MODE_INT32) INIT_SEQ(QueueInt32Slot, cap); |
|
305
|
3 |
38 |
else if (mode == QUEUE_MODE_INT16) INIT_SEQ(QueueInt16Slot, cap); |
|
|
1072 |
3 |
else if (mode == QUEUE_MODE_INT16) INIT_SEQ(QueueInt16Slot, cap); |
|
313
|
87 |
0 |
if (errbuf) errbuf[0] = '\0'; |
|
316
|
0 |
87 |
if (cap == 0) { QUEUE_ERR("invalid capacity"); return NULL; } |
|
|
0 |
0 |
if (cap == 0) { QUEUE_ERR("invalid capacity"); return NULL; } |
|
317
|
0 |
87 |
if (mode > QUEUE_MODE_INT16) { QUEUE_ERR("unknown mode %u", mode); return NULL; } |
|
|
0 |
0 |
if (mode > QUEUE_MODE_INT16) { QUEUE_ERR("unknown mode %u", mode); return NULL; } |
|
321
|
48 |
39 |
: (mode == QUEUE_MODE_INT32) ? sizeof(QueueInt32Slot) |
|
322
|
40 |
8 |
: (mode == QUEUE_MODE_INT16) ? sizeof(QueueInt16Slot) |
|
323
|
3 |
37 |
: sizeof(QueueStrSlot); |
|
327
|
37 |
50 |
if (mode == QUEUE_MODE_STR) { |
|
331
|
8 |
29 |
if (arena_cap < 4096) arena_cap = 4096; |
|
332
|
0 |
37 |
if (arena_cap > UINT32_MAX) arena_cap = UINT32_MAX; |
|
342
|
21 |
66 |
if (anonymous) { |
|
347
|
0 |
21 |
if (base == MAP_FAILED) { |
|
348
|
0 |
0 |
QUEUE_ERR("mmap(anonymous): %s", strerror(errno)); |
|
355
|
0 |
66 |
if (fd < 0) { QUEUE_ERR("open(%s): %s", path, strerror(errno)); return NULL; } |
|
|
0 |
0 |
if (fd < 0) { QUEUE_ERR("open(%s): %s", path, strerror(errno)); return NULL; } |
|
357
|
0 |
66 |
if (flock(fd, LOCK_EX) < 0) { |
|
358
|
0 |
0 |
QUEUE_ERR("flock(%s): %s", path, strerror(errno)); |
|
363
|
0 |
66 |
if (fstat(fd, &st) < 0) { |
|
364
|
0 |
0 |
QUEUE_ERR("fstat(%s): %s", path, strerror(errno)); |
|
370
|
9 |
57 |
if (!is_new && (uint64_t)st.st_size < sizeof(QueueHeader)) { |
|
|
0 |
9 |
if (!is_new && (uint64_t)st.st_size < sizeof(QueueHeader)) { |
|
371
|
0 |
0 |
QUEUE_ERR("%s: file too small (%lld)", path, (long long)st.st_size); |
|
375
|
57 |
9 |
if (is_new) { |
|
376
|
0 |
57 |
if (ftruncate(fd, (off_t)total_size) < 0) { |
|
377
|
0 |
0 |
QUEUE_ERR("ftruncate(%s): %s", path, strerror(errno)); |
|
382
|
9 |
57 |
map_size = is_new ? (size_t)total_size : (size_t)st.st_size; |
|
384
|
0 |
66 |
if (base == MAP_FAILED) { |
|
385
|
0 |
0 |
QUEUE_ERR("mmap(%s): %s", path, strerror(errno)); |
|
391
|
9 |
57 |
if (!is_new) { |
|
394
|
9 |
0 |
hdr->version == QUEUE_VERSION && |
|
395
|
5 |
4 |
hdr->mode == mode && |
|
396
|
5 |
0 |
hdr->capacity > 0 && |
|
397
|
5 |
0 |
(hdr->capacity & (hdr->capacity - 1)) == 0 && |
|
398
|
5 |
0 |
hdr->total_size == (uint64_t)st.st_size && |
|
399
|
9 |
0 |
hdr->slots_off == sizeof(QueueHeader) && |
|
|
5 |
0 |
hdr->slots_off == sizeof(QueueHeader) && |
|
400
|
5 |
0 |
hdr->capacity <= (hdr->total_size - hdr->slots_off) / slot_size); |
|
401
|
3 |
6 |
if (mode == QUEUE_MODE_STR && valid) { |
|
|
2 |
1 |
if (mode == QUEUE_MODE_STR && valid) { |
|
403
|
2 |
0 |
valid = (hdr->arena_off >= slots_end && |
|
404
|
2 |
0 |
hdr->arena_off + hdr->arena_cap <= hdr->total_size); |
|
406
|
4 |
5 |
if (!valid) { |
|
407
|
4 |
0 |
QUEUE_ERR("%s: invalid or incompatible queue file", path); |
|
426
|
0 |
83 |
if (!h) { munmap(base, map_size); return NULL; } |
|
430
|
36 |
47 |
h->arena = (mode == QUEUE_MODE_STR) ? (char *)base + hdr->arena_off : NULL; |
|
435
|
62 |
21 |
h->path = path ? strdup(path) : NULL; |
|
447
|
12 |
0 |
if (errbuf) errbuf[0] = '\0'; |
|
450
|
0 |
12 |
if (cap == 0) { QUEUE_ERR("invalid capacity"); return NULL; } |
|
|
0 |
0 |
if (cap == 0) { QUEUE_ERR("invalid capacity"); return NULL; } |
|
451
|
0 |
12 |
if (mode > QUEUE_MODE_INT16) { QUEUE_ERR("unknown mode %u", mode); return NULL; } |
|
|
0 |
0 |
if (mode > QUEUE_MODE_INT16) { QUEUE_ERR("unknown mode %u", mode); return NULL; } |
|
455
|
6 |
6 |
: (mode == QUEUE_MODE_INT32) ? sizeof(QueueInt32Slot) |
|
456
|
5 |
1 |
: (mode == QUEUE_MODE_INT16) ? sizeof(QueueInt16Slot) |
|
457
|
1 |
4 |
: sizeof(QueueStrSlot); |
|
460
|
4 |
8 |
if (mode == QUEUE_MODE_STR) { |
|
464
|
0 |
4 |
if (arena_cap < 4096) arena_cap = 4096; |
|
465
|
0 |
4 |
if (arena_cap > UINT32_MAX) arena_cap = UINT32_MAX; |
|
471
|
12 |
0 |
int fd = memfd_create(name ? name : "queue", MFD_CLOEXEC | MFD_ALLOW_SEALING); |
|
472
|
0 |
12 |
if (fd < 0) { QUEUE_ERR("memfd_create: %s", strerror(errno)); return NULL; } |
|
|
0 |
0 |
if (fd < 0) { QUEUE_ERR("memfd_create: %s", strerror(errno)); return NULL; } |
|
474
|
0 |
12 |
if (ftruncate(fd, (off_t)total_size) < 0) { |
|
475
|
0 |
0 |
QUEUE_ERR("ftruncate(memfd): %s", strerror(errno)); |
|
483
|
0 |
12 |
if (base == MAP_FAILED) { |
|
484
|
0 |
0 |
QUEUE_ERR("mmap(memfd): %s", strerror(errno)); |
|
491
|
0 |
12 |
if (!h) { munmap(base, (size_t)total_size); close(fd); return NULL; } |
|
495
|
4 |
8 |
h->arena = (mode == QUEUE_MODE_STR) ? (char *)base + arena_off : NULL; |
|
509
|
2 |
0 |
if (errbuf) errbuf[0] = '\0'; |
|
512
|
0 |
2 |
if (fstat(fd, &st) < 0) { |
|
513
|
0 |
0 |
QUEUE_ERR("fstat(fd=%d): %s", fd, strerror(errno)); |
|
517
|
0 |
2 |
if ((uint64_t)st.st_size < sizeof(QueueHeader)) { |
|
518
|
0 |
0 |
QUEUE_ERR("fd %d: too small (%lld)", fd, (long long)st.st_size); |
|
524
|
0 |
2 |
if (base == MAP_FAILED) { |
|
525
|
0 |
0 |
QUEUE_ERR("mmap(fd=%d): %s", fd, strerror(errno)); |
|
531
|
1 |
1 |
: (mode == QUEUE_MODE_INT32) ? sizeof(QueueInt32Slot) |
|
532
|
1 |
0 |
: (mode == QUEUE_MODE_INT16) ? sizeof(QueueInt16Slot) |
|
533
|
0 |
1 |
: sizeof(QueueStrSlot); |
|
535
|
2 |
0 |
hdr->version == QUEUE_VERSION && |
|
536
|
2 |
0 |
hdr->mode == mode && |
|
537
|
2 |
0 |
hdr->capacity > 0 && |
|
538
|
2 |
0 |
(hdr->capacity & (hdr->capacity - 1)) == 0 && |
|
539
|
2 |
0 |
hdr->total_size == (uint64_t)st.st_size && |
|
540
|
2 |
0 |
hdr->slots_off == sizeof(QueueHeader) && |
|
|
2 |
0 |
hdr->slots_off == sizeof(QueueHeader) && |
|
541
|
2 |
0 |
hdr->capacity <= (hdr->total_size - hdr->slots_off) / slot_size); |
|
542
|
1 |
1 |
if (mode == QUEUE_MODE_STR && valid) { |
|
|
1 |
0 |
if (mode == QUEUE_MODE_STR && valid) { |
|
544
|
1 |
0 |
valid = (hdr->arena_off >= slots_end && |
|
545
|
1 |
0 |
hdr->arena_off + hdr->arena_cap <= hdr->total_size); |
|
547
|
0 |
2 |
if (!valid) { |
|
548
|
0 |
0 |
QUEUE_ERR("fd %d: invalid or incompatible queue", fd); |
|
555
|
0 |
2 |
if (myfd < 0) { |
|
556
|
0 |
0 |
QUEUE_ERR("fcntl(F_DUPFD_CLOEXEC): %s", strerror(errno)); |
|
562
|
0 |
2 |
if (!h) { munmap(base, map_size); close(myfd); return NULL; } |
|
566
|
1 |
1 |
h->arena = (mode == QUEUE_MODE_STR) ? (char *)base + hdr->arena_off : NULL; |
|
579
|
0 |
97 |
if (!h) return; |
|
580
|
10 |
87 |
if (h->notify_fd >= 0) close(h->notify_fd); |
|
581
|
14 |
83 |
if (h->backing_fd >= 0) close(h->backing_fd); |
|
582
|
97 |
0 |
if (h->hdr) munmap(h->hdr, h->mmap_size); |
|
734
|
44 |
5 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
6 |
3 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
100 |
7 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
0 |
7 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
7 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
0 |
7 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
7 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
0 |
7 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
5 |
2 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
10 |
3 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
1 |
2 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
0 |
2 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
0 |
2 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
1 |
1 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
1 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
1 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
310 |
39 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
310 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
39 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
209 |
11 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
209 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
|
11 |
0 |
DEFINE_INT_QUEUE(int, QueueIntSlot, int64_t, uint64_t, int64_t) |
|
737
|
16 |
1 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
1 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
99 |
2 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
2 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
2 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
2 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
2 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
138 |
7 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
138 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
7 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
37 |
1 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
37 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
|
1 |
0 |
DEFINE_INT_QUEUE(int32, QueueInt32Slot, int32_t, uint32_t, int32_t) |
|
740
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
12 |
1 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
12 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
1 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
12 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
12 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
|
0 |
0 |
DEFINE_INT_QUEUE(int16, QueueInt16Slot, int16_t, uint32_t, int32_t) |
|
751
|
0 |
190 |
if (len > QUEUE_STR_LEN_MASK) return -2; |
|
753
|
11 |
179 |
if (hdr->tail - hdr->head >= h->capacity) { |
|
759
|
2 |
177 |
if (alloc == 0) alloc = 8; |
|
760
|
0 |
179 |
if (alloc > h->arena_cap) return -2; |
|
765
|
2 |
177 |
if ((uint64_t)pos + alloc > h->arena_cap) { |
|
770
|
1 |
178 |
if ((uint64_t)hdr->arena_used + skip > h->arena_cap) { |
|
771
|
0 |
1 |
if (hdr->tail == hdr->head) { |
|
788
|
4 |
174 |
slot->packed_len = len | (utf8 ? QUEUE_STR_UTF8_FLAG : 0); |
|
804
|
173 |
11 |
if (r == 1) queue_wake_consumers(h->hdr); |
|
813
|
30 |
164 |
if (hdr->tail == hdr->head) { |
|
824
|
0 |
164 |
if (!queue_ensure_copy_buf(h, len + 1)) |
|
826
|
162 |
2 |
if (len > 0) |
|
833
|
49 |
115 |
if (hdr->arena_used == 0) |
|
846
|
140 |
23 |
if (r == 1) queue_wake_producers(h->hdr); |
|
853
|
5 |
3 |
if (r != 0) return r; /* 1 = success, -2 = too long */ |
|
854
|
0 |
3 |
if (timeout == 0) return 0; |
|
859
|
3 |
0 |
if (has_deadline) queue_make_deadline(timeout, &deadline); |
|
864
|
0 |
3 |
if (r != 0) return r; |
|
868
|
3 |
0 |
if (has_deadline) { |
|
869
|
0 |
3 |
if (!queue_remaining_time(&deadline, &remaining)) { |
|
879
|
1 |
2 |
if (r != 0) return r; |
|
880
|
2 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
|
2 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
887
|
50 |
7 |
if (r != 0) return r; |
|
888
|
0 |
7 |
if (timeout == 0) return 0; |
|
893
|
7 |
0 |
if (has_deadline) queue_make_deadline(timeout, &deadline); |
|
898
|
0 |
8 |
if (r != 0) return r; |
|
902
|
8 |
0 |
if (has_deadline) { |
|
903
|
0 |
8 |
if (!queue_remaining_time(&deadline, &remaining)) { |
|
913
|
5 |
3 |
if (r != 0) return r; |
|
914
|
2 |
1 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
|
2 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
935
|
0 |
7 |
if (__atomic_load_n(&hdr->push_waiters, __ATOMIC_RELAXED) > 0) { |
|
939
|
0 |
7 |
if (__atomic_load_n(&hdr->pop_waiters, __ATOMIC_RELAXED) > 0) { |
|
950
|
1 |
6 |
if (hdr->tail == hdr->head) { |
|
958
|
0 |
6 |
if (!queue_ensure_copy_buf(h, len + 1)) { |
|
962
|
6 |
0 |
if (len > 0) |
|
977
|
0 |
21 |
if (len > QUEUE_STR_LEN_MASK) { |
|
983
|
6 |
15 |
if (size >= h->capacity) { |
|
990
|
0 |
15 |
if (alloc == 0) alloc = 8; |
|
991
|
0 |
15 |
if (alloc > h->arena_cap) { |
|
999
|
0 |
15 |
if ((uint64_t)pos + alloc > h->arena_cap) { |
|
1004
|
0 |
15 |
if ((uint64_t)hdr->arena_used + skip > h->arena_cap) { |
|
1005
|
0 |
0 |
if (hdr->tail == hdr->head) { |
|
1024
|
1 |
14 |
slot->packed_len = len | (utf8 ? QUEUE_STR_UTF8_FLAG : 0); |
|
1040
|
1 |
2 |
if (r != 0) return r; |
|
1041
|
0 |
2 |
if (timeout == 0) return 0; |
|
1046
|
2 |
0 |
if (has_deadline) queue_make_deadline(timeout, &deadline); |
|
1051
|
0 |
2 |
if (r != 0) return r; |
|
1055
|
2 |
0 |
if (has_deadline) { |
|
1056
|
0 |
2 |
if (!queue_remaining_time(&deadline, &remaining)) { |
|
1066
|
1 |
1 |
if (r != 0) return r; |
|
1067
|
1 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
|
1 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
1077
|
7 |
19 |
if (hdr->tail == hdr->head) { |
|
1090
|
0 |
19 |
if (!queue_ensure_copy_buf(h, len + 1)) { |
|
1095
|
19 |
0 |
if (len > 0) |
|
1107
|
0 |
19 |
if (slot_alloc == 0) slot_alloc = 8; |
|
1108
|
16 |
3 |
if (slot->arena_off + slot_alloc == hdr->arena_wpos) |
|
1111
|
7 |
12 |
if (hdr->arena_used == 0) |
|
1123
|
1 |
2 |
if (r != 0) return r; |
|
1124
|
0 |
2 |
if (timeout == 0) return 0; |
|
1129
|
2 |
0 |
if (has_deadline) queue_make_deadline(timeout, &deadline); |
|
1134
|
0 |
2 |
if (r != 0) return r; |
|
1138
|
2 |
0 |
if (has_deadline) { |
|
1139
|
0 |
2 |
if (!queue_remaining_time(&deadline, &remaining)) { |
|
1149
|
1 |
1 |
if (r != 0) return r; |
|
1150
|
1 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
|
1 |
0 |
if (rc == -1 && errno == ETIMEDOUT) return 0; |
|
1164
|
1 |
10 |
if (h->notify_fd >= 0) return h->notify_fd; |
|
1170
|
1 |
0 |
if (h->notify_fd >= 0 && h->notify_fd != fd) |
|
|
1 |
0 |
if (h->notify_fd >= 0 && h->notify_fd != fd) |
|
1177
|
7 |
1 |
if (h->notify_fd >= 0) { |
|
1186
|
0 |
10 |
if (h->notify_fd < 0) return -1; |
|
1188
|
0 |
10 |
if (read(h->notify_fd, &val, sizeof(val)) != sizeof(val)) return -1; |