* [Patch 1/3] cldcli: Add default CLD host
@ 2009-08-04 1:54 Pete Zaitcev
2009-08-04 2:08 ` Jeff Garzik
0 siblings, 1 reply; 2+ messages in thread
From: Pete Zaitcev @ 2009-08-04 1:54 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Project Hail
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;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch 1/3] cldcli: Add default CLD host
2009-08-04 1:54 [Patch 1/3] cldcli: Add default CLD host Pete Zaitcev
@ 2009-08-04 2:08 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2009-08-04 2:08 UTC (permalink / raw)
To: Pete Zaitcev; +Cc: Project Hail
Pete Zaitcev wrote:
> It's convenient to run cldcli without arguments if your DNS is set up.
>
> Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
applied
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-04 2:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-04 1:54 [Patch 1/3] cldcli: Add default CLD host Pete Zaitcev
2009-08-04 2:08 ` 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.