Lines Matching refs:task_p

57 isns_run_task(struct isns_task_s *task_p)
67 DBG("isns_run_task: task_type=%d\n", task_p->task_type);
69 if (task_p->task_type < ARRAY_ELEMS(task_dispatch_table))
70 task_dispatch_table[task_p->task_type](task_p);
72 DBG("isns_run_task: unknown task type=%d\n", task_p->task_type);
77 isns_wait_task(struct isns_task_s *task_p, const struct timespec *timeout_p)
83 DBG("isns_wait_task: waitable=%d\n", task_p->waitable);
85 if (!task_p->waitable)
88 pthread_mutex_lock(&task_p->wait_mutex);
91 rval = pthread_cond_wait(&task_p->wait_condvar,
92 &task_p->wait_mutex);
98 rval = pthread_cond_timedwait(&task_p->wait_condvar,
99 &task_p->wait_mutex, &ts_abstime);
102 pthread_mutex_unlock(&task_p->wait_mutex);
104 isns_free_task(task_p);
113 isns_end_task(struct isns_task_s *task_p)
115 DBG("isns_end_task: %p\n", task_p);
116 if (task_p == task_p->cfg_p->curtask_p)
117 task_p->cfg_p->curtask_p = NULL;
119 if (task_p->waitable)
120 pthread_cond_signal(&task_p->wait_condvar);
122 isns_free_task(task_p);
127 isns_task_discover_server(struct isns_task_s *task_p)
132 isns_end_task(task_p);
140 isns_task_reconnect_server(struct isns_task_s *task_p)
148 ai_p = task_p->var.reconnect_server.ai_p;
150 rv = isns_socket_create(&(task_p->cfg_p->sd), ai_p->ai_family,
155 rv = isns_socket_connect(task_p->cfg_p->sd, ai_p->ai_addr,
159 rv = isns_change_kevent_list(task_p->cfg_p,
167 task_p->cfg_p->sd_connected = 1;
170 rv = isns_change_kevent_list(task_p->cfg_p,
171 (uintptr_t)(task_p->cfg_p->sd), EVFILT_READ,
178 isns_end_task(task_p);
185 * We send all of the pdu's associated with transaction task_p->trans_p here.
188 * (1) task_p->trans_p->pdu_req_list is an ordered (seq_id) list of
194 isns_task_send_pdu(struct isns_task_s *task_p)
209 cfg_p = task_p->cfg_p;
210 pdu_p = task_p->var.send_pdu.pdu_p;
308 if (!task_p->waitable) {
309 isns_complete_trans(task_p->var.send_pdu.trans_p);
310 isns_end_task(task_p);
318 isns_task_init_socket_io(struct isns_task_s *task_p)
326 cfg_p = task_p->cfg_p;
345 cfg_p->sd = task_p->var.init_socket_io.sd;
346 cfg_p->ai_p = task_p->var.init_socket_io.ai_p;
358 isns_end_task(task_p);
363 * isns_task_init_refresh(struct isns_task_s *task_p)
366 isns_task_init_refresh(struct isns_task_s *task_p)
374 cfg_p = task_p->cfg_p;
382 cfg_p->refresh_p = task_p->var.init_refresh.ref_p;
395 isns_end_task(task_p);
403 struct isns_task_s *task_p;
407 task_p = NULL;
410 task_p = (struct isns_task_s *)isns_buffer_data(buf_p, 0);
411 task_p->cfg_p = cfg_p;
412 task_p->task_type = task_type;
413 task_p->waitable = waitable;
419 pthread_mutex_init(&task_p->wait_mutex, &mutexattr);
422 pthread_cond_init(&task_p->wait_condvar, &condattr);
423 task_p->wait_ref_count = 2;
427 DBG("isns_new_task: %p, waitable=%d\n", task_p, waitable);
429 return task_p;
434 isns_free_task(struct isns_task_s *task_p)
439 DBG("isns_free_task: %p\n", task_p);
440 if (task_p->waitable) {
441 pthread_mutex_lock(&task_p->wait_mutex);
442 ref_count = --task_p->wait_ref_count;
443 pthread_mutex_unlock(&task_p->wait_mutex);
450 pthread_mutex_destroy(&task_p->wait_mutex);
451 pthread_cond_destroy(&task_p->wait_condvar);
453 buf_p = ((struct isns_buffer_s *)(void *)(task_p))-1;
460 struct isns_task_s *task_p)
463 SIMPLEQ_INSERT_HEAD(&cfg_p->taskq_head, task_p, taskq_entry);
466 DBG("isns_taskq_insert_head: %p\n", task_p);
472 struct isns_task_s *task_p)
475 SIMPLEQ_INSERT_TAIL(&cfg_p->taskq_head, task_p, taskq_entry);
478 DBG("isns_taskq_insert_tail: %p\n", task_p);
485 struct isns_task_s *task_p = NULL;
488 if ((task_p = SIMPLEQ_FIRST(&cfg_p->taskq_head)) != NULL)
492 DBG("isns_taskq_remove: %p\n", task_p);
494 return task_p;
501 struct isns_task_s *task_p;
506 SIMPLEQ_FOREACH(task_p, &cfg_p->taskq_head, taskq_entry) {
507 if ((task_p->task_type == ISNS_TASK_SEND_PDU)
508 && (task_p->var.send_pdu.trans_p->id == trans_id)) {
514 SIMPLEQ_REMOVE(&cfg_p->taskq_head, task_p, isns_task_s,
519 return (trans_found ? task_p : NULL);