Commit 43607106 authored by Liu Xiaodong's avatar Liu Xiaodong Committed by Jim Harris
Browse files

intr: allow operations on fd=0



It is possible that STDIN_FILENO is registered as one
interrupt source. So fd_group and spdk_thread should
accept fd whose value is "0".

Change-Id: I96c7e0d6dc1dfa10b42b59aadfa6dc159c133519
Signed-off-by: default avatarLiu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5161


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent add8fc15
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1098,6 +1098,7 @@ poller_register(spdk_poller_fn fn,
	if (thread->interrupt_mode && period_microseconds != 0) {
		int rc;

		poller->timerfd = -1;
		rc = thread_interrupt_register_timerfd(thread->fgrp, period_microseconds, poller);
		if (rc < 0) {
			SPDK_ERRLOG("Failed to register timerfd for periodic poller: %s\n", spdk_strerror(-rc));
@@ -1154,10 +1155,10 @@ spdk_poller_unregister(struct spdk_poller **ppoller)
		return;
	}

	if (thread->interrupt_mode && poller->timerfd) {
	if (thread->interrupt_mode && poller->timerfd >= 0) {
		spdk_fd_group_remove(thread->fgrp, poller->timerfd);
		close(poller->timerfd);
		poller->timerfd = 0;
		poller->timerfd = -1;
	}

	/* If the poller was paused, put it on the active_pollers list so that
@@ -1825,12 +1826,13 @@ thread_interrupt_destroy(struct spdk_thread *thread)

	SPDK_INFOLOG(thread, "destroy fgrp for thread (%s)\n", thread->name);

	if (thread->msg_fd <= 0) {
	if (thread->msg_fd < 0) {
		return;
	}

	spdk_fd_group_remove(fgrp, thread->msg_fd);
	close(thread->msg_fd);
	thread->msg_fd = -1;

	spdk_fd_group_destroy(fgrp);
	thread->fgrp = NULL;
+3 −3
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ spdk_fd_group_add(struct spdk_fd_group *fgrp,
	int rc;

	/* parameter checking */
	if (fgrp == NULL || efd <= 0 || fn == NULL) {
	if (fgrp == NULL || efd < 0 || fn == NULL) {
		return -EINVAL;
	}

@@ -132,7 +132,7 @@ spdk_fd_group_remove(struct spdk_fd_group *fgrp, int efd)
	struct event_handler *ehdlr;
	int rc;

	if (fgrp == NULL || efd <= 0) {
	if (fgrp == NULL || efd < 0) {
		SPDK_ERRLOG("Invalid to remvoe efd(%d) from fd_group(%p).\n", efd, fgrp);
		assert(0);
		return;
@@ -177,7 +177,7 @@ spdk_fd_group_event_modify(struct spdk_fd_group *fgrp,
	struct epoll_event epevent;
	struct event_handler *ehdlr;

	if (fgrp == NULL || efd <= 0) {
	if (fgrp == NULL || efd < 0) {
		return -EINVAL;
	}