mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Teigland <teigland@redhat.com>
To: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: [patch 2/9] dlm: don't add duplicate node addresses
Date: Thu, 2 Jun 2005 16:02:30 +0800	[thread overview]
Message-ID: <20050602080230.GB21570@redhat.com> (raw)

[-- Attachment #1: no-duplicate-addrs.patch --]
[-- Type: text/plain, Size: 895 bytes --]

If an address has already been set for a node, don't add it again.

Signed-off-by: David Teigland <teigland@redhat.com>

Index: linux/drivers/dlm/lowcomms.c
===================================================================
--- linux.orig/drivers/dlm/lowcomms.c	2005-06-02 12:28:30.000000000 +0800
+++ linux/drivers/dlm/lowcomms.c	2005-06-02 12:52:51.391577056 +0800
@@ -272,6 +272,7 @@
 int dlm_set_local(int nodeid, int weight, char *addr_buf)
 {
 	struct sockaddr_storage *addr;
+	int i;
 
 	if (local_count > DLM_MAX_ADDR_COUNT - 1) {
 		log_print("too many local addresses set %d", local_count);
@@ -284,7 +285,15 @@
 	if (!addr)
 		return -ENOMEM;
 	memcpy(addr, addr_buf, sizeof(*addr));
+
+	for (i = 0; i < local_count; i++) {
+		if (!memcmp(local_addr[i], addr, sizeof(*addr))) {
+			kfree(addr);
+			goto out;
+		}
+	}
 	local_addr[local_count++] = addr;
+ out:
 	return 0;
 }
 

--


                 reply	other threads:[~2005-06-02  7:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050602080230.GB21570@redhat.com \
    --to=teigland@redhat.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®