Skip to contentSkip to conversation

chunkd: switch to ncld

PATCH In review Pete Zaitcev 2 participants 2 messages Mar 31, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 chunkd: switch to ncld

This patch makes chunkd to use ncld_foo interface, so procedural programming is now possible. Also, the code is shorter.

---
 server/chunkd.h |    1 
 server/cldu.c   |  656 ++++++++++++++++------------------------------
 server/server.c |   18 -
 3 files changed, 253 insertions(+), 422 deletions(-)
server/chunkd.h +1 -0
index cd83f7b..dd86cee 100644
@@ -289,6 +289,7 @@ extern void cli_out_end(struct client *cli);
 extern void cli_in_end(struct client *cli);
 
 /* cldu.c */
+extern void cld_init(void);
 extern void cldu_add_host(const char *host, unsigned int port);
 extern int cld_begin(const char *thishost, const char *thisgroup, uint32_t nid,
 		     struct geo *locp, void (*cb)(enum st_cld));
server/cldu.c +242 -414

816 lines not on this page · raw message

server/server.c +10 -8
index 5b34725..b2a30bc 100644
@@ -1756,6 +1756,8 @@ int main (int argc, char *argv[])
 	SSL_CTX_set_mode(ssl_ctx, SSL_CTX_get_mode(ssl_ctx) |
 			 SSL_MODE_ENABLE_PARTIAL_WRITE);
 
+	cld_init();
+
 	/*
 	 * Next, read master configuration. This should be done as
 	 * early as possible, so that tunables are available.
@@ -1817,12 +1819,6 @@ int main (int argc, char *argv[])
 		goto err_out_fs;
 	}
 
-	if (cld_begin(chunkd_srv.ourhost, chunkd_srv.group, chunkd_srv.nid,
-		      &chunkd_srv.loc, NULL)) {
-		rc = 1;
-		goto err_out_cld;
-	}
-
 	/* set up server networking */
 	for (tmpl = chunkd_srv.listeners; tmpl; tmpl = tmpl->next) {
 		rc = net_open(tmpl->data);
@@ -1830,16 +1826,22 @@ int main (int argc, char *argv[])
 			goto err_out_listen;
 	}
 
+	if (cld_begin(chunkd_srv.ourhost, chunkd_srv.group, chunkd_srv.nid,
+		      &chunkd_srv.loc, NULL)) {
+		rc = 1;
+		goto err_out_cld;
+	}
+
 	applog(LOG_INFO, "initialized");
 
 	rc = main_loop();
 
 	applog(LOG_INFO, "shutting down");
 
+	/* cld_end(); */
+err_out_cld:
 	/* net_close(); */
 err_out_listen:
-	cld_end();
-err_out_cld:
 	fs_close();
 err_out_fs:
 	cmd = CHK_CMD_EXIT;
#1 lore raw
Quoted 10 lines · Pete Zaitcev

This patch makes chunkd to use ncld_foo interface, so procedural programming is now possible. Also, the code is shorter.

---
  server/chunkd.h |    1
  server/cldu.c   |  656 ++++++++++++++++------------------------------
  server/server.c |   18 -
  3 files changed, 253 insertions(+), 422 deletions(-)

applied 1-3