- pthread_mutex_unlock(&mutex);
- while (count)
- pthread_join(others[--count], NULL);
- pthread_mutex_lock(&mutex);
-
- /* cancel pending jobs of other threads */
- remains = 0;
- head = first_job;
- first_job = NULL;
- tail = NULL;
- while (head) {
- /* unlink the job */
- job = head;
- head = job->next;
-
- /* search if job is stacked for current */
- t = current;
- while (t && t->job != job)
- t = t->upper;
- if (t) {
- /* yes, relink it at end */
- if (tail)
- tail->next = job;
- else
- first_job = job;
- tail = job;
- job->next = NULL;
- } else {
- /* no cancel the job */
- pthread_mutex_unlock(&mutex);
- sig_monitor(0, job_cancel, job);
- free(job);
- pthread_mutex_lock(&mutex);
- }
- }
- pthread_mutex_unlock(&mutex);
-}
-
-/**
- * Adds the current thread to the pool of threads
- * processing the jobs. Returns normally when the threads are
- * terminated or immediately with an error if the thread is
- * already in the pool.
- * @return 0 in case of success or -1 in case of error
- */
-int jobs_add_me()
-{
- struct thread me;
-
- /* check whether already running */
- if (current) {
- ERROR("thread already running");
- errno = EINVAL;
- return -1;
- }
-
- /* allowed... */
- pthread_mutex_lock(&mutex);
- allowed++;
- thread_run(&me);
- allowed--;
- pthread_mutex_unlock(&mutex);
- return 0;
-}
-
-
-struct sd_event *jobs_get_sd_event()
-{
- struct events *events;
- struct thread *me;
- int rc;
-
- pthread_mutex_lock(&mutex);