From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail <hail-devel@vger.kernel.org>
Subject: [Patch 1/3] cldcli: Add default CLD host
Date: Mon, 3 Aug 2009 19:54:19 -0600 [thread overview]
Message-ID: <20090803195419.1f2901d9@redhat.com> (raw)
It's convenient to run cldcli without arguments if your DNS is set up.
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
diff --git a/tools/cldcli.c b/tools/cldcli.c
index ad7a75e..bb5c4cc 100644
--- a/tools/cldcli.c
+++ b/tools/cldcli.c
@@ -42,11 +42,6 @@ static struct argp_option options[] = {
static const char doc[] =
"cldcli - command line interface to coarse locking service";
-struct db_remote {
- char *host;
- unsigned short port;
-};
-
enum creq_cmd {
CREQ_CD,
CREQ_CAT,
@@ -118,6 +113,15 @@ static void errc_msg(struct cresp *cresp, enum cle_err_codes errc)
strcpy(cresp->msg, names_cle_err[errc]);
}
+static void app_log(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
static void do_write(int fd, const void *buf, size_t buflen, const char *msg)
{
ssize_t rc;
@@ -461,7 +465,7 @@ static struct cldc_ops cld_ops = {
static gpointer cld_thread(gpointer dummy)
{
- struct db_remote *dr;
+ struct cldc_host *dr;
struct cldc_call_opts copts = { .cb = cb_new_sess };
char tcode = TC_FAILED;
struct pollfd pfd[2];
@@ -741,11 +745,13 @@ static bool push_host(const char *arg)
{
char *colon;
unsigned int port;
- struct db_remote *dr;
+ struct cldc_host *dr;
dr = malloc(sizeof(*dr));
if (!dr)
return false;
+ memset(dr, 0, sizeof(*dr));
+
dr->host = strdup(arg);
if (!dr->host)
goto err_out;
@@ -840,6 +846,22 @@ int main (int argc, char *argv[])
return 1;
}
+ if (!host_list) {
+ enum { hostsz = 64 };
+ char hostb[hostsz];
+
+ if (gethostname(hostb, hostsz-1) < 0) {
+ fprintf(stderr, "gethostname error: %s\n",
+ strerror(errno));
+ return 1;
+ }
+ hostb[hostsz-1] = 0;
+ if (cldc_getaddr(&host_list, hostb, debugging, app_log)) {
+ fprintf(stderr, "Unable to find a CLD host\n");
+ return 1;
+ }
+ }
+
if ((pipe(from_thread) < 0) || (pipe(to_thread) < 0)) {
perror("pipe");
return 1;
next reply other threads:[~2009-08-04 1:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-04 1:54 Pete Zaitcev [this message]
2009-08-04 2:08 ` [Patch 1/3] cldcli: Add default CLD host 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=20090803195419.1f2901d9@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.