コード例 #1
0
ファイル: vfs_aio_pthread.c プロジェクト: ebrainte/Samba
static void aio_open_handle_completion(struct event_context *event_ctx,
				struct fd_event *event,
				uint16 flags,
				void *p)
{
	struct aio_open_private_data *opd = NULL;
	int jobid = 0;
	int ret;

	DEBUG(10, ("aio_open_handle_completion called with flags=%d\n",
		(int)flags));

	if ((flags & EVENT_FD_READ) == 0) {
		return;
	}

	ret = pthreadpool_finished_job(open_pool, &jobid);
	if (ret) {
		smb_panic("aio_open_handle_completion");
		/* notreached. */
		return;
	}

	opd = find_open_private_data_by_jobid(jobid);
	if (opd == NULL) {
		DEBUG(0, ("aio_open_handle_completion cannot find jobid %d\n",
			jobid));
		smb_panic("aio_open_handle_completion - no jobid");
		/* notreached. */
		return;
	}

	DEBUG(10,("aio_open_handle_completion: jobid %d mid %llu "
		"for file %s/%s completed\n",
		jobid,
		(unsigned long long)opd->mid,
		opd->dname,
		opd->fname));

	opd->in_progress = false;

	/* Find outstanding event and reschdule. */
	if (!schedule_deferred_open_message_smb(opd->sconn, opd->mid)) {
		/*
		 * Outstanding event didn't exist or was
		 * cancelled. Free up the fd and throw
		 * away the result.
		 */
		if (opd->ret_fd != -1) {
			close(opd->ret_fd);
			opd->ret_fd = -1;
		}
		TALLOC_FREE(opd);
	}
}
コード例 #2
0
ファイル: vfs_aio_pthread.c プロジェクト: encukou/samba
static void aio_open_handle_completion(struct tevent_context *event_ctx,
				struct tevent_fd *event,
				uint16_t flags,
				void *p)
{
	struct aio_open_private_data *opd = NULL;
	int jobid = 0;
	int ret;
	struct smbXsrv_connection *xconn;

	DEBUG(10, ("aio_open_handle_completion called with flags=%d\n",
		(int)flags));

	if ((flags & TEVENT_FD_READ) == 0) {
		return;
	}

	ret = pthreadpool_pipe_finished_jobs(open_pool, &jobid, 1);
	if (ret != 1) {
		smb_panic("aio_open_handle_completion");
		/* notreached. */
		return;
	}

	opd = find_open_private_data_by_jobid(jobid);
	if (opd == NULL) {
		DEBUG(0, ("aio_open_handle_completion cannot find jobid %d\n",
			jobid));
		smb_panic("aio_open_handle_completion - no jobid");
		/* notreached. */
		return;
	}

	DEBUG(10,("aio_open_handle_completion: jobid %d mid %llu "
		"for file %s/%s completed\n",
		jobid,
		(unsigned long long)opd->mid,
		opd->dname,
		opd->fname));

	opd->in_progress = false;

	/*
	 * TODO: In future we need a proper algorithm
	 * to find the correct connection for a fsp.
	 * For now we only have one connection, so this is correct...
	 */
	xconn = opd->sconn->client->connections;

	/* Find outstanding event and reschedule. */
	if (!schedule_deferred_open_message_smb(xconn, opd->mid)) {
		/*
		 * Outstanding event didn't exist or was
		 * cancelled. Free up the fd and throw
		 * away the result.
		 */
		if (opd->ret_fd != -1) {
			close(opd->ret_fd);
			opd->ret_fd = -1;
		}
		TALLOC_FREE(opd);
	}
}