"Fossies" - the Fresh Open Source Software Archive

Member "glusterfs-8.2/xlators/features/changelog/src/changelog-rt.c" (16 Sep 2020, 1491 Bytes) of package /linux/misc/glusterfs-8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "changelog-rt.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2    Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com>
    3    This file is part of GlusterFS.
    4 
    5    This file is licensed to you under your choice of the GNU Lesser
    6    General Public License, version 3 or any later version (LGPLv3 or
    7    later), or the GNU General Public License, version 2 (GPLv2), in all
    8    cases as published by the Free Software Foundation.
    9 */
   10 
   11 #include <glusterfs/xlator.h>
   12 #include <glusterfs/defaults.h>
   13 #include <glusterfs/logging.h>
   14 
   15 #include "changelog-rt.h"
   16 #include "changelog-mem-types.h"
   17 
   18 int
   19 changelog_rt_init(xlator_t *this, changelog_dispatcher_t *cd)
   20 {
   21     changelog_rt_t *crt = NULL;
   22 
   23     crt = GF_CALLOC(1, sizeof(*crt), gf_changelog_mt_rt_t);
   24     if (!crt)
   25         return -1;
   26 
   27     LOCK_INIT(&crt->lock);
   28 
   29     cd->cd_data = crt;
   30     cd->dispatchfn = &changelog_rt_enqueue;
   31 
   32     return 0;
   33 }
   34 
   35 int
   36 changelog_rt_fini(xlator_t *this, changelog_dispatcher_t *cd)
   37 {
   38     changelog_rt_t *crt = NULL;
   39 
   40     crt = cd->cd_data;
   41 
   42     LOCK_DESTROY(&crt->lock);
   43     GF_FREE(crt);
   44 
   45     return 0;
   46 }
   47 
   48 int
   49 changelog_rt_enqueue(xlator_t *this, changelog_priv_t *priv, void *cbatch,
   50                      changelog_log_data_t *cld_0, changelog_log_data_t *cld_1)
   51 {
   52     int ret = 0;
   53     changelog_rt_t *crt = NULL;
   54 
   55     crt = (changelog_rt_t *)cbatch;
   56 
   57     LOCK(&crt->lock);
   58     {
   59         ret = changelog_handle_change(this, priv, cld_0);
   60         if (!ret && cld_1)
   61             ret = changelog_handle_change(this, priv, cld_1);
   62     }
   63     UNLOCK(&crt->lock);
   64 
   65     return ret;
   66 }