Ejemplo n.º 1
0
static int del_session(struct iscsi_target *target, unsigned long ptr)
{
	int err;
	struct session_info info;

	if ((err = copy_from_user(&info, (void *) ptr, sizeof(info))) < 0)
		return err;

	return session_del(target, info.sid);
}
Ejemplo n.º 2
0
void session_close(session_list_t * list, session_t * session)
{
	fclose(session->file);
	fprintf(stdout, "DTNperf monitor: saved log file: %s\n\n", session->full_filename);
	session_del(session_list, session);
}
Ejemplo n.º 3
0
// session expiration timer thread
void * session_expiration_timer(void * opt)
{
	u32_t current_dtn_time;
	struct timeval current_time;
	session_t * session, * next;

	while(1)
	{
		pthread_sleep(5);
		current_dtn_time = get_current_dtn_time();
		gettimeofday(&current_time, NULL);

		pthread_mutex_lock(&mutexdata);

		for(session = session_list->first; session != NULL; session = next)
		{
			next = session->next;

			// all status reports has been received: close session
			if (session->total_to_receive > 0 && session->delivered_count == session->total_to_receive)
			{
				// close monitor if dedicated
				if (dedicated_monitor)
				{
					kill(getpid(), SIGUSR2);
				}
				else
				{
					session_close(session_list, session);
				}
			}

			// stop bundle arrived but not all the status reports have arrived and the timer has expired
			else if (session->total_to_receive > 0 &&session->stop_arrival_time->tv_sec + session->wait_after_stop < current_time.tv_sec)
			{
				fprintf(stdout, "DTNperf monitor: Session Expired: Bundle stop arrived, but not all the status reports did\n");

				// close monitor if dedicated
				if (dedicated_monitor)
				{
					kill(getpid(), SIGUSR2);
				}
				else
				{
					fprintf(stdout, "\tsaved log file: %s\n\n", session->full_filename);
					if (fclose(session->file) < 0)
						perror("Error closing expired file:");
					session_del(session_list, session);
				}
			}
			// stop bundle is not yet arrived and the last bundle has expired
			else if (session->last_bundle_time + session->expiration < current_dtn_time)
			{
				fprintf(stdout, "DTNperf monitor: Session Expired: Bundle stop did not arrive\n");

				// close monitor if dedicated
				if (dedicated_monitor)
				{
					kill(getpid(), SIGUSR2);
				}
				else
				{
					fprintf(stdout,"\tsaved log file: %s\n\n", session->full_filename);
					if (fclose(session->file) < 0)
						perror("Error closing expired file:");
					session_del(session_list, session);
				}
			}
		}
		pthread_mutex_unlock(&mutexdata);
		sched_yield();
	}
	pthread_exit(NULL);
}