~raghavendra-prabhu/percona-xtradb-cluster/release-5.5.30-galera-2.x

« back to all changes in this revision

Viewing changes to gcs/src/gcs.c

  • Committer: Ignacio Nin
  • Date: 2012-10-31 22:57:41 UTC
  • mfrom: (95.2.11 2.x)
  • Revision ID: ignacio.nin@percona.com-20121031225741-kzcz6072mwzfpaiw
MergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Copyright (C) 2008-2011 Codership Oy <info@codership.com>
3
3
 *
4
 
 * $Id: gcs.c 2832 2012-06-25 20:06:26Z alex $
 
4
 * $Id: gcs.c 2887 2012-10-24 16:32:16Z alex $
5
5
 */
6
6
 
7
7
/*
830
830
            gu_fatal ("Failed to lock mutex.");
831
831
            abort();
832
832
        }
833
 
 
 
833
 
834
834
        conn->sync_sent = false;
835
835
 
836
836
        // need to wake up send monitor if it was paused during CC
1621
1621
            assert (action.seqno_l >  0);
1622
1622
 
1623
1623
            gcs_gcache_free (conn->gcache, action.buf);
1624
 
            // index of donor is in the global seqno
 
1624
            // on joiner global seqno stores donor index
 
1625
            // on donor global seqno stores global seqno
1625
1626
            ret = action.seqno_g;
1626
1627
        }
1627
1628
        else {
1632
1633
    return ret;
1633
1634
}
1634
1635
 
1635
 
gcs_seqno_t gcs_desync (gcs_conn_t* conn)
 
1636
long gcs_desync (gcs_conn_t* conn, gcs_seqno_t* local)
1636
1637
{
1637
 
    gcs_seqno_t local;
1638
 
    long ret;
1639
 
 
1640
 
    ret = gcs_request_state_transfer (conn, "", 1, GCS_DESYNC_REQ, &local);
1641
 
 
1642
 
    if (ret >= 0) return local;
1643
 
 
1644
 
    assert (GCS_SEQNO_ILL == local);
1645
 
 
1646
 
    return ret;
 
1638
    long ret = gcs_request_state_transfer (conn, "", 1, GCS_DESYNC_REQ, local);
 
1639
 
 
1640
    if (ret >= 0) {
 
1641
        return 0;
 
1642
    }
 
1643
    else {
 
1644
        return ret;
 
1645
    }
1647
1646
}
1648
1647
 
1649
1648
static inline void
1827
1826
static long
1828
1827
_set_fc_limit (gcs_conn_t* conn, const char* value)
1829
1828
{
1830
 
    char* endptr = NULL;
1831
 
    long  limit  = strtol (value, &endptr, 0);
1832
 
 
1833
 
    if (limit > 0 && *endptr == '\0') {
 
1829
    long long limit;
 
1830
    const char* const endptr = gu_str2ll(value, &limit);
 
1831
 
 
1832
    if (limit > 0LL && *endptr == '\0') {
 
1833
 
 
1834
        if (limit > LONG_MAX) limit = LONG_MAX;
1834
1835
 
1835
1836
        gu_fifo_lock(conn->recv_q);
1836
1837
        {
1858
1859
static long
1859
1860
_set_fc_factor (gcs_conn_t* conn, const char* value)
1860
1861
{
1861
 
    char*  endptr = NULL;
1862
 
    double factor = strtod (value, &endptr);
 
1862
    double factor;
 
1863
    const char* const endptr = gu_str2dbl(value, &factor);
1863
1864
 
1864
1865
    if (factor >= 0.0 && factor <= 1.0 && *endptr == '\0') {
1865
1866
 
1891
1892
static long
1892
1893
_set_fc_debug (gcs_conn_t* conn, const char* value)
1893
1894
{
1894
 
    char* endptr = NULL;
1895
 
    long  debug  = strtol (value, &endptr, 0);
 
1895
    bool debug;
 
1896
    const char* const endptr = gu_str2bool(value, &debug);
1896
1897
 
1897
 
    if (debug >= 0 && *endptr == '\0') {
 
1898
    if (*endptr == '\0') {
1898
1899
 
1899
1900
        if (conn->params.fc_debug == debug) return 0;
1900
1901
 
1901
1902
        conn->params.fc_debug = debug;
1902
1903
        gcs_fc_debug (&conn->stfc, debug);
 
1904
        gu_config_set_bool (conn->config, GCS_PARAMS_FC_DEBUG, debug);
1903
1905
 
1904
1906
        return 0;
1905
1907
    }
1928
1930
static long
1929
1931
_set_pkt_size (gcs_conn_t* conn, const char* value)
1930
1932
{
1931
 
    char* endptr   = NULL;
1932
 
    long  pkt_size = strtol (value, &endptr, 0);
 
1933
    long long pkt_size;
 
1934
    const char* const endptr = gu_str2ll (value, &pkt_size);
1933
1935
 
1934
1936
    if (pkt_size > 0 && *endptr == '\0') {
1935
1937
 
 
1938
        if (pkt_size > LONG_MAX) pkt_size = LONG_MAX;
 
1939
 
1936
1940
        if (conn->params.max_packet_size == pkt_size) return 0;
1937
1941
 
1938
1942
        long ret = gcs_set_pkt_size (conn, pkt_size);
1939
1943
 
1940
 
        return (ret >= 0 ? 0 : ret);
 
1944
        if (ret >= 0)
 
1945
        {
 
1946
            ret = 0;
 
1947
            gu_config_set_int64(conn->config,GCS_PARAMS_MAX_PKT_SIZE,pkt_size);
 
1948
        }
 
1949
 
 
1950
        return ret;
1941
1951
    }
1942
1952
    else {
1943
1953
//        gu_warn ("Invalid value for %s: '%s'", GCS_PARAMS_PKT_SIZE, value);
1948
1958
static long
1949
1959
_set_recv_q_hard_limit (gcs_conn_t* conn, const char* value)
1950
1960
{
1951
 
    char*   endptr = NULL;
1952
 
    ssize_t limit  = strtoll (value, &endptr, 0);
 
1961
    long long limit;
 
1962
    const char* const endptr = gu_str2ll (value, &limit);
1953
1963
 
1954
1964
    if (limit > 0 && *endptr == '\0') {
1955
1965
 
1956
 
        if (conn->params.recv_q_hard_limit == limit) return 0;
 
1966
        if (limit > LONG_MAX) limit = LONG_MAX;
 
1967
 
 
1968
        long long limit_fixed = limit * gcs_fc_hard_limit_fix;
 
1969
 
 
1970
        if (conn->params.recv_q_hard_limit == limit_fixed) return 0;
1957
1971
 
1958
1972
        gu_config_set_int64 (conn->config, GCS_PARAMS_RECV_Q_HARD_LIMIT, limit);
1959
 
        conn->params.recv_q_hard_limit = limit * gcs_fc_hard_limit_fix;
 
1973
        conn->params.recv_q_hard_limit = limit_fixed;
1960
1974
 
1961
1975
        return 0;
1962
1976
    }
1968
1982
static long
1969
1983
_set_recv_q_soft_limit (gcs_conn_t* conn, const char* value)
1970
1984
{
1971
 
    char*  endptr = NULL;
1972
 
    double dbl    = strtod (value, &endptr);
 
1985
    double dbl;
 
1986
    const char* const endptr = gu_str2dbl (value, &dbl);
1973
1987
 
1974
1988
    if (dbl >= 0.0 && dbl < 1.0 && *endptr == '\0') {
1975
1989
 
1988
2002
static long
1989
2003
_set_max_throttle (gcs_conn_t* conn, const char* value)
1990
2004
{
1991
 
    char*  endptr = NULL;
1992
 
    double dbl    = strtod (value, &endptr);
 
2005
    double dbl;
 
2006
    const char* const endptr = gu_str2dbl (value, &dbl);
1993
2007
 
1994
2008
    if (dbl >= 0.0 && dbl < 1.0 && *endptr == '\0') {
1995
2009