* [Patch 1/2] tabled: return known to array
@ 2009-08-05 7:32 Pete Zaitcev
2009-08-05 9:02 ` Jeff Garzik
0 siblings, 1 reply; 2+ messages in thread
From: Pete Zaitcev @ 2009-08-05 7:32 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Project Hail List
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 d99513c..2fc6c38 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; /* /tabled-cell directory */
@@ -85,7 +90,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, const char *thiscell)
@@ -236,11 +241,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) {
@@ -606,9 +611,9 @@ int cld_begin(const char *thishost, const char *thiscell,
*/
tmp = host_list;
while (i < N_CLD && tmp) {
- memcpy(&ses.cldv[i], tmp->data,
+ memcpy(&ses.cldv[i].h, tmp->data,
sizeof(struct cldc_host));
-
+ ses.cldv[i].known = 1;
i++;
tmp = tmp->next;
}
@@ -651,7 +656,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);
}
}
@@ -662,7 +667,7 @@ void cld_end(void)
void cldu_add_host(const char *hostname, unsigned int port)
{
static struct cld_session *sp = &ses;
- struct cldc_host *hp;
+ struct cld_host *hp;
int i;
for (i = 0; i < N_CLD; i++) {
@@ -673,7 +678,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, cldu_p_log))
return;
hp->known = 1;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch 1/2] tabled: return known to array
2009-08-05 7:32 [Patch 1/2] tabled: return known to array Pete Zaitcev
@ 2009-08-05 9:02 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2009-08-05 9:02 UTC (permalink / raw)
To: Pete Zaitcev; +Cc: Project Hail List
Pete Zaitcev wrote:
> 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>
applied 1-2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-05 9:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-05 7:32 [Patch 1/2] tabled: return known to array Pete Zaitcev
2009-08-05 9:02 ` Jeff Garzik
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.