~ubuntu-branches/ubuntu/vivid/pgpool2/vivid-proposed

« back to all changes in this revision

Viewing changes to main.c

  • Committer: Package Import Robot
  • Author(s): Christoph Berg
  • Date: 2014-10-15 21:36:17 UTC
  • mfrom: (15.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20141015213617-opxy1fvj2im734tw
Tags: 3.3.4-1
* New upstream release.
* Remove test patches that no longer apply.
* Skip installcheck test on 8.4/9.0.
* Add systemd service file, initial patch by Michael Stapelberg, thanks!
  Closes: #756453.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * pgpool: a language independent connection pool server for PostgreSQL
6
6
 * written by Tatsuo Ishii
7
7
 *
8
 
 * Copyright (c) 2003-2013      PgPool Global Development Group
 
8
 * Copyright (c) 2003-2014      PgPool Global Development Group
9
9
 *
10
10
 * Permission to use, copy, modify, and distribute this software and
11
11
 * its documentation for any purpose and without fee is hereby
935
935
 
936
936
        /* redirect stdin, stdout and stderr to /dev/null */
937
937
        i = open("/dev/null", O_RDWR);
938
 
        dup2(i, 0);
939
 
        dup2(i, 1);
940
 
        dup2(i, 2);
941
 
 
 
938
        if(i < 0)
 
939
        {
 
940
                pool_error("Failed to open \"/dev/null\" reason:%s", strerror(errno));
 
941
        }
 
942
        else
 
943
        {
 
944
                dup2(i, 0);
 
945
                dup2(i, 1);
 
946
                dup2(i, 2);
 
947
                close(i);
 
948
        }
942
949
        /* close syslog connection for daemonizing */
943
950
        if (pool_config->logsyslog) {
944
951
                closelog();
1589
1596
        {
1590
1597
                pool_debug("exit_handler: I am not parent");
1591
1598
                POOL_SETMASK(&UnBlockSig);
1592
 
                pool_shmem_exit(0);
1593
1599
                exit(0);
1594
1600
        }
1595
1601
 
1608
1614
 
1609
1615
        exiting = 1;
1610
1616
 
 
1617
        /* Close listen socket */
 
1618
        pool_log("pgpool main: close listen socket");
 
1619
        close(inet_fd);
 
1620
        close(unix_fd);
 
1621
 
1611
1622
        for (i = 0; i < pool_config->num_init_children; i++)
1612
1623
        {
1613
1624
                pid_t pid = process_info[i].pid;
2817
2828
        BackendInfo *bkinfo;
2818
2829
        POOL_CONNECTION_POOL_SLOT *s;
2819
2830
        POOL_CONNECTION *con;
2820
 
        POOL_STATUS status;
2821
2831
        POOL_SELECT_RESULT *res;
2822
2832
        bool is_standby;
2823
2833
        int i;
2862
2872
                        continue;
2863
2873
                }
2864
2874
                con = s->con;
2865
 
                status = do_query(con, "SELECT pg_is_in_recovery()",
2866
 
                                                  &res, PROTO_MAJOR_V3);
2867
 
                if (res->numrows <= 0)
2868
 
                {
2869
 
                        pool_log("find_primary_node: do_query returns no rows");
2870
 
                }
2871
 
                if (res->data[0] == NULL)
2872
 
                {
2873
 
                        pool_log("find_primary_node: do_query returns no data");
2874
 
                }
2875
 
                if (res->nullflags[0] == -1)
2876
 
                {
2877
 
                        pool_log("find_primary_node: do_query returns NULL");
2878
 
                }
2879
 
                if (res->data[0] && !strcmp(res->data[0], "t"))
2880
 
                {
2881
 
                        is_standby = true;
2882
 
                }
2883
 
                free_select_result(res);
 
2875
                if (do_query(con, "SELECT pg_is_in_recovery()",&res, PROTO_MAJOR_V3) == POOL_CONTINUE)
 
2876
                {
 
2877
                        if (res->numrows <= 0)
 
2878
                        {
 
2879
                                pool_log("find_primary_node: do_query returns no rows");
 
2880
                        }
 
2881
                        if (res->data[0] == NULL)
 
2882
                        {
 
2883
                                pool_log("find_primary_node: do_query returns no data");
 
2884
                        }
 
2885
                        if (res->nullflags[0] == -1)
 
2886
                        {
 
2887
                                pool_log("find_primary_node: do_query returns NULL");
 
2888
                        }
 
2889
                        if (res->data[0] && !strcmp(res->data[0], "t"))
 
2890
                        {
 
2891
                                is_standby = true;
 
2892
                        }
 
2893
                }
 
2894
                else
 
2895
                {
 
2896
                        pool_log("find_primary_node: do_query failed");
 
2897
                }
 
2898
 
 
2899
                if(res)
 
2900
                        free_select_result(res);
2884
2901
                discard_persistent_db_connection(s);
2885
2902
 
2886
2903
                /*