Browse Source

defect 1088
First patch for porting to BSD systems. This patch removes the WAITALL
flag entirely from the library handlers, as it appears there may be some
portability problems with this flag. The code already handles partial
reads anyway, so it was not necessary.


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

Steven Dake 20 năm trước cách đây
mục cha
commit
c35db8b2c7
10 tập tin đã thay đổi với 46 bổ sung80 xóa
  1. 2 3
      lib/amf.c
  2. 2 3
      lib/cfg.c
  3. 22 35
      lib/ckpt.c
  4. 2 3
      lib/clm.c
  5. 2 3
      lib/evs.c
  6. 4 6
      lib/evt.c
  7. 2 3
      lib/lck.c
  8. 2 3
      lib/msg.c
  9. 7 12
      lib/util.c
  10. 1 9
      lib/util.h

+ 2 - 3
lib/amf.c

@@ -253,14 +253,13 @@ saAmfDispatch (
 			 * Queue empty, read response from socket
 			 */
 			error = saRecvRetry (amfInstance->dispatch_fd, &dispatch_data.header,
-				sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
+				sizeof (struct res_header));
 			if (error != SA_AIS_OK) {
 				goto error_unlock;
 			}
 			if (dispatch_data.header.size > sizeof (struct res_header)) {
 				error = saRecvRetry (amfInstance->dispatch_fd, &dispatch_data.data,
-					dispatch_data.header.size - sizeof (struct res_header),
-					MSG_WAITALL | MSG_NOSIGNAL);
+					dispatch_data.header.size - sizeof (struct res_header));
 				if (error != SA_AIS_OK) {
 					goto error_unlock;
 				}

+ 2 - 3
lib/cfg.c

@@ -251,14 +251,13 @@ openaisCfgDispatch (
 			 * Queue empty, read response from socket
 			 */
 			error = saRecvRetry (cfgInstance->dispatch_fd, &dispatch_data.header,
-				sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
+				sizeof (struct res_header));
 			if (error != SA_OK) {
 				goto error_unlock;
 			}
 			if (dispatch_data.header.size > sizeof (struct res_header)) {
 				error = saRecvRetry (cfgInstance->dispatch_fd, &dispatch_data.data,
-					dispatch_data.header.size - sizeof (struct res_header),
-					MSG_WAITALL | MSG_NOSIGNAL);
+					dispatch_data.header.size - sizeof (struct res_header));
 				if (error != SA_OK) {
 					goto error_unlock;
 				}

+ 22 - 35
lib/ckpt.c

@@ -391,14 +391,13 @@ saCkptDispatch (
 		}
 		
 		memset(&dispatch_data,0, sizeof(struct message_overlay));
-		error = saRecvRetry (ckptInstance->dispatch_fd, &dispatch_data.header, sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
+		error = saRecvRetry (ckptInstance->dispatch_fd, &dispatch_data.header, sizeof (struct res_header));
 		if (error != SA_AIS_OK) {
 			goto error_unlock;
 		}
 		if (dispatch_data.header.size > sizeof (struct res_header)) {
 			error = saRecvRetry (ckptInstance->dispatch_fd, &dispatch_data.data,
-				dispatch_data.header.size - sizeof (struct res_header),
-				MSG_WAITALL | MSG_NOSIGNAL);
+				dispatch_data.header.size - sizeof (struct res_header));
 			if (error != SA_AIS_OK) {
 				goto error_unlock;
 			}
@@ -629,7 +628,7 @@ saCkptCheckpointOpen (
 	}
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd, &res_lib_ckpt_checkpointopen,
-		sizeof (struct res_lib_ckpt_checkpointopen), MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_checkpointopen));
 	if (error != SA_AIS_OK) {
 		goto error_put_destroy;
 	}
@@ -758,8 +757,7 @@ saCkptCheckpointOpenAsync (
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
 		&res_lib_ckpt_checkpointopenasync,
-		sizeof (struct res_lib_ckpt_checkpointopenasync),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_checkpointopenasync));
 	if (error != SA_AIS_OK) {
 		goto error_put_destroy;
 	}
