diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-07-10 08:06:51 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:59:20 -0500 |
commit | 6504900f1f52927adab3489b8d04b6644ceaee7d (patch) | |
tree | 893cadba231a529f320046429767cedf8b0eec30 /source4/cluster/ctdb/ib/ibwrapper_test.c | |
parent | d4e2d157cbce5a1cdc75efb5ced75d9608a0f7df (diff) | |
download | samba-6504900f1f52927adab3489b8d04b6644ceaee7d.tar.gz samba-6504900f1f52927adab3489b8d04b6644ceaee7d.tar.bz2 samba-6504900f1f52927adab3489b8d04b6644ceaee7d.zip |
r23806: update Samba4 with the latest ctdb code.
This doesn't get the ctdb code fully working in Samba4, it just gets
it building and not breaking non-clustered use of Samba. It will take
a bit longer to update some of the calling ctdb_cluster.c code to make
it work correctly in Samba4.
Note also that Samba4 now only links to the client portion of
ctdb. For the moment I am leaving the ctdbd as a separate daemon,
which you install separately from http://ctdb.samba.org/.
(This used to be commit b196077cbb55cbecad87065133c2d67198e31066)
Diffstat (limited to 'source4/cluster/ctdb/ib/ibwrapper_test.c')
-rw-r--r-- | source4/cluster/ctdb/ib/ibwrapper_test.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/source4/cluster/ctdb/ib/ibwrapper_test.c b/source4/cluster/ctdb/ib/ibwrapper_test.c index 2942d26ed6..07c78e7709 100644 --- a/source4/cluster/ctdb/ib/ibwrapper_test.c +++ b/source4/cluster/ctdb/ib/ibwrapper_test.c @@ -289,7 +289,7 @@ int ibwtest_connstate_handler(struct ibw_ctx *ctx, struct ibw_conn *conn) talloc_free(conn); break; case IBWC_ERROR: - DEBUG(10, ("test IBWC_ERROR\n")); + DEBUG(10, ("test IBWC_ERROR %s\n", ibw_getLastError())); break; default: assert(0); @@ -335,7 +335,7 @@ int ibwtest_receive_handler(struct ibw_conn *conn, void *buf, int n) ibw_stop(tcx->ibwctx); goto error; } - } else { + } else if (op!=TESTOP_SEND_ID) { char *buf2; void *key2; @@ -465,6 +465,19 @@ int ibwtest_parse_attrs(struct ibwtest_ctx *tcx, char *optext, return 0; } +static int ibwtest_get_address(const char *address, struct in_addr *addr) +{ + if (inet_pton(AF_INET, address, addr) <= 0) { + struct hostent *he = gethostbyname(address); + if (he == NULL || he->h_length > sizeof(*addr)) { + DEBUG(0, ("invalid nework address '%s'\n", address)); + return -1; + } + memcpy(addr, he->h_addr, he->h_length); + } + return 0; +} + int ibwtest_getdests(struct ibwtest_ctx *tcx, char op) { int i; @@ -482,7 +495,8 @@ int ibwtest_getdests(struct ibwtest_ctx *tcx, char op) for(i=0; i<tcx->naddrs; i++) { p = tcx->addrs + i; p->sin_family = AF_INET; - p->sin_addr.s_addr = inet_addr(attrs[i].name); + if (ibwtest_get_address(attrs[i].name, &p->sin_addr)) + return -1; p->sin_port = htons(atoi(attrs[i].value)); } @@ -516,13 +530,14 @@ void ibwtest_usage(struct ibwtest_ctx *tcx, char *name) printf("\t%s -i <id> -o {name:value} -d {addr:port} -t nsec -s\n", name); printf("\t-i <id> is a free text, acting as a server id, max 23 chars [mandatory]\n"); printf("\t-o name1:value1,name2:value2,... is a list of (name, value) pairs\n"); - printf("\t-d addr1:port1,addr2:port2,... is a list of destination ip addresses\n"); + printf("\t-a addr1:port1,addr2:port2,... is a list of destination ip addresses\n"); printf("\t-t nsec delta time between sends in nanosec [default %d]\n", tcx->nsec); printf("\t\t send message periodically and endless when nsec is non-zero\n"); printf("\t-s server mode (you have to give exactly one -d address:port in this case)\n"); printf("\t-n number of messages to send [default %d]\n", tcx->nmsg); printf("\t-l usec time to sleep in the main loop [default %d]\n", tcx->sleep_usec); printf("\t-v max variable msg size in bytes [default %d], 0=don't send var. size\n", tcx->maxsize); + printf("\t-d LogLevel [default %d]\n", LogLevel); printf("Press ctrl+C to stop the program.\n"); } @@ -538,13 +553,14 @@ int main(int argc, char *argv[]) memset(tcx, 0, sizeof(struct ibwtest_ctx)); tcx->nsec = 0; tcx->nmsg = 1000; + LogLevel = 0; /* here is the only case we can't avoid using global... */ testctx = tcx; signal(SIGINT, ibwtest_sigint_handler); srand((unsigned)time(NULL)); - while ((op=getopt(argc, argv, "i:o:d:m:st:n:l:v:")) != -1) { + while ((op=getopt(argc, argv, "i:o:d:m:st:n:l:v:a:")) != -1) { switch (op) { case 'i': tcx->id = talloc_strdup(tcx, optarg); @@ -555,7 +571,7 @@ int main(int argc, char *argv[]) &tcx->nattrs, op)) goto cleanup; break; - case 'd': + case 'a': if (ibwtest_getdests(tcx, op)) goto cleanup; break; @@ -574,6 +590,9 @@ int main(int argc, char *argv[]) case 'v': tcx->maxsize = (unsigned int)atoi(optarg); break; + case 'd': + LogLevel = atoi(optarg); + break; default: fprintf(stderr, "ERROR: unknown option -%c\n", (char)op); ibwtest_usage(tcx, argv[0]); |