summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src/client-handshake.c
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2015-05-31 15:16:41 +0200
committerNiels de Vos <ndevos@redhat.com>2015-06-20 05:01:43 -0700
commitea1d2b0045e2c2ad82a2162a58f9fc36f9d07b20 (patch)
tree986f6c3039c26e0d4547b1ddde8b0f324270113d /xlators/protocol/client/src/client-handshake.c
parentf460d1c9a2d83b24500c574aabce75438bdc8f9d (diff)
core: add "gf_ref_t" for common refcounting structures
Checks for compiler supported atomic operations comes from client_t.h. An example usage of this change can be found in adding reference counting to "struct auth_cache_entry" in http://review.gluster.org/11023 Basic usage looks like this: #include "refcount.h" struct my_struct { GF_REF_DECL; ... /* more members */ } void my_destructor (void *data) { struct my_struct *my_ptr = (struct my_struct *) data; ... /* do some more cleanups */ GF_FREE (my_ptr); } void init_ptr (struct parent *parent) { struct my_struct *my_ptr = malloc (sizeof (struct my_struct)); GF_REF_INIT (my_ptr, my_destructor); /* refcount is set to 1 */ ... /* my_ptr probably gets added to some parent structure */ parent_add_ptr (parent, my_ptr); } void do_something (struct parent *parent) { struct my_struct *my_ptr = NULL; /* likely need to lock parent, depends on its access pattern */ my_ptr = parent_remove_first_ptr (parent); /* unlock parent */ ... /* do something */ GF_REF_PUT (my_ptr); /* calls my_destructor on refcount = 0 */ } URL: http://thread.gmane.org/gmane.comp.file-systems.gluster.devel/11202 Change-Id: Idb98a5861a44c31676108ed8876db12c320912ef BUG: 1228157 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/11022 Reviewed-by: Xavier Hernandez <xhernandez@datalab.es> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'xlators/protocol/client/src/client-handshake.c')
0 files changed, 0 insertions, 0 deletions