All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [Patch 1/2] chunkd: return known to array
Date: Wed, 5 Aug 2009 01:31:19 -0600	[thread overview]
Message-ID: <20090805013119.71e417d2@redhat.com> (raw)

The .known is the array management item which has no business in
a list-managed struct. Phase 1: return it where it was. In phase 2
we will drop it from cldc_host. Then perhaps change array to a
circular list.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>

diff --git a/server/cldu.c b/server/cldu.c
index 1e11e6c..34dd996 100644
--- a/server/cldu.c
+++ b/server/cldu.c
@@ -22,13 +22,18 @@
 
 #define N_CLD		10	/* 5 * (v4+v6) */
 
+struct cld_host {
+	int known;
+	struct cldc_host h;
+};
+
 struct cld_session {
 	bool forced_hosts;		/* Administrator overrode default CLD */
 	bool sess_open;
 	struct cldc_udp *lib;		/* library state */
 
 	int actx;		/* Active host cldv[actx] */
-	struct cldc_host cldv[N_CLD];
+	struct cld_host cldv[N_CLD];
 
 	struct event ev;	/* Associated with fd */
 	char *cfname;		/* /chunk-CELL directory */
@@ -71,7 +76,7 @@ static int cldu_nextactive(struct cld_session *sp)
 			n = 0;
 	}
 	/* Full circle, end on the old actx */
-	return n;
+	return sp->actx;
 }
 
 static int cldu_setcell(struct cld_session *sp,
@@ -217,11 +222,11 @@ static int cldu_set_cldc(struct cld_session *sp, int newactive)
 	}
 
 	sp->actx = newactive;
-	hp = &sp->cldv[sp->actx];
-	if (!hp->known) {
+	if (!sp->cldv[sp->actx].known) {
 		applog(LOG_ERR, "No CLD hosts");
 		goto err_addr;
 	}
+	hp = &sp->cldv[sp->actx].h;
 
 	rc = cldc_udp_new(hp->host, hp->port, &sp->lib);
 	if (rc) {
@@ -530,8 +535,9 @@ int cld_begin(const char *thishost, const char *thiscell, uint32_t nid,
 		i = 0;
 		for (tmp = host_list; tmp; tmp = tmp->next) {
 			if (i < N_CLD) {
-				memcpy(&ses.cldv[i], tmp->data,
+				memcpy(&ses.cldv[i].h, tmp->data,
 				       sizeof(struct cldc_host));
+				ses.cldv[i].known = 1;
 				i++;
 			} else {
 				struct cldc_host *hp = tmp->data;
@@ -577,7 +583,7 @@ void cld_end(void)
 	if (!ses.forced_hosts) {
 		for (i = 0; i < N_CLD; i++) {
 			if (ses.cldv[i].known)
-				free(ses.cldv[i].host);
+				free(ses.cldv[i].h.host);
 		}
 	}
 
@@ -589,7 +595,7 @@ void cldu_add_host(const char *hostname, unsigned int port,
 		   void log(const char *fmt, ...))
 {
 	static struct cld_session *sp = &ses;
-	struct cldc_host *hp;
+	struct cld_host *hp;
 	int i;
 
 	for (i = 0; i < N_CLD; i++) {
@@ -600,7 +606,7 @@ void cldu_add_host(const char *hostname, unsigned int port,
 	if (i >= N_CLD)
 		return;
 
-	if (cldc_saveaddr(hp, 100, 100, port, strlen(hostname), hostname,
+	if (cldc_saveaddr(&hp->h, 100, 100, port, strlen(hostname), hostname,
 			  debugging, log))
 		return;
 	hp->known = 1;

             reply	other threads:[~2009-08-05  7:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-05  7:31 Pete Zaitcev [this message]
2009-08-05  8:59 ` [Patch 1/2] chunkd: return known to array Jeff Garzik

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=20090805013119.71e417d2@redhat.com \
    --to=zaitcev@redhat.com \
    --cc=hail-devel@vger.kernel.org \
    --cc=jeff@garzik.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.