MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / eventInit

Method eventInit

src/common/isc_sync.cpp:585–640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583}
584
585int SharedMemoryBase::eventInit(event_t* event)
586{
587/**************************************
588 *
589 * I S C _ e v e n t _ i n i t
590 *
591 **************************************
592 *
593 * Functional description
594 * Prepare an event object for use.
595 *
596 **************************************/
597
598#if defined(WIN_NT)
599
600 static AtomicCounter idCounter;
601
602 event->event_id = ++idCounter;
603
604 event->event_pid = process_id = getpid();
605 event->event_count = 0;
606
607 event->event_handle = ISC_make_signal(true, true, process_id, event->event_id);
608
609 return (event->event_handle) ? FB_SUCCESS : FB_FAILURE;
610
611#else // pthread-based event
612
613 event->event_count = 0;
614 event->event_pid = getpid();
615
616 // Prepare an Inter-Process event block
617 pthread_mutexattr_t mattr;
618 pthread_condattr_t cattr;
619
620 PTHREAD_ERROR(pthread_mutexattr_init(&mattr));
621 PTHREAD_ERROR(pthread_condattr_init(&cattr));
622#ifdef PTHREAD_PROCESS_SHARED
623 if (!isSandboxed())
624 {
625 PTHREAD_ERROR(pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED));
626 PTHREAD_ERROR(pthread_condattr_setpshared(&cattr, PTHREAD_PROCESS_SHARED));
627 }
628#else
629#error Your system must support PTHREAD_PROCESS_SHARED to use firebird.
630#endif
631 PTHREAD_ERROR(pthread_mutex_init(event->event_mutex, &mattr));
632 PTHREAD_ERROR(pthread_cond_init(event->event_cond, &cattr));
633 PTHREAD_ERROR(pthread_mutexattr_destroy(&mattr));
634 PTHREAD_ERROR(pthread_condattr_destroy(&cattr));
635
636 return FB_SUCCESS;
637
638#endif // OS-dependent choice
639
640}
641
642

Callers 6

create_processMethod · 0.80
init_owner_blockMethod · 0.80
ProfilerIpcMethod · 0.80
initClientMethod · 0.80
create_processMethod · 0.80
setupMethod · 0.80

Calls 4

ISC_make_signalFunction · 0.85
isSandboxedFunction · 0.85
pthread_mutex_initFunction · 0.85
pthread_cond_initFunction · 0.85

Tested by

no test coverage detected