소스 검색

Move the closing of file descriptors from the destructor to
the finalize function. This allows threads waiting on poll to
wake up and release handle references.

(Logical change 1.205)


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@662 fd59a12c-fef9-0310-b244-a6a79926bd2f

Mark Haverkamp 21 년 전
부모
커밋
bf199836cf
5개의 변경된 파일52개의 추가작업 그리고 52개의 파일을 삭제
  1. 9 10
      lib/amf.c
  2. 10 5
      lib/ckpt.c
  3. 9 10
      lib/clm.c
  4. 12 14
      lib/evs.c
  5. 12 13
      lib/evt.c

+ 9 - 10
lib/amf.c

@@ -100,16 +100,6 @@ static struct saVersionDatabase amfVersionDatabase = {
 
 void amfHandleInstanceDestructor (void *instance)
 {
-	struct amfInstance *amfInstance = (struct amfInstance *)instance;
-
-	if (amfInstance->response_fd != -1) {
-		shutdown (amfInstance->response_fd, 0);
-		close (amfInstance->response_fd);
-	}
-	if (amfInstance->dispatch_fd != -1) {
-		shutdown (amfInstance->dispatch_fd, 0);
-		close (amfInstance->dispatch_fd);
-	}
 }
 
 SaErrorT
@@ -400,6 +390,15 @@ saAmfFinalize (
 
 	saHandleDestroy (&amfHandleDatabase, *amfHandle);
 
+	if (amfInstance->response_fd != -1) {
+		shutdown (amfInstance->response_fd, 0);
+		close (amfInstance->response_fd);
+	}
+	if (amfInstance->dispatch_fd != -1) {
+		shutdown (amfInstance->dispatch_fd, 0);
+		close (amfInstance->dispatch_fd);
+	}
+
 	saHandleInstancePut (&amfHandleDatabase, *amfHandle);
 
 	return (error);

+ 10 - 5
lib/ckpt.c

@@ -142,10 +142,6 @@ void ckptHandleInstanceDestructor (void *instance)
 {
 struct ckptInstance *ckptInstance = (struct ckptInstance *)instance;
 
-	if (ckptInstance->response_fd != -1) {
-		shutdown (ckptInstance->response_fd, 0);
-		close (ckptInstance->response_fd);
-	}
 }
 
 void checkpointHandleInstanceDestructor (void *instance)
@@ -434,9 +430,18 @@ saCkptFinalize (
 			ckptCheckpointInstance->checkpointHandle);
 	}
 
+	saHandleDestroy (&ckptHandleDatabase, ckptHandle);
+
+	if (ckptInstance->response_fd != -1) {
+		shutdown (ckptInstance->response_fd, 0);
+		close (ckptInstance->response_fd);
+	}
+	if (ckptInstance->dispatch_fd != -1) {
+		shutdown (ckptInstance->dispatch_fd, 0);
+		close (ckptInstance->dispatch_fd);
+	}
 	saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
 
-	saHandleDestroy (&ckptHandleDatabase, ckptHandle);
 
 	return (SA_AIS_OK);
 }

+ 9 - 10
lib/clm.c

@@ -90,16 +90,6 @@ static struct saVersionDatabase clmVersionDatabase = {
 
 void clmHandleInstanceDestructor (void *instance)
 {
-	struct clmInstance *clmInstance = (struct clmInstance *)instance;
-
-	if (clmInstance->response_fd != -1) {
-		shutdown (clmInstance->response_fd, 0);
-		close (clmInstance->response_fd);
-	}
-	if (clmInstance->dispatch_fd != -1) {
-		shutdown (clmInstance->dispatch_fd, 0);
-		close (clmInstance->dispatch_fd);
-	}
 }
 
 
@@ -383,6 +373,15 @@ saClmFinalize (
 
 	saHandleDestroy (&clmHandleDatabase, clmHandle);
 
+	if (clmInstance->response_fd != -1) {
+		shutdown (clmInstance->response_fd, 0);
+		close (clmInstance->response_fd);
+	}
+	if (clmInstance->dispatch_fd != -1) {
+		shutdown (clmInstance->dispatch_fd, 0);
+		close (clmInstance->dispatch_fd);
+	}
+
 	saHandleInstancePut (&clmHandleDatabase, clmHandle);
 
 	return (error);

+ 12 - 14
lib/evs.c

@@ -73,19 +73,6 @@ static struct saHandleDatabase evs_handle_t_db = {
  */
 static void evs_instance_destructor (void *instance)
 {
-    struct evs_inst *evs_inst = instance;
-
-    /*
-     * Disconnect from the server
-     */
-    if (evs_inst->response_fd != -1) {
-        shutdown(evs_inst->response_fd, 0);
-        close(evs_inst->response_fd);
-    }
-    if (evs_inst->dispatch_fd != -1) {
-        shutdown(evs_inst->dispatch_fd, 0);
-        close(evs_inst->dispatch_fd);
-    }
 }
 
 
@@ -157,9 +144,20 @@ evs_error_t evs_finalize (
 
 	pthread_mutex_unlock (&evs_inst->response_mutex);
 
+	saHandleDestroy (&evs_handle_t_db, handle);
+    /*
+     * Disconnect from the server
+     */
+    if (evs_inst->response_fd != -1) {
+        shutdown(evs_inst->response_fd, 0);
+        close(evs_inst->response_fd);
+    }
+    if (evs_inst->dispatch_fd != -1) {
+        shutdown(evs_inst->dispatch_fd, 0);
+        close(evs_inst->dispatch_fd);
+    }
 	saHandleInstancePut (&evs_handle_t_db, handle);
 
-	saHandleDestroy (&evs_handle_t_db, handle);
 
 	return (EVS_OK);
 }

+ 12 - 13
lib/evt.c

@@ -186,20 +186,7 @@ struct event_data_instance {
  */
 static void evtHandleInstanceDestructor(void *instance)
 {
-	struct event_instance *evti = instance;
 
-	/*
-	 * Disconnect from the server
-	 */
-    if (evti->ei_response_fd != -1) {
-		shutdown(evti->ei_response_fd, 0);
-		close(evti->ei_response_fd);
-	}
-
-	if (evti->ei_dispatch_fd != -1) {
-		shutdown(evti->ei_dispatch_fd, 0);
-		close(evti->ei_dispatch_fd);
-	}
 }
 
 /*
@@ -737,6 +724,18 @@ saEvtFinalize(SaEvtHandleT evtHandle)
 	pthread_mutex_unlock(&evti->ei_response_mutex);
 
 	saHandleDestroy(&evt_instance_handle_db, evtHandle);
+	/*
+	 * Disconnect from the server
+	 */
+    if (evti->ei_response_fd != -1) {
+		shutdown(evti->ei_response_fd, 0);
+		close(evti->ei_response_fd);
+	}
+
+	if (evti->ei_dispatch_fd != -1) {
+		shutdown(evti->ei_dispatch_fd, 0);
+		close(evti->ei_dispatch_fd);
+	}
 	saHandleInstancePut(&evt_instance_handle_db, evtHandle);
 
 	return error;