Helper function to support starting threads for SIGEV_THREAD. */
| 169 | |
| 170 | /* Helper function to support starting threads for SIGEV_THREAD. */ |
| 171 | static void * |
| 172 | timer_helper_thread(void *arg) |
| 173 | { |
| 174 | helper_tid = syscall(SYS_gettid); |
| 175 | sem_post(&helper_notification); |
| 176 | |
| 177 | /* Wait for the SIGTIMER signal, allowing the setXid signal, and |
| 178 | none else. */ |
| 179 | sigset_t ss; |
| 180 | sigemptyset(&ss); |
| 181 | sigaddset(&ss, SIGTIMER); |
| 182 | |
| 183 | /* Endless loop of waiting for signals. The loop is only ended when |
| 184 | the thread is canceled. */ |
| 185 | while (1) { |
| 186 | siginfo_t si; |
| 187 | |
| 188 | /* sigwaitinfo cannot be used here, since it deletes |
| 189 | SIGCANCEL == SIGTIMER from the set. */ |
| 190 | |
| 191 | pthread_testcancel(); |
| 192 | |
| 193 | // int oldtype = LIBC_CANCEL_ASYNC (); |
| 194 | |
| 195 | /* XXX The size argument hopefully will have to be changed to the |
| 196 | real size of the user-level sigset_t. */ |
| 197 | int result = sigtimedwait(&ss, &si, NULL); |
| 198 | |
| 199 | // LIBC_CANCEL_RESET (oldtype); |
| 200 | |
| 201 | if (result > 0) { |
| 202 | if (si.si_code == SI_TIMER) { |
| 203 | struct timer *tk = (struct timer *)si.si_ptr; |
| 204 | |
| 205 | /* Check the timer is still used and will not go away |
| 206 | while we are reading the values here. */ |
| 207 | DmtcpMutexLock(&active_timer_sigev_thread_lock); |
| 208 | |
| 209 | struct timer *runp = active_timer_sigev_thread; |
| 210 | while (runp != NULL) { |
| 211 | if (runp == tk) { |
| 212 | break; |
| 213 | } else { |
| 214 | runp = runp->next; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | if (runp != NULL) { |
| 219 | struct thread_start_data *td = |
| 220 | (struct thread_start_data *)JALLOC_MALLOC(sizeof(*td)); |
| 221 | |
| 222 | /* There is not much we can do if the allocation fails. */ |
| 223 | if (td != NULL) { |
| 224 | /* This is the signal we are waiting for. */ |
| 225 | td->thrfunc = tk->thrfunc; |
| 226 | td->sival = tk->sival; |
| 227 | |
| 228 | pthread_t th; |
nothing calls this directly
no test coverage detected