[tabled patch 3/5] cleanup a call to closelog()

2010-08-12 Thread Pete Zaitcev
Since we're on it, only call closelog() if openlog() was called.
There is no crash if we do that, but still it's not very correct.

Signed-off-by: Pete Zaitcev zait...@redhat.com

---
 server/server.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

commit ae8ac067adde81a34c9d6114cfbaa1f95c9b48da
Author: Pete Zaitcev zait...@yahoo.com
Date:   Thu Aug 12 12:33:39 2010 -0600

Syslog cleanup.

diff --git a/server/server.c b/server/server.c
index 829d2db..7a9fb7a 100644
--- a/server/server.c
+++ b/server/server.c
@@ -2344,7 +2344,8 @@ err_evpipe:
unlink(tabled_srv.pid_file);
close(tabled_srv.pid_fd);
 err_out:
-   closelog();
+   if (use_syslog)
+   closelog();
return rc;
 }
 
--
To unsubscribe from this list: send the line unsubscribe hail-devel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[tabled patch 4/5] Support auto replicaton port

2010-08-12 Thread Pete Zaitcev
Allow random ports for replication master to listen on.

The patch is somewhat larger than expected, because before we had
the MASTER file written right after locking. Now we may have it
written without listening parameters, and the slaves must be
ready to deal with it.

Unlike the auto client port, we do not need to write any accessor
files, because we already report the host and port through CLD.

Listening on random ports has security implications.

Signed-off-by: Pete Zaitcev zait...@redhat.com

---
 doc/etc.tabled.conf   |   16 ++-
 server/cldu.c |  166 ++--
 server/config.c   |   22 +++--
 server/metarep.c  |   34 
 server/tabled.h   |1 
 test/tabled-test.conf |2 
 6 files changed, 173 insertions(+), 68 deletions(-)

commit 7ca8a587348e315ab7c6c9e32476d8fa387718d5
Author: Pete Zaitcev zait...@yahoo.com
Date:   Thu Aug 12 12:37:27 2010 -0600

TDBRepPort auto.

diff --git a/doc/etc.tabled.conf b/doc/etc.tabled.conf
index c3b1d1d..5112e8a 100644
--- a/doc/etc.tabled.conf
+++ b/doc/etc.tabled.conf
@@ -12,14 +12,22 @@
 /Listen
 
 !--
-  One group per DB, don't skimp on groups. Also, make sure the replication
-  ports do not conflict when you make boxes to host several groups or use
-  replication instances iwth TDBRepName.
+  One group per DB, don't skimp on groups.
   --
 Groupultracart2/Group
+
 TDB/path/tabled-uc2//TDB!-- mkdir -p /path/tabled-uc2 --
-!-- TDBRepName12345.my_local_node_name.example.com/TDBRepName --
+
+!--
+  The usual practice is to set a fixed TDBRepPort (8083) because this
+  permits to configure a firewall easily. Remember that replication
+  has no authentication and authorization whatsoever for now!
+  When running two test instances on the same host, you may use auto.
+  But if so, do not forget to set replication instances with TDBRepName.
+  By default, a hostname serves fine as an instance name, port is auto.
+  --
 TDBRepPort8083/TDBRepPort
+!-- TDBRepNameinst-b.my_local_node_name.example.com/TDBRepName --
 
 !--
   The clause CLD is not to be used in production configurations.
diff --git a/server/cldu.c b/server/cldu.c
index 45a6a83..57d486e 100644
--- a/server/cldu.c
+++ b/server/cldu.c
@@ -67,7 +67,6 @@ struct cld_session {
 
char *thisname;
char *thisgroup;
-   char *thishost;
char *cfname;   /* /tabled-group directory */
struct ncld_fh *cfh;/* /tabled-group directory, keep open for scan 
*/
char *ffname;   /* /tabled-group/thisname */
@@ -119,24 +118,17 @@ static int cldu_nextactive(struct cld_session *sp)
  * chunkservers that it uses, so this function only takes one group argument.
  */
 static int cldu_setgroup(struct cld_session *sp,
-const char *thisgroup, const char *thishost,
-const char *thisname)
+const char *thisgroup, const char *thisname)
 {
char *mem;
 
if (thisgroup == NULL) {
thisgroup = default;
}
-   if (thisname == NULL) {
-   thisname = thishost;
-   }
 
sp-thisgroup = strdup(thisgroup);
if (!sp-thisgroup)
goto err_oom;
-   sp-thishost = strdup(thishost);
-   if (!sp-thishost)
-   goto err_oom;
sp-thisname = strdup(thisname);
if (!sp-thisname)
goto err_oom;
@@ -256,59 +248,82 @@ static void cldu_parse_master(const char *mfname, const 
char *mfile, long len)
applog(LOG_DEBUG, %s: No name, mfname);
return;
}
+   if (namelen = sizeof(namebuf)) {
+   applog(LOG_ERR, Long master name);
+   return;
+   }
+   memcpy(namebuf, name, namelen);
+   namebuf[namelen] = 0;
+
if (!host || !hostlen) {
if (debugging)
applog(LOG_DEBUG, %s: No host, mfname);
-   return;
+   hostlen = 0;
}
if (!port || !portlen) {
if (debugging)
applog(LOG_DEBUG, %s: No port, mfname);
-   return;
+   portlen = 0;
}
 
-   if (namelen = sizeof(namebuf)) {
-   applog(LOG_ERR, Long master name);
-   return;
-   }
-   memcpy(namebuf, name, namelen);
-   namebuf[namelen] = 0;
+   if (hostlen != 0  portlen != 0) {
 
-   if (hostlen = sizeof(hostbuf)) {
-   applog(LOG_ERR, Long host);
-   return;
-   }
-   memcpy(hostbuf, host, hostlen);
-   hostbuf[hostlen] = 0;
+   if (hostlen = sizeof(hostbuf)) {
+   applog(LOG_ERR, Long host);
+   return;
+   }
+   memcpy(hostbuf, host, hostlen);
+   hostbuf[hostlen] = 0;
 
-   if (portlen = sizeof(portbuf)) {
-   applog(LOG_ERR, Long port);
-   return;
-