[stgt] [PATCH] "Delete and Add event instead of modifying on the fly"

Chandra Seetharaman sekharan at us.ibm.com
Fri Oct 15 06:57:02 CEST 2010


This applies cleanly on the "thread" branch.
---
When running thread per target feature under valgrind I occasionaly
saw some race where both the main thread and the target's thread are
in iscsi_tcp_event_handler(). Which at times lead to issues where
the connection was never getting disconnected (after the initiator
closed it).

Removing and adding the fd, under epoll control (instead of modifying
the flags to be 0), and the issues go away.

Signed-off-by: Chandra Seetharaman <sekharan at us.ibm.com>
---
 usr/iscsi/iscsi_tcp.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: tgt-thread/usr/iscsi/iscsi_tcp.c
===================================================================
--- tgt-thread.orig/usr/iscsi/iscsi_tcp.c
+++ tgt-thread/usr/iscsi/iscsi_tcp.c
@@ -177,7 +177,8 @@ static void iscsi_tcp_event_handler(int 
 			pthread_mutex_unlock(&target->event_lock);
 			/* let the main thread handle this */
 			tcp_conn->pthread = 0;
-			tgt_event_modify(tcp_conn->fd, EPOLLIN|EPOLLOUT|EPOLLERR);
+			tgt_event_add(tcp_conn->fd, EPOLLIN,
+					iscsi_tcp_event_handler, conn);
 		} else {
 			conn_close(conn);
 		}
@@ -285,7 +286,7 @@ static void iscsi_tcp_conn_nexus_init(st
 
 	if (iscsi_pthread_per_target()) {
 		/* remove the conn from the main thread. */
-		conn->tp->ep_event_modify(conn, 0);
+		tgt_event_del(tcp_conn->fd);
 
 		tcp_conn->pthread = 1;
 


--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list