MCPcopy Create free account
hub / github.com/apache/trafficserver / ink_sem_init

Function ink_sem_init

src/tscore/ink_thread.cc:42–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40#endif
41
42void
43ink_sem_init(ink_semaphore *sp, unsigned int count)
44{
45// Darwin has sem_open, but not sem_init. We emulate sem_init with sem_open.
46#if TS_EMULATE_ANON_SEMAPHORES
47 char sname[NAME_MAX];
48
49 sp->semid = ink_atomic_increment(&ink_semaphore_count, 1);
50 snprintf(sname, sizeof(sname), "/trafficserver/anon/%" PRId64, sp->semid);
51
52 ink_assert((sp->sema = sem_open(sname, O_CREAT | O_EXCL, 0770, count)) != SEM_FAILED);
53
54 // Since we are emulating anonymous semaphores, unlink the name
55 // so no other process can accidentally get it.
56 ink_assert(sem_unlink(sname) != -1);
57#else
58 ink_assert(sem_init(sp->get(), 0 /* pshared */, count) != -1);
59#endif
60}
61
62void
63ink_sem_destroy(ink_semaphore *sp)

Callers 1

create_queueFunction · 0.85

Calls 2

ink_atomic_incrementFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected