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

totemudpu: Handle fd leak in totemudpu

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Jan Friesse 12 лет назад
Родитель
Сommit
93286a344e
1 измененных файлов с 8 добавлено и 2 удалено
  1. 8 2
      exec/totemudpu.c

+ 8 - 2
exec/totemudpu.c

@@ -1034,7 +1034,7 @@ static int totemudpu_create_sending_socket(
 	if (res == -1) {
 	if (res == -1) {
 		LOGSYS_PERROR (errno, instance->totemudpu_log_level_warning,
 		LOGSYS_PERROR (errno, instance->totemudpu_log_level_warning,
 			"Could not set non-blocking operation on token socket");
 			"Could not set non-blocking operation on token socket");
-		return (-1);
+		goto error_close_fd;
 	}
 	}
 
 
 	/*
 	/*
@@ -1047,6 +1047,9 @@ static int totemudpu_create_sending_socket(
 	if (res == -1) {
 	if (res == -1) {
 		LOGSYS_PERROR (errno, instance->totemudpu_log_level_notice,
 		LOGSYS_PERROR (errno, instance->totemudpu_log_level_notice,
 			"Could not set sendbuf size");
 			"Could not set sendbuf size");
+		/*
+		 * Fail in setting sendbuf size is not fatal -> don't exit
+		 */
 	}
 	}
 
 
 	/*
 	/*
@@ -1057,11 +1060,14 @@ static int totemudpu_create_sending_socket(
 	if (res == -1) {
 	if (res == -1) {
 		LOGSYS_PERROR (errno, instance->totemudpu_log_level_warning,
 		LOGSYS_PERROR (errno, instance->totemudpu_log_level_warning,
 			"bind token socket failed");
 			"bind token socket failed");
-		return (-1);
+		goto error_close_fd;
 	}
 	}
 
 
 	return (fd);
 	return (fd);
 
 
+error_close_fd:
+	close(fd);
+	return (-1);
 }
 }
 
 
 int totemudpu_member_add (
 int totemudpu_member_add (