MCPcopy Create free account
hub / github.com/ceph/ceph / try_create

Method try_create

src/common/Thread.cc:114–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114int Thread::try_create(size_t stacksize)
115{
116 pthread_attr_t *thread_attr = NULL;
117 pthread_attr_t thread_attr_loc;
118
119 stacksize &= CEPH_PAGE_MASK; // must be multiple of page
120 if (stacksize) {
121 thread_attr = &thread_attr_loc;
122 pthread_attr_init(thread_attr);
123 pthread_attr_setstacksize(thread_attr, stacksize);
124 }
125
126 int r;
127
128 // The child thread will inherit our signal mask. Set our signal mask to
129 // the set of signals we want to block. (It's ok to block signals more
130 // signals than usual for a little while-- they will just be delivered to
131 // another thread or delieverd to this thread later.)
132
133 #ifndef _WIN32
134 sigset_t old_sigset;
135 if (g_code_env == CODE_ENVIRONMENT_LIBRARY) {
136 block_signals(NULL, &old_sigset);
137 }
138 else {
139 int to_block[] = { SIGPIPE , 0 };
140 block_signals(to_block, &old_sigset);
141 }
142 r = pthread_create(&thread_id, thread_attr, _entry_func, (void*)this);
143 restore_sigset(&old_sigset);
144 #else
145 r = pthread_create(&thread_id, thread_attr, _entry_func, (void*)this);
146 #endif
147
148 if (thread_attr) {
149 pthread_attr_destroy(thread_attr);
150 }
151
152 return r;
153}
154
155void Thread::create(const char *name, size_t stacksize)
156{

Callers

nothing calls this directly

Calls 3

pthread_createFunction · 0.85
restore_sigsetFunction · 0.85
block_signalsFunction · 0.70

Tested by

no test coverage detected