Beispiel #1
0
/** Mark the endpoint as inactive and allow access for further fibrils.
 * @param instance endpoint_t structure.
 */
void endpoint_release(endpoint_t *instance)
{
	assert(instance);
	fibril_mutex_lock(&instance->guard);
	instance->active = false;
	fibril_mutex_unlock(&instance->guard);
	fibril_condvar_signal(&instance->avail);
}
Beispiel #2
0
void prodcons_produce(prodcons_t *pc, link_t *item)
{
	fibril_mutex_lock(&pc->mtx);
	
	list_append(item, &pc->list);
	fibril_condvar_signal(&pc->cv);
	
	fibril_mutex_unlock(&pc->mtx);
}
Beispiel #3
0
/** Fibril for spawning the task running after user connects.
 *
 * @param arg Corresponding @c telnet_user_t structure.
 */
static int spawn_task_fibril(void *arg)
{
	telnet_user_t *user = arg;
	int rc;

	char term[LOC_NAME_MAXLEN];
	snprintf(term, LOC_NAME_MAXLEN, "%s/%s", "/loc", user->service_name);

	task_id_t task;
	rc = task_spawnl(&task, APP_GETTERM, APP_GETTERM, "-w", term, APP_SHELL, NULL);
	if (rc != EOK) {
		telnet_user_error(user, "Spawning `%s -w %s %s' failed: %s.",
		    APP_GETTERM, term, APP_SHELL, str_error(rc));
		fibril_mutex_lock(&user->guard);
		user->task_finished = true;
		user->srvs.aborted = true;
		fibril_condvar_signal(&user->refcount_cv);
		fibril_mutex_unlock(&user->guard);
		return EOK;
	}

	fibril_mutex_lock(&user->guard);
	user->task_id = task;
	fibril_mutex_unlock(&user->guard);

	task_exit_t task_exit;
	int task_retval;
	task_wait(task, &task_exit, &task_retval);
	telnet_user_log(user, "%s terminated %s, exit code %d.", APP_GETTERM,
	    task_exit == TASK_EXIT_NORMAL ? "normally" : "unexpectedly",
	    task_retval);

	/* Announce destruction. */
	fibril_mutex_lock(&user->guard);
	user->task_finished = true;
	user->srvs.aborted = true;
	fibril_condvar_signal(&user->refcount_cv);
	fibril_mutex_unlock(&user->guard);

	return EOK;
}