From: mornfall@sourceware.org <mornfall@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/daemons common/daemon-client.c common/dae ...
Date: 27 Jun 2011 13:46:47 -0000 [thread overview]
Message-ID: <20110627134647.21121.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall at sourceware.org 2011-06-27 13:46:45
Modified files:
daemons/common : daemon-client.c daemon-server.c daemon-server.h
daemons/lvmetad: lvmetad-core.c testclient.c
Log message:
Parse the incoming config tree in daemon-server.c, providing the
daemon-specific handler with a struct config_tree pointer to look things up in.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-client.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/common/daemon-server.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/lvmetad-core.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/testclient.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4
--- LVM2/daemons/common/daemon-client.c 2011/06/27 13:14:53 1.2
+++ LVM2/daemons/common/daemon-client.c 2011/06/27 13:46:45 1.3
@@ -15,7 +15,7 @@
goto error;
}
memset(&sockaddr, 0, sizeof(sockaddr));
- fprintf(stderr, "connecting to %s\n", i.socket);
+ fprintf(stderr, "[C] connecting to %s\n", i.socket);
strcpy(sockaddr.sun_path, i.socket);
sockaddr.sun_family = AF_UNIX;
if (connect(h.socket_fd,(struct sockaddr *) &sockaddr, sizeof(sockaddr))) {
--- LVM2/daemons/common/daemon-server.c 2011/06/14 02:34:18 1.4
+++ LVM2/daemons/common/daemon-server.c 2011/06/27 13:46:45 1.5
@@ -107,7 +107,7 @@
fprintf(stderr, "setting CLOEXEC on socket fd %d failed: %s\n", fd, strerror(errno));
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
- fprintf(stderr, "creating %s\n", s.socket_path);
+ fprintf(stderr, "[D] creating %s\n", s.socket_path);
memset(&sockaddr, 0, sizeof(sockaddr));
strcpy(sockaddr.sun_path, s.socket_path);
sockaddr.sun_family = AF_UNIX;
@@ -213,8 +213,10 @@
if (!read_buffer(b->client.socket_fd, &req.buffer))
goto fail;
- /* TODO parse the buffer into req.cft */
+ req.cft = create_config_tree_from_string(req.buffer);
response res = b->s.handler(b->s, b->client, req);
+ destroy_config_tree(req.cft);
+ dm_free(req.buffer);
if (!res.buffer) {
/* TODO fill in the buffer from res.cft */
@@ -223,7 +225,6 @@
write_buffer(b->client.socket_fd, res.buffer, strlen(res.buffer));
free(res.buffer);
- free(req.buffer);
}
fail:
/* TODO what should we really do here? */
--- LVM2/daemons/common/daemon-server.h 2011/06/14 02:34:18 1.5
+++ LVM2/daemons/common/daemon-server.h 2011/06/27 13:46:45 1.6
@@ -26,13 +26,13 @@
} client_handle;
typedef struct {
- struct config_node *cft;
+ struct config_tree *cft;
char *buffer;
} request;
typedef struct {
int error;
- struct config_node *cft;
+ struct config_tree *cft;
char *buffer;
} response;
--- LVM2/daemons/lvmetad/lvmetad-core.c 2011/06/27 13:15:49 1.2
+++ LVM2/daemons/lvmetad/lvmetad-core.c 2011/06/27 13:46:45 1.3
@@ -7,7 +7,7 @@
static response handler(daemon_state s, client_handle h, request r)
{
response res;
- fprintf(stderr, "---- server obtained:\n%s\n----------------------\n", r.buffer);
+ fprintf(stderr, "[D] REQUEST: %s\n", find_config_str(r.cft->root, "request", "NONE"));
res.error = 1;
res.buffer = strdup("hey hey.\n\n");
return res;
--- LVM2/daemons/lvmetad/testclient.c 2011/06/27 13:15:49 1.3
+++ LVM2/daemons/lvmetad/testclient.c 2011/06/27 13:46:45 1.4
@@ -5,7 +5,7 @@
int i;
for (i = 0; i < 5; ++i ) {
daemon_reply reply = daemon_send_simple(h, "hello world", "param = %d", 3, NULL);
- fprintf(stderr, "daemon says: %s\n", reply.buffer);
+ fprintf(stderr, "[C] obtained: %s\n", reply.buffer);
}
daemon_close(h);
return 0;
next reply other threads:[~2011-06-27 13:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-27 13:46 mornfall [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-06-27 13:58 LVM2/daemons common/daemon-client.c common/dae mornfall
2012-02-23 23:52 mornfall
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=20110627134647.21121.qmail@sourceware.org \
--to=mornfall@sourceware.org \
--cc=lvm-devel@redhat.com \
/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.