/** * Cleanup the rdev service: * - free the buffers allocated bu rdev_init(), * - stop the exa_rdev kernel module. */ static int rdev_shutdown(int thr_nb) { broken_disk_table_unload(&broken_disks); /* close the rdev checking thread */ quit = true; if (rdev_check_id_started) os_thread_join(rdev_check_id); rdev_check_id_started = false; os_aligned_free(rdev_check_buffer); if (exa_rdev_fd > 0) close(exa_rdev_fd); exa_rdev_static_clean(RDEV_STATIC_DELETE); examsgExit(mh); if (os_kmod_unload("exa_rdev") != 0) return -ADMIND_ERR_MODULESTOP; return EXA_SUCCESS; }
int algopr_close_plugin(void) { algopr_run = false; wq_wake(ð.wq_send); os_thread_join(eth.send_thread); os_thread_join(eth.receive_thread); __close_socket(eth.accept_sock); os_thread_join(eth.accept_thread); /* Reset these last, threads may need it until joined */ cleanup_peers(); this_node_id = EXA_NODEID_NONE; /* FIXME What about resetting 'eth'? */ return EXA_SUCCESS; }
/* * rpmemd_fip_stop_thread -- stop background thread for in-band connection */ static int rpmemd_fip_stop_thread(struct rpmemd *rpmemd) { RPMEMD_ASSERT(rpmemd->fip_running); void *tret; errno = os_thread_join(&rpmemd->fip_thread, &tret); if (errno) RPMEMD_LOG(ERR, "!waiting for in-band thread"); int ret = (int)(uintptr_t)tret; if (ret) RPMEMD_LOG(ERR, "in-band thread failed -- '%d'", ret); return ret; }
int daemon_main(void) { os_thread_t net_events_thread; if (exathread_create(&net_events_thread, EXAMSGD_STACK_SIZE + MIN_THREAD_STACK_SIZE, net_events_routine, NULL)) { /* Init was ok, and thread is running => start the real work */ local_events_routine(NULL); os_thread_join(net_events_thread); } cleanup(); exalog_static_clean(); examsg_static_clean(EXAMSG_STATIC_RELEASE); os_meminfo("Examsgd", OS_MEMINFO_DETAILED); return 0; }
ut_cleanup() { int i; tm_disconnect(user_tm); tm_free(&user_tm); for (i = 0; i < NUM_TEST_CLUSTERS; i++) { tm_disconnect(clusters[i].tms[0]); tm_free(&clusters[i].tms[0]); tm_disconnect(clusters[i].tms[1]); tm_free(&clusters[i].tms[1]); } os_sleep(1); token_manager_thread_stop(); os_thread_join(server_thread); unlink(test_tokens_file); os_random_cleanup(); }
int unexport_device(const exa_uuid_t *uuid) { device_t *dev = find_device_from_uuid(uuid); if (dev == NULL) { exalog_error("can not remove unknown device with UUID = " UUID_FMT, UUID_VAL(uuid)); return -CMD_EXP_ERR_UNKNOWN_DEVICE; } os_thread_mutex_lock(&nbd_server.mutex_edevs); /* ask the thread to terminate */ dev->exit_thread = true; /* prevent any new IO to be put in device IO list */ nbd_server.devices[dev->dev_index] = NULL; os_thread_mutex_unlock(&nbd_server.mutex_edevs); /* now we can join, because with the nbd_close_list() * we can assume was the disk thread will reach a cancelation point */ os_thread_join(nbd_server.td_pid[dev->dev_index]); /* close the list used to disk queue */ nbd_close_list(&dev->disk_queue); /* get back all header in the kernel exa_rdev to the free list and close the device */ if (dev->handle != NULL) exa_rdev_handle_free(dev->handle); /* close the semaphore used by the disk */ os_sem_destroy(&dev->lock_sem_disk); /* free used memory for the device */ os_free(dev); return EXA_SUCCESS; }
void cli_server_stop(void) { stop = true; os_thread_join(thr_xml_proto); }
int jpeg_encode (uint8_t * Y, uint8_t * UV, yuv_args_t * _yuv_args) { int rc, i; encoder_args_t encoder_args; memset (&encoder_args, 0, sizeof (encoder_args)); LOG_D ("=============================================================\n"); LOG_D ("Encoder start\n"); LOG_D ("=============================================================\n"); encoder_args.main.y_buf = Y; encoder_args.main.uv_buf = UV; encoder_args.main.quality = _yuv_args->quality; // encoder_args.thumbnail.quality = 50; encoder_args.main.width = _yuv_args->width; // encoder_args.thumbnail.width = 0; encoder_args.main.height = _yuv_args->height; // encoder_args.thumbnail.height = 0; encoder_args.rotation = 0; // encoder_args.encode_thumbnail = true; encoder_args.main.format = YCBCRLP_H2V2; // encoder_args.thumbnail.format = YCBCRLP_H2V2; encoder_args.preference = _yuv_args->preference; encoder_args.back_to_back_count = 1; #if 0 encoder_args.main_scale_cfg.enable = false; encoder_args.main_scale_cfg.input_width = 0; encoder_args.main_scale_cfg.input_height = 0; encoder_args.main_scale_cfg.output_width = 0; encoder_args.main_scale_cfg.output_height = 0; encoder_args.main_scale_cfg.h_offset = 0; encoder_args.main_scale_cfg.v_offset = 0; encoder_args.tn_scale_cfg.enable = false; encoder_args.tn_scale_cfg.input_width = 0; encoder_args.tn_scale_cfg.input_height = 0; encoder_args.tn_scale_cfg.output_width = 0; encoder_args.tn_scale_cfg.output_height = 0; encoder_args.tn_scale_cfg.h_offset = 0; encoder_args.tn_scale_cfg.v_offset = 0; encoder_args.target_filesize = 0; #endif encoder_args.abort_time = 0; encoder_args.use_pmem = false; // Double check all the required arguments are set #if 0 if (!encoder_args.main.file_name || !encoder_args.output_file || !encoder_args.main.width || !encoder_args.main.height || encoder_args.main.format == 8) { LOG_D ("Missing required arguments.\n"); return 1; } if (encoder_args.encode_thumbnail && (!encoder_args.thumbnail.file_name || !encoder_args.thumbnail.width || !encoder_args.thumbnail.height || encoder_args.thumbnail.format == 8)) { LOG_D ("Missing thumbnail arguments.\n"); return 1; } #endif // Create thread control blocks thread_ctrl_blks = (thread_ctrl_blk_t *) malloc (concurrent_cnt * sizeof (thread_ctrl_blk_t)); if (!thread_ctrl_blks) { LOG_D ("hw_engine_encode failed: insufficient memory in creating thread control blocks\n"); return 1; } memset (thread_ctrl_blks, 0, concurrent_cnt * sizeof (thread_ctrl_blk_t)); // Initialize the blocks and kick off the threads for (i = 0; i < concurrent_cnt; i++) { thread_ctrl_blks[i].tid = i; thread_ctrl_blks[i].p_args = &encoder_args; os_mutex_init (&thread_ctrl_blks[i].output_handler_args.mutex); os_cond_init (&thread_ctrl_blks[i].output_handler_args.cond); if (os_thread_create(&thread_ctrl_blks[i].thread, hw_engine_encode,&thread_ctrl_blks[i])) { LOG_D ("hw_engine_encode: os_create failed\n"); return 1; } } rc = 0; // Join the threads for (i = 0; i < concurrent_cnt; i++) { OS_THREAD_FUNC_RET_T ret; os_thread_join (&thread_ctrl_blks[i].thread, &ret); if (ret) { LOG_D ("hw_engine_encode: thread %d failed\n", i); rc = (int) OS_THREAD_FUNC_RET_FAILED; } } free (thread_ctrl_blks); if (!rc) LOG_D ("hw_engine_encode finished successfully\n"); LOG_D ("exit value: %d\n", rc); return rc; }