summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2014-06-27 08:20:10 -0400
committerNiels de Vos <ndevos@redhat.com>2014-07-07 06:09:22 -0700
commit515113f243c1ff805139f600a98343f21bb2b885 (patch)
tree98c2be98c634292195d0d534ecfeb9de8952225e /libglusterfs
parent193d3b348a6c657e51f2a62c8bd9726fb635d582 (diff)
libglusterfs/client_t: cliententries are never expanded
clienttable->cliententries are never expanded once all the available entries have been used. Also removed a couple chatty log messages. Change-Id: I3947fcb948e9ab84d1bb54233e96ea6808620b66 BUG: 1113749 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: http://review.gluster.org/8193 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/client_t.c43
-rw-r--r--libglusterfs/src/client_t.h2
2 files changed, 31 insertions, 14 deletions
diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c
index 1bf3de3f5ff..957eca60978 100644
--- a/libglusterfs/src/client_t.c
+++ b/libglusterfs/src/client_t.c
@@ -52,26 +52,20 @@ gf_client_clienttable_expand (clienttable_t *clienttable, uint32_t nr)
uint32_t oldmax_clients = -1;
int ret = -1;
- if (clienttable == NULL || nr < 0) {
+ if (clienttable == NULL || nr <= clienttable->max_clients) {
gf_log_callingfn ("client_t", GF_LOG_ERROR, "invalid argument");
ret = EINVAL;
goto out;
}
- /* expand size by power-of-two...
- this originally came from .../xlators/protocol/server/src/server.c
- where it was not commented */
- nr /= (1024 / sizeof (cliententry_t));
- nr = gf_roundup_next_power_of_two (nr + 1);
- nr *= (1024 / sizeof (cliententry_t));
-
oldclients = clienttable->cliententries;
oldmax_clients = clienttable->max_clients;
clienttable->cliententries = GF_CALLOC (nr, sizeof (cliententry_t),
gf_common_mt_cliententry_t);
if (!clienttable->cliententries) {
- ret = ENOMEM;
+ clienttable->cliententries = oldclients;
+ ret = 0;
goto out;
}
clienttable->max_clients = nr;
@@ -101,6 +95,7 @@ clienttable_t *
gf_clienttable_alloc (void)
{
clienttable_t *clienttable = NULL;
+ int result = 0;
clienttable =
GF_CALLOC (1, sizeof (clienttable_t), gf_common_mt_clienttable_t);
@@ -108,7 +103,16 @@ gf_clienttable_alloc (void)
return NULL;
LOCK_INIT (&clienttable->lock);
- gf_client_clienttable_expand (clienttable, GF_CLIENTTABLE_INITIAL_SIZE);
+
+ result = gf_client_clienttable_expand (clienttable,
+ GF_CLIENTTABLE_INITIAL_SIZE);
+ if (result != 0) {
+ gf_log ("client_t", GF_LOG_ERROR,
+ "gf_client_clienttable_expand failed");
+ GF_FREE (clienttable);
+ return NULL;
+ }
+
return clienttable;
}
@@ -181,8 +185,6 @@ gf_client_get (xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid)
return NULL;
}
- gf_log (this->name, GF_LOG_INFO, "client_uid=%s", client_uid);
-
clienttable = this->ctx->clienttable;
LOCK (&clienttable->lock);
@@ -264,7 +266,22 @@ gf_client_get (xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid)
}
client->tbl_index = clienttable->first_free;
- cliententry = &clienttable->cliententries[client->tbl_index];
+ cliententry = &clienttable->cliententries[clienttable->first_free];
+ if (cliententry->next_free == GF_CLIENTTABLE_END) {
+ int result =
+ gf_client_clienttable_expand (clienttable,
+ clienttable->max_clients +
+ GF_CLIENTTABLE_INITIAL_SIZE);
+ if (result != 0) {
+ GF_FREE (client->scratch_ctx.ctx);
+ GF_FREE (client->client_uid);
+ GF_FREE (client);
+ client = NULL;
+ errno = result;
+ goto unlock;
+ }
+ cliententry->next_free = clienttable->first_free;
+ }
cliententry->client = client;
clienttable->first_free = cliententry->next_free;
cliententry->next_free = GF_CLIENTENTRY_ALLOCATED;
diff --git a/libglusterfs/src/client_t.h b/libglusterfs/src/client_t.h
index 548081896c0..8e913be27b7 100644
--- a/libglusterfs/src/client_t.h
+++ b/libglusterfs/src/client_t.h
@@ -64,7 +64,7 @@ struct clienttable {
};
typedef struct clienttable clienttable_t;
-#define GF_CLIENTTABLE_INITIAL_SIZE 32
+#define GF_CLIENTTABLE_INITIAL_SIZE 128
/* Signifies no more entries in the client table. */
#define GF_CLIENTTABLE_END -1