Просмотр исходного кода

defect 1116
The IPC code spins in recvmsg in the library resulting in poor performance
and deadlock in the AMF service.




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

Steven Dake 20 лет назад
Родитель
Сommit
9a0d93ade8
3 измененных файлов с 10 добавлено и 92 удалено
  1. 1 1
      exec/main.c
  2. 2 91
      lib/util.c
  3. 7 0
      test/evsbench.c

+ 1 - 1
exec/main.c

@@ -749,7 +749,7 @@ static int poll_handler_libais_deliver (poll_handle handle, int fd, int revent,
 	assert (iov_recv.iov_len != 0);
 
 retry_recv:
-	res = recvmsg (fd, &msg_recv, MSG_NOSIGNAL | MSG_DONTWAIT);
+	res = recvmsg (fd, &msg_recv, MSG_NOSIGNAL);
 	if (res == -1 && errno == EINTR) {
 		goto retry_recv;
 	} else

+ 2 - 91
lib/util.c

@@ -1,7 +1,7 @@
 /*
  * vi: set autoindent tabstop=4 shiftwidth=4 :
  *
- * Copyright (c) 2002-2004 MontaVista Software, Inc.
+ * Copyright (c) 2002-2006 MontaVista Software, Inc.
  *
  * All rights reserved.
  *
@@ -89,82 +89,6 @@ void socket_nosigpipe(int s)
 }
 #endif 
 
-SaAisErrorT
-saServiceConnect (
-	int *fdOut,
-	enum service_types service)
-{
-	int fd;
-	int result;
-	struct sockaddr_un address;
-	struct req_lib_response_init req_lib_response_init;
-	struct res_lib_response_init res_lib_response_init;
-	SaAisErrorT error;
-	gid_t egid;
-
-	/*
-	 * Allow set group id binaries to be authenticated
-	 */
-	egid = getegid();
-	setregid (egid, -1);
-
-	memset (&address, 0, sizeof (struct sockaddr_un));
-#if defined(OPENAIS_BSD) || defined(OPENAIS_DARWIN)
-	address.sun_len = sizeof(struct sockaddr_un);
-#endif
-	address.sun_family = PF_UNIX;
-#if defined(OPENAIS_LINUX)
-	strcpy (address.sun_path + 1, socketname);
-#else
-	strcpy (address.sun_path, socketname);
-#endif
-	fd = socket (PF_UNIX, SOCK_STREAM, 0);
-	if (fd == -1) {
-		return (SA_AIS_ERR_NO_RESOURCES);
-	}
-
-	socket_nosigpipe (fd);
-
-	result = connect (fd, (struct sockaddr *)&address, AIS_SUN_LEN(&address));
-	if (result == -1) {
-		return (SA_AIS_ERR_TRY_AGAIN);
-	}
-
-	result = fcntl (fd, F_SETFL, O_NONBLOCK);
-	if (result == -1) {
-		return (SA_AIS_ERR_TRY_AGAIN);
-	}
-
-	req_lib_response_init.resdis_header.size = sizeof (req_lib_response_init);
-	req_lib_response_init.resdis_header.id = MESSAGE_REQ_RESPONSE_INIT;
-	req_lib_response_init.resdis_header.service = service;
-
-	error = saSendRetry (fd, &req_lib_response_init,
-		sizeof (struct req_lib_response_init));
-	if (error != SA_AIS_OK) {
-		goto error_exit;
-	}
-	error = saRecvRetry (fd, &res_lib_response_init,
-		sizeof (struct res_lib_response_init));
-	if (error != SA_AIS_OK) {
-		goto error_exit;
-	}
-
-	/*
-	 * Check for security errors
-	 */
-	if (res_lib_response_init.header.error != SA_AIS_OK) {
-		error = res_lib_response_init.header.error;
-		goto error_exit;
-	}
-
-	*fdOut = fd;
-	return (SA_AIS_OK);
-error_exit:
-	close (fd);
-	return (error);
-}
-
 SaAisErrorT
 saServiceConnectTwo (
 	int *responseOut,
@@ -211,12 +135,6 @@ saServiceConnectTwo (
 		return (SA_AIS_ERR_TRY_AGAIN);
 	}
 
-	result = fcntl (responseFD, F_SETFL, O_NONBLOCK);
-	if (result == -1) {
-		close (responseFD);
-		return (SA_AIS_ERR_TRY_AGAIN);
-	}
-
 	req_lib_response_init.resdis_header.size = sizeof (req_lib_response_init);
 	req_lib_response_init.resdis_header.id = MESSAGE_REQ_RESPONSE_INIT;
 	req_lib_response_init.resdis_header.service = service;
@@ -257,13 +175,6 @@ saServiceConnectTwo (
 		return (SA_AIS_ERR_TRY_AGAIN);
 	}
 
-	result = fcntl (callbackFD, F_SETFL, O_NONBLOCK);
-	if (result == -1) {
-		close (callbackFD);
-		close (responseFD);
-		return (SA_AIS_ERR_TRY_AGAIN);
-	}
-
 	req_lib_dispatch_init.resdis_header.size = sizeof (req_lib_dispatch_init);
 	req_lib_dispatch_init.resdis_header.id = MESSAGE_REQ_DISPATCH_INIT;
 	req_lib_dispatch_init.resdis_header.service = service;
@@ -324,7 +235,7 @@ retry_recv:
 	iov_recv.iov_base = (void *)&rbuf[processed];
 	iov_recv.iov_len = len - processed;
 
-	result = recvmsg (s, &msg_recv, MSG_NOSIGNAL | MSG_DONTWAIT);
+	result = recvmsg (s, &msg_recv, MSG_NOSIGNAL);
 	if (result == -1 && errno == EINTR) {
 		goto retry_recv;
 	}

+ 7 - 0
test/evsbench.c

@@ -158,6 +158,11 @@ void sigalrm_handler (int num)
 	alarm_notice = 1;
 }
 
+void sigintr_handler (int num)
+{
+	exit (1);
+}
+
 int main (void) {
 	int size;
 	int i;
@@ -165,6 +170,8 @@ int main (void) {
 	evs_handle_t handle;
 
 	signal (SIGALRM, sigalrm_handler);
+	signal (SIGINT, sigintr_handler);
+
 
 	result = evs_initialize (&handle, &callbacks);
 	printf ("Init result %d\n", result);