@@ -814,7 +812,7 @@ saCkptCheckpointClose (
 	}
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd, &res_lib_ckpt_checkpointclose,
-		sizeof (struct res_lib_ckpt_checkpointclose), MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_checkpointclose));
 
 	if (error == SA_AIS_OK) {
 		error = res_lib_ckpt_checkpointclose.header.error;
@@ -861,7 +859,7 @@ saCkptCheckpointUnlink (
 	}
 
 	error = saRecvRetry (ckptInstance->response_fd, &res_lib_ckpt_checkpointunlink,
-		sizeof (struct res_lib_ckpt_checkpointunlink), MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_checkpointunlink));
 
 exit_put:
 	saHandleInstancePut (&ckptHandleDatabase, ckptHandle);
@@ -904,8 +902,7 @@ saCkptCheckpointRetentionDurationSet (
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
 		&res_lib_ckpt_checkpointretentiondurationset,
-		sizeof (struct res_lib_ckpt_checkpointretentiondurationset),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_checkpointretentiondurationset));
 
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
 
@@ -950,8 +947,7 @@ saCkptActiveReplicaSet (
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
 		&res_lib_ckpt_activereplicaset,
-		sizeof (struct res_lib_ckpt_activereplicaset),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_activereplicaset));
 
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
 
@@ -996,8 +992,7 @@ saCkptCheckpointStatusGet (
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
 		&res_lib_ckpt_checkpointstatusget,
-		sizeof (struct res_lib_ckpt_checkpointstatusget),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_checkpointstatusget));
 	if (error != SA_AIS_OK) {
 		goto error_exit;
 	}
@@ -1082,8 +1077,7 @@ saCkptSectionCreate (
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
 		&res_lib_ckpt_sectioncreate,
-		sizeof (struct res_lib_ckpt_sectioncreate),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_sectioncreate));
 
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
 
@@ -1144,8 +1138,7 @@ saCkptSectionDelete (
 	}
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
 		&res_lib_ckpt_sectiondelete,
-		sizeof (struct res_lib_ckpt_sectiondelete),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_sectiondelete));
 
 error_exit:
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
@@ -1211,8 +1204,7 @@ saCkptSectionExpirationTimeSet (
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
 		&res_lib_ckpt_sectionexpirationtimeset,
-		sizeof (struct res_lib_ckpt_sectionexpirationtimeset),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_sectionexpirationtimeset));
 
 error_exit:
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
@@ -1304,8 +1296,7 @@ saCkptSectionIterationInitialize (
 
 	error = saRecvRetry (ckptSectionIterationInstance->response_fd,
 		&res_lib_ckpt_sectioniterationinitialize,
-		sizeof (struct res_lib_ckpt_sectioniterationinitialize),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_sectioniterationinitialize));
 
 	pthread_mutex_unlock (&ckptSectionIterationInstance->response_mutex);
 
@@ -1370,7 +1361,7 @@ saCkptSectionIterationNext (
 	}
 
 	error = saRecvRetry (ckptSectionIterationInstance->response_fd, &res_lib_ckpt_sectioniteratornext,
-		sizeof (struct res_lib_ckpt_sectioniteratornext), MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_sectioniteratornext));
 	if (error != SA_AIS_OK) {
 		goto error_put_unlock;
 	}
@@ -1385,8 +1376,7 @@ saCkptSectionIterationNext (
 		error = saRecvRetry (ckptSectionIterationInstance->response_fd,
 			sectionDescriptor->sectionId.id,
 			res_lib_ckpt_sectioniteratornext.header.size -
-				sizeof (struct res_lib_ckpt_sectioniteratornext),
-			MSG_WAITALL | MSG_NOSIGNAL);
+				sizeof (struct res_lib_ckpt_sectioniteratornext));
 	}
 
 	error = (error == SA_AIS_OK ? res_lib_ckpt_sectioniteratornext.header.error : error);
