[PVFS2-CVS] commit by neill in pvfs2/src/io/bmi/bmi_tcp: bmi-tcp.c

CVS commit program cvs at parl.clemson.edu
Thu Jul 8 13:17:10 EDT 2004


Update of /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp
In directory parlweb:/tmp/cvs-serv12211/src/io/bmi/bmi_tcp

Modified Files:
	bmi-tcp.c 
Log Message:
- merging in the pvfs2-nm-nb-branch with the main tree
  see ChangeLog for details, or browse the cvs history of the branch
  for full details


Index: bmi-tcp.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp/bmi-tcp.c,v
diff -p -u -r1.82 -r1.83
--- bmi-tcp.c	13 May 2004 12:10:33 -0000	1.82
+++ bmi-tcp.c	8 Jul 2004 16:17:09 -0000	1.83
@@ -336,6 +336,11 @@ enum
     TCP_MODE_REND_LIMIT = 16777216	/* 16M */
 };
 
+/* toggles cancel mode; for bmi_tcp this will result in socket being closed
+ * in all cancellation cases
+ */
+static int forceful_cancel_mode = 0;
+
 /*************************************************************************
  * Visible Interface 
  */
@@ -616,6 +621,10 @@ int BMI_tcp_set_info(int option,
     switch (option)
     {
 
+    case BMI_FORCEFUL_CANCEL_MODE:
+	forceful_cancel_mode = 1;
+	ret = 0;
+	break;
     case BMI_DROP_ADDR:
 	if (inout_parameter == NULL)
 	{
@@ -1043,9 +1052,11 @@ int BMI_tcp_testcontext(int incount,
 
     /* pop as many items off of the completion queue as we can */
     while((*outcount < incount) && (query_op = 
-	op_list_shownext(completion_array[context_id]))) 
+	op_list_shownext(completion_array[context_id])))
     {
+        assert(query_op);
 	assert(query_op->context_id == context_id);
+
 	/* this one's done; pop it out */
 	op_list_remove(query_op);
 	error_code_array[*outcount] = query_op->error_code;
@@ -1061,6 +1072,7 @@ int BMI_tcp_testcontext(int incount,
 	    BMI_EVENT_END(PVFS_EVENT_BMI_RECV, query_op->actual_size, query_op->op_id);
 
 	dealloc_tcp_method_op(query_op);
+        query_op = NULL;
 	(*outcount)++;
     }
 
@@ -1284,6 +1296,9 @@ int BMI_tcp_cancel(bmi_op_id_t id, bmi_c
     if(((struct tcp_op*)(query_op->method_data))->tcp_op_state ==
 	BMI_TCP_COMPLETE)
     {
+	/* only close socket in forceful cancel mode */
+	if(forceful_cancel_mode)
+	    tcp_forget_addr(query_op->addr, 0, -BMI_ECANCEL);
 	/* we are done! status will be collected during test */
 	gen_mutex_unlock(&interface_mutex);
 	return(0);
@@ -1292,7 +1307,8 @@ int BMI_tcp_cancel(bmi_op_id_t id, bmi_c
     /* has the operation started moving data yet? */
     if(query_op->env_amt_complete)
     {
-	/* be pessimistic and kill the socket */
+	/* be pessimistic and kill the socket, even if not in forceful
+	 * cancel mode */
 	/* NOTE: this may place other operations beside this one into
 	 * EINTR error state 
 	 */
@@ -1315,8 +1331,10 @@ int BMI_tcp_cancel(bmi_op_id_t id, bmi_c
     op_list_remove(query_op);
     ((struct tcp_op*)(query_op->method_data))->tcp_op_state = 
 	BMI_TCP_COMPLETE;
+    /* only close socket in forceful cancel mode */
+    if(forceful_cancel_mode)
+	tcp_forget_addr(query_op->addr, 0, -BMI_ECANCEL);
     op_list_add(completion_array[query_op->context_id], query_op);
-
     gen_mutex_unlock(&interface_mutex);
     return(0);
 }
@@ -2024,6 +2042,12 @@ static int tcp_post_recv_generic(bmi_op_
 			    expected_size, context_id);
     /* just for safety; this field isn't valid to the caller anymore */
     (*actual_size) = 0;
+    /* TODO: figure out why this causes deadlocks; observable in 2
+     * scenarios:
+     * - pvfs2-client-core with threaded library and nptl
+     * - pvfs2-server threaded with nptl sending messages to itself
+     */
+#if 0
     if (ret >= 0)
     {
 	/* go ahead and try to do some work while we are in this
@@ -2032,6 +2056,7 @@ static int tcp_post_recv_generic(bmi_op_
 	 */
 	ret = tcp_do_work(0);
     }
+#endif
     return (ret);
 }
 



More information about the PVFS2-CVS mailing list