summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src/server.c
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2013-08-21 14:11:38 -0400
committerAnand Avati <avati@redhat.com>2013-10-31 09:32:50 -0700
commit3108d4529d57690f58027da61ac5e56a0987ed57 (patch)
treeed2eb16d54fdc4dcbdfe15eb2bff90597658339a /xlators/protocol/server/src/server.c
parentc47408e896c9bcaf21e7f8956bdae85633f873e0 (diff)
client_t: phase 2, refactor server_ctx and locks_ctx out
remove server_ctx and locks_ctx from client_ctx directly and store as into discrete entities in the scratch_ctx hooking up dump will be in phase 3 BUG: 849630 Change-Id: I94cea328326db236cdfdf306cb381e4d58f58d4c Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: http://review.gluster.org/5678 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/protocol/server/src/server.c')
-rw-r--r--xlators/protocol/server/src/server.c73
1 files changed, 55 insertions, 18 deletions
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 7e6e2c091..65ea0bb55 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -25,8 +25,6 @@
#include "statedump.h"
#include "defaults.h"
#include "authenticate.h"
-#include "rpcsvc.h"
-#include "client_t.h"
void
grace_time_handler (void *data)
@@ -34,6 +32,7 @@ grace_time_handler (void *data)
client_t *client = NULL;
xlator_t *this = NULL;
gf_timer_t *timer = NULL;
+ server_ctx_t *serv_ctx = NULL;
gf_boolean_t cancelled = _gf_false;
gf_boolean_t detached = _gf_false;
@@ -43,16 +42,23 @@ grace_time_handler (void *data)
GF_VALIDATE_OR_GOTO (THIS->name, this, out);
gf_log (this->name, GF_LOG_INFO, "grace timer expired for %s",
- client->server_ctx.client_uid);
+ client->client_uid);
- LOCK (&client->server_ctx.fdtable_lock);
+ serv_ctx = server_ctx_get (client, this);
+
+ if (serv_ctx == NULL) {
+ gf_log (this->name, GF_LOG_INFO, "server_ctx_get() failed");
+ goto out;
+ }
+
+ LOCK (&serv_ctx->fdtable_lock);
{
- if (client->server_ctx.grace_timer) {
- timer = client->server_ctx.grace_timer;
- client->server_ctx.grace_timer = NULL;
+ if (serv_ctx->grace_timer) {
+ timer = serv_ctx->grace_timer;
+ serv_ctx->grace_timer = NULL;
}
}
- UNLOCK (&client->server_ctx.fdtable_lock);
+ UNLOCK (&serv_ctx->fdtable_lock);
if (timer) {
gf_timer_call_cancel (this->ctx, timer);
cancelled = _gf_true;
@@ -67,7 +73,7 @@ grace_time_handler (void *data)
gf_client_put (client, &detached);
if (detached)//reconnection did not happen :-(
server_connection_cleanup (this, client,
- INTERNAL_LOCKS | POSIX_LOCKS);
+ INTERNAL_LOCKS | POSIX_LOCKS);
gf_client_unref (client);
}
out:
@@ -144,7 +150,7 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg,
if (frame) {
state = CALL_STATE (frame);
frame->local = NULL;
- client = state->client;
+ client = frame->root->client;
}
if (client)
@@ -463,6 +469,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
rpc_transport_t *trans = NULL;
server_conf_t *conf = NULL;
client_t *client = NULL;
+ server_ctx_t *serv_ctx = NULL;
if (!xl || !data) {
gf_log_callingfn ("server", GF_LOG_WARNING,
@@ -471,7 +478,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
}
this = xl;
- trans= data;
+ trans = data;
conf = this->private;
switch (event) {
@@ -511,7 +518,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
break;
gf_log (this->name, GF_LOG_INFO, "disconnecting connection"
- "from %s", client->server_ctx.client_uid);
+ "from %s", client->client_uid);
/* If lock self heal is off, then destroy the
conn object, else register a grace timer event */
@@ -527,22 +534,30 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
trans->xl_private = NULL;
server_connection_cleanup (this, client, INTERNAL_LOCKS);
- LOCK (&client->server_ctx.fdtable_lock);
+ serv_ctx = server_ctx_get (client, this);
+
+ if (serv_ctx == NULL) {
+ gf_log (this->name, GF_LOG_INFO,
+ "server_ctx_get() failed");
+ goto out;
+ }
+
+ LOCK (&serv_ctx->fdtable_lock);
{
- if (!client->server_ctx.grace_timer) {
+ if (!serv_ctx->grace_timer) {
gf_log (this->name, GF_LOG_INFO,
"starting a grace timer for %s",
- client->server_ctx.client_uid);
+ client->client_uid);
- client->server_ctx.grace_timer =
+ serv_ctx->grace_timer =
gf_timer_call_after (this->ctx,
conf->grace_ts,
grace_time_handler,
client);
}
}
- UNLOCK (&client->server_ctx.fdtable_lock);
+ UNLOCK (&serv_ctx->fdtable_lock);
break;
case RPCSVC_EVENT_TRANSPORT_DESTROY:
/*- conn obj has been disassociated from trans on first
@@ -753,6 +768,26 @@ out:
return ret;
}
+static int32_t
+client_destroy_cbk (xlator_t *this, client_t *client)
+{
+ void *tmp = NULL;
+ server_ctx_t *ctx = NULL;
+
+ client_ctx_del (client, this, &tmp);
+
+ ctx = tmp;
+
+ if (ctx == NULL)
+ return 0;
+
+ gf_fd_fdtable_destroy (ctx->fdtable);
+ LOCK_DESTROY (&ctx->fdtable_lock);
+ GF_FREE (ctx);
+
+ return 0;
+}
+
int
init (xlator_t *this)
{
@@ -965,7 +1000,9 @@ notify (xlator_t *this, int32_t event, void *data, ...)
struct xlator_fops fops;
-struct xlator_cbks cbks;
+struct xlator_cbks cbks = {
+ .client_destroy = client_destroy_cbk,
+};
struct xlator_dumpops dumpops = {
.priv = server_priv,