@@ -1443,7 +1433,7 @@ saCkptSectionIterationFinalize (
 	}
 
 	error = saRecvRetry (ckptSectionIterationInstance->response_fd, &res_lib_ckpt_sectioniterationfinalize,
-		sizeof (struct res_lib_ckpt_sectioniterationfinalize), MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_sectioniterationfinalize));
 	if (error != SA_AIS_OK) {
 		goto error_put;
 	}
@@ -1528,7 +1518,7 @@ saCkptCheckpointWrite (
 		 * Receive response
 		 */
 		error = saRecvRetry (ckptCheckpointInstance->response_fd, &res_lib_ckpt_sectionwrite,
-			sizeof (struct res_lib_ckpt_sectionwrite), MSG_WAITALL | MSG_NOSIGNAL);
+			sizeof (struct res_lib_ckpt_sectionwrite));
 		if (error != SA_AIS_OK) {
 			goto error_exit;
 		}
@@ -1616,8 +1606,7 @@ saCkptSectionOverwrite (
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
 		&res_lib_ckpt_sectionoverwrite,
-		sizeof (struct res_lib_ckpt_sectionoverwrite),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_sectionoverwrite));
 
 error_exit:
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
@@ -1684,7 +1673,7 @@ saCkptCheckpointRead (
 		 * Receive response header
 		 */
 		error = saRecvRetry (ckptCheckpointInstance->response_fd, &res_lib_ckpt_sectionread,
-			sizeof (struct res_lib_ckpt_sectionread), MSG_WAITALL | MSG_NOSIGNAL);
+			sizeof (struct res_lib_ckpt_sectionread));
 		if (error != SA_AIS_OK) {
 				goto error_exit;
 		}
@@ -1705,7 +1694,7 @@ saCkptCheckpointRead (
 		
 		if (dataLength > 0) {
 			error = saRecvRetry (ckptCheckpointInstance->response_fd, ioVector[i].dataBuffer,
-				dataLength, MSG_WAITALL | MSG_NOSIGNAL);
+				dataLength);
 			if (error != SA_AIS_OK) {
 					goto error_exit;
 			}
@@ -1772,8 +1761,7 @@ saCkptCheckpointSynchronize (
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
 		&res_lib_ckpt_checkpointsynchronize,
-		sizeof (struct res_lib_ckpt_checkpointsynchronize),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_checkpointsynchronize));
 
 error_exit:
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);
@@ -1837,8 +1825,7 @@ saCkptCheckpointSynchronizeAsync (
 
 	error = saRecvRetry (ckptCheckpointInstance->response_fd,
 		&res_lib_ckpt_checkpointsynchronizeasync,
-		sizeof (struct res_lib_ckpt_checkpointsynchronizeasync),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_ckpt_checkpointsynchronizeasync));
 
 error_exit:
 	pthread_mutex_unlock (&ckptCheckpointInstance->response_mutex);

+ 2 - 3
lib/clm.c

