summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@zresearch.com>2009-04-03 06:30:54 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-03 19:09:35 +0530
commit6eb419f1ca68f536a700e63c1521e428560a0d9d (patch)
tree571e5bb852d90b94ddab0bcc5a7deaf26630c2a0 /libglusterfs
parentd3d7245970189629937f6330a6d946f5fbb454af (diff)
server-protocol - reimplement connection cleanup to happen in 2 phases
- first phase, which happens when POLLERR is received on transport, releases all locks, flushes all open fds. - second phase, which happens when both the transports of connection destroyed, destroys the containers like lock table, fd table along with the connection. - the first phase, clears up any references to transport held by translators like posix-locks(in the form of blocked locks) paving way for the second phase. Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/fd.c62
-rw-r--r--libglusterfs/src/fd.h3
2 files changed, 55 insertions, 10 deletions
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 918b6c14dcc..deb3c800145 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -129,26 +129,68 @@ gf_fd_fdtable_alloc (void)
return fdtable;
}
+fd_t **
+__gf_fd_fdtable_get_all_fds (fdtable_t *fdtable, uint32_t *count)
+{
+ fd_t **fds = NULL;
+
+ if (count == NULL) {
+ goto out;
+ }
+
+ fds = fdtable->fds;
+ fdtable->fds = calloc (fdtable->max_fds, sizeof (fd_t *));
+ *count = fdtable->max_fds;
+
+out:
+ return fds;
+}
+
+fd_t **
+gf_fd_fdtable_get_all_fds (fdtable_t *fdtable, uint32_t *count)
+{
+ fd_t **fds = NULL;
+ if (fdtable) {
+ pthread_mutex_lock (&fdtable->lock);
+ {
+ fds = __gf_fd_fdtable_get_all_fds (fdtable, count);
+ }
+ pthread_mutex_unlock (&fdtable->lock);
+ }
+
+ return fds;
+}
+
void
gf_fd_fdtable_destroy (fdtable_t *fdtable)
{
-
- int32_t i = 0;
+ struct list_head list = {0, };
+ fd_t *fd = NULL;
+ fd_t **fds = NULL;
+ uint32_t fd_count = 0;
+ int32_t i = 0;
+
+ INIT_LIST_HEAD (&list);
if (fdtable) {
pthread_mutex_lock (&fdtable->lock);
{
- for (i=0; i < fdtable->max_fds; i++) {
- if (fdtable->fds[i]) {
- fd_t *fd = fdtable->fds[i];
-
- fd_unref (fd);
- }
- }
-
+ fds = __gf_fd_fdtable_get_all_fds (fdtable, &fd_count);
FREE (fdtable->fds);
}
pthread_mutex_unlock (&fdtable->lock);
+
+ if (fds != NULL) {
+ for (i = 0; i < fd_count; i++) {
+ fd = fds[i];
+ if (fd != NULL) {
+ fd_unref (fd);
+ }
+ }
+
+ FREE (fds);
+ }
+
pthread_mutex_destroy (&fdtable->lock);
FREE (fdtable);
}
diff --git a/libglusterfs/src/fd.h b/libglusterfs/src/fd.h
index 0382ccdc218..2916a44812e 100644
--- a/libglusterfs/src/fd.h
+++ b/libglusterfs/src/fd.h
@@ -77,6 +77,9 @@ gf_fd_unused_get (fdtable_t *fdtable, fd_t *fdptr);
int32_t
gf_fd_unused_get2 (fdtable_t *fdtable, fd_t *fdptr, int32_t fd);
+fd_t **
+gf_fd_fdtable_get_all_fds (fdtable_t *fdtable, uint32_t *count);
+
void
gf_fd_fdtable_destroy (fdtable_t *fdtable);