summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2009-09-15 04:45:08 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-16 07:11:30 -0700
commit5480b6eca96a8da4b159783a19f2ed5c2f640769 (patch)
tree865c1d26cc8561ab3be938ef11bfabe0ac137117 /xlators/protocol/client/src
parentb542a8e5323fad46ce4e5f8921c906a58cff91d2 (diff)
protocol/client: Support for dumpop priv.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 213 (Support for process state dump) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=213
Diffstat (limited to 'xlators/protocol/client/src')
-rw-r--r--xlators/protocol/client/src/client-protocol.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/xlators/protocol/client/src/client-protocol.c b/xlators/protocol/client/src/client-protocol.c
index af5a0bb15f2..bd6854caa6d 100644
--- a/xlators/protocol/client/src/client-protocol.c
+++ b/xlators/protocol/client/src/client-protocol.c
@@ -36,6 +36,7 @@
#include "defaults.h"
#include "compat.h"
#include "compat-errno.h"
+#include "statedump.h"
#include <sys/resource.h>
#include <inttypes.h>
@@ -6089,6 +6090,57 @@ protocol_client_pollin (xlator_t *this, transport_t *trans)
return ret;
}
+int
+client_priv_dump (xlator_t *this)
+{
+ client_conf_t *conf = NULL;
+ int ret = -1;
+ client_fd_ctx_t *tmp = NULL;
+ int i = 0;
+ char key[GF_DUMP_MAX_BUF_LEN];
+ char key_prefix[GF_DUMP_MAX_BUF_LEN];
+
+ if (!this)
+ return -1;
+
+ conf = this->private;
+ if (!conf) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "conf null in xlator");
+ return -1;
+ }
+
+ ret = pthread_mutex_trylock(&conf->mutex);
+ if (ret) {
+ gf_log("", GF_LOG_WARNING, "Unable to lock client %s"
+ " errno: %d", this->name, errno);
+ return -1;
+ }
+
+ gf_proc_dump_build_key(key_prefix, "xlator.protocol.client",
+ "%s.priv", this->name);
+
+ gf_proc_dump_add_section(key_prefix);
+
+ list_for_each_entry(tmp, &conf->saved_fds, sfd_pos) {
+ gf_proc_dump_build_key(key, key_prefix,
+ "fd.%d.remote_fd", ++i);
+ gf_proc_dump_write(key, "%d", tmp->remote_fd);
+ }
+
+ gf_proc_dump_build_key(key, key_prefix, "connecting");
+ gf_proc_dump_write(key, "%d", conf->connecting);
+ gf_proc_dump_build_key(key, key_prefix, "last_sent");
+ gf_proc_dump_write(key, "%s", ctime(&conf->last_sent.tv_sec));
+ gf_proc_dump_build_key(key, key_prefix, "last_received");
+ gf_proc_dump_write(key, "%s", ctime(&conf->last_received.tv_sec));
+
+ pthread_mutex_unlock(&conf->mutex);
+
+ return 0;
+
+}
+
/*
* client_protocol_notify - notify function for client protocol
@@ -6304,6 +6356,10 @@ struct xlator_cbks cbks = {
};
+struct xlator_dumpops dumpops = {
+ .priv = client_priv_dump,
+};
+
struct volume_options options[] = {
{ .key = {"username"},
.type = GF_OPTION_TYPE_ANY