@@ -257,14 +257,13 @@ saClmDispatch (
 
 		if (ufds.revents & POLLIN) {
 			error = saRecvRetry (clmInstance->dispatch_fd, &dispatch_data.header,
-				sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
+				sizeof (struct res_header));
 			if (error != SA_AIS_OK) {
 				goto error_unlock;
 			}
 			if (dispatch_data.header.size > sizeof (struct res_header)) {
 				error = saRecvRetry (clmInstance->dispatch_fd, &dispatch_data.data,
-					dispatch_data.header.size - sizeof (struct res_header),
-					MSG_WAITALL | MSG_NOSIGNAL);
+					dispatch_data.header.size - sizeof (struct res_header));
 				if (error != SA_AIS_OK) {
 					goto error_unlock;
 				}

+ 2 - 3
lib/evs.c

@@ -259,14 +259,13 @@ evs_error_t evs_dispatch (
 			 * Queue empty, read response from socket
 			 */
 			error = saRecvRetry (evs_inst->dispatch_fd, &dispatch_data.header,
-				sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
+				sizeof (struct res_header));
 			if (error != SA_AIS_OK) {
 				goto error_unlock;
 			}
 			if (dispatch_data.header.size > sizeof (struct res_header)) {
 				error = saRecvRetry (evs_inst->dispatch_fd, &dispatch_data.data,
-					dispatch_data.header.size - sizeof (struct res_header),
-					MSG_WAITALL | MSG_NOSIGNAL);
+					dispatch_data.header.size - sizeof (struct res_header));
 
 				if (error != SA_AIS_OK) {
 					goto error_unlock;

+ 4 - 6
lib/evt.c

@@ -303,7 +303,7 @@ static SaAisErrorT evt_recv_event(int fd, struct lib_event_data **msg)
 	struct res_header hdr;
 	void *data;
 
-	error = saRecvRetry(fd, &hdr, sizeof(hdr), MSG_WAITALL | MSG_NOSIGNAL);
+	error = saRecvRetry(fd, &hdr, sizeof(hdr));
 	if (error != SA_AIS_OK) {
 		goto msg_out;
 	}
@@ -315,8 +315,7 @@ static SaAisErrorT evt_recv_event(int fd, struct lib_event_data **msg)
 	data = (void *)((unsigned long)*msg) + sizeof(hdr);
 	memcpy(*msg, &hdr, sizeof(hdr));
 	if (hdr.size > sizeof(hdr)) {
-		error = saRecvRetry(fd, data, hdr.size - sizeof(hdr),
-				MSG_WAITALL | MSG_NOSIGNAL);
+		error = saRecvRetry(fd, data, hdr.size - sizeof(hdr));
 		if (error != SA_AIS_OK) {
 			goto msg_out;
 		}
@@ -674,15 +673,14 @@ saEvtDispatch(
 
 			if (ufds.revents & POLLIN) {
 				error = saRecvRetry (evti->ei_dispatch_fd, &dispatch_data.header,
-					sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
+					sizeof (struct res_header));
 
 				if (error != SA_AIS_OK) {
 					goto dispatch_unlock;
 				}
 				if (dispatch_data.header.size > sizeof (struct res_header)) {
 					error = saRecvRetry (evti->ei_dispatch_fd, &dispatch_data.data,
-						dispatch_data.header.size - sizeof (struct res_header),
-						MSG_WAITALL | MSG_NOSIGNAL);
+						dispatch_data.header.size - sizeof (struct res_header));
 					if (error != SA_AIS_OK) {
 						goto dispatch_unlock;
 					}

+ 2 - 3
lib/lck.c

@@ -401,14 +401,13 @@ saLckDispatch (
 		}
 		
 		memset(&dispatch_data,0, sizeof(struct message_overlay));
-		error = saRecvRetry (lckInstance->dispatch_fd, &dispatch_data.header, sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
+		error = saRecvRetry (lckInstance->dispatch_fd, &dispatch_data.header, sizeof (struct res_header));
 		if (error != SA_AIS_OK) {
 			goto error_unlock;
 		}
 		if (dispatch_data.header.size > sizeof (struct res_header)) {
 			error = saRecvRetry (lckInstance->dispatch_fd, &dispatch_data.data,
-				dispatch_data.header.size - sizeof (struct res_header),
-				MSG_WAITALL | MSG_NOSIGNAL);
+				dispatch_data.header.size - sizeof (struct res_header));
 			if (error != SA_AIS_OK) {
 				goto error_unlock;
 			}

+ 2 - 3
lib/msg.c

@@ -347,14 +347,13 @@ saMsgDispatch (
 		}
 		
 		memset(&dispatch_data,0, sizeof(struct message_overlay));
-		error = saRecvRetry (msgInstance->dispatch_fd, &dispatch_data.header, sizeof (struct res_header), MSG_WAITALL | MSG_NOSIGNAL);
+		error = saRecvRetry (msgInstance->dispatch_fd, &dispatch_data.header, sizeof (struct res_header));
 		if (error != SA_AIS_OK) {
 			goto error_unlock;
 		}
 		if (dispatch_data.header.size > sizeof (struct res_header)) {
 			error = saRecvRetry (msgInstance->dispatch_fd, &dispatch_data.data,
-				dispatch_data.header.size - sizeof (struct res_header),
-				MSG_WAITALL | MSG_NOSIGNAL);
+				dispatch_data.header.size - sizeof (struct res_header));
 			if (error != SA_AIS_OK) {
 				goto error_unlock;
 			}

+ 7 - 12
lib/util.c

@@ -108,7 +108,7 @@ saServiceConnect (
 		goto error_exit;
 	}
 	error = saRecvRetry (fd, &res_lib_response_init,
-		sizeof (struct res_lib_response_init), MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_response_init));
 	if (error != SA_AIS_OK) {
 		goto error_exit;
 	}
@@ -174,8 +174,7 @@ saServiceConnectTwo (
 		goto error_exit;
 	}
 	error = saRecvRetry (responseFD, &res_lib_response_init,
-		sizeof (struct res_lib_response_init),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_response_init));
 	if (error != SA_AIS_OK) {
 		goto error_exit;
 	}
@@ -213,8 +212,7 @@ saServiceConnectTwo (
 		goto error_exit_two;
 	}
 	error = saRecvRetry (callbackFD, &res_lib_dispatch_init,
-		sizeof (struct res_lib_dispatch_init),
-		MSG_WAITALL | MSG_NOSIGNAL);
+		sizeof (struct res_lib_dispatch_init));
 	if (error != SA_AIS_OK) {
 		goto error_exit_two;
 	}
@@ -241,8 +239,7 @@ SaAisErrorT
 saRecvRetry (
 	int s,
 	void *msg,
-	size_t len,
-	int flags)
+	size_t len)
 {
 	SaAisErrorT error = SA_AIS_OK;
 	int result;
@@ -263,7 +260,7 @@ retry_recv:
 	iov_recv.iov_base = (void *)&rbuf[processed];
 	iov_recv.iov_len = len - processed;
 
-	result = recvmsg (s, &msg_recv, flags);
+	result = recvmsg (s, &msg_recv, MSG_NOSIGNAL);
 	if (result == -1 && errno == EINTR) {
 		goto retry_recv;
 	}
@@ -483,8 +480,7 @@ SaAisErrorT saSendMsgReceiveReply (
 		goto error_exit;
 	}
 	
-	error = saRecvRetry (s, responseMessage, responseLen,
-		MSG_WAITALL | MSG_NOSIGNAL);
+	error = saRecvRetry (s, responseMessage, responseLen);
 	if (error != SA_AIS_OK) {
 		goto error_exit;
 	}
@@ -508,8 +504,7 @@ SaAisErrorT saSendReceiveReply (
 		goto error_exit;
 	}
 	
-	error = saRecvRetry (s, responseMessage, responseLen,
-		MSG_WAITALL | MSG_NOSIGNAL);
+	error = saRecvRetry (s, responseMessage, responseLen);
 	if (error != SA_AIS_OK) {
 		goto error_exit;
 	}

+ 1 - 9
lib/util.h

@@ -78,15 +78,7 @@ SaAisErrorT
 saRecvRetry (
 	int s,
 	void *msg,
-	size_t len,
-	int flags);
-
-SaAisErrorT
-saRecvQueue (
-	int s,
-	void *msg,
-	struct queue *queue,
-	int findMessageId);
+	size_t len);
 
 SaAisErrorT
 saSendRetry (