~ubuntu-branches/ubuntu/oneiric/pgpool2/oneiric

« back to all changes in this revision

Viewing changes to pool_error.c

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2011-06-10 10:18:29 UTC
  • mfrom: (1.1.6 upstream) (4.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110610101829-m1aig6u0p74qpif3
Tags: 3.0.4-1
* New upstream release
* Use format 3.0 (quilt).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*-pgsql-c-*- */
2
2
/*
3
 
 * $Header: /cvsroot/pgpool/pgpool-II/pool_error.c,v 1.4 2009/08/22 04:04:21 t-ishii Exp $
 
3
 * $Header: /cvsroot/pgpool/pgpool-II/pool_error.c,v 1.8 2010/08/10 15:08:32 gleu Exp $
4
4
 *
5
5
 * pgpool: a language independent connection pool server for PostgreSQL
6
6
 * written by Tatsuo Ishii
7
7
 *
8
 
 * Copyright (c) 2003-2008      PgPool Global Development Group
 
8
 * Copyright (c) 2003-2010      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
29
29
#include <stdlib.h>
30
30
 
31
31
#include "pool.h"
 
32
#include "pool_config.h"
32
33
 
33
34
#define MAXSTRFTIME 128
34
35
 
41
42
        va_list         ap;
42
43
#ifdef HAVE_ASPRINTF
43
44
        char            *fmt2;
 
45
    int         len;
44
46
#endif
45
47
 
46
48
#ifdef HAVE_SIGPROCMASK
53
55
 
54
56
        if (pool_config->print_timestamp)
55
57
#ifdef HAVE_ASPRINTF
56
 
          asprintf(&fmt2, "%s ERROR: pid %d: %s\n", nowsec(), (int)getpid(), fmt);
 
58
          len = asprintf(&fmt2, "%s ERROR: pid %d: %s\n", nowsec(), (int)getpid(), fmt);
57
59
        else
58
 
          asprintf(&fmt2, "ERROR: pid %d: %s\n", (int)getpid(), fmt);
 
60
          len = asprintf(&fmt2, "ERROR: pid %d: %s\n", (int)getpid(), fmt);
59
61
 
60
 
   if (fmt2)
 
62
   if (len >= 0 && fmt2)
61
63
   {
62
64
     va_start(ap, fmt);
63
65
     vfprintf(stderr, fmt2, ap);
84
86
        va_list         ap;
85
87
#ifdef HAVE_ASPRINTF
86
88
        char            *fmt2;
 
89
    int         len;
87
90
#endif
88
91
 
89
92
#ifdef HAVE_SIGPROCMASK
92
95
        int     oldmask;
93
96
#endif
94
97
 
95
 
        if (!debug)
96
 
                return;
 
98
        if (run_as_pcp_child)
 
99
        {
 
100
                if (!debug)
 
101
                        return;
 
102
        }
 
103
        else
 
104
        {
 
105
                if (pool_config->debug_level <= 0)
 
106
                        return;
 
107
        }
97
108
 
98
109
        POOL_SETMASK2(&BlockSig, &oldmask);
99
110
 
100
111
        if (pool_config->print_timestamp)
101
112
#ifdef HAVE_ASPRINTF
102
 
          asprintf(&fmt2, "%s DEBUG: pid %d: %s\n", nowsec(), (int)getpid(), fmt);
 
113
          len = asprintf(&fmt2, "%s DEBUG: pid %d: %s\n", nowsec(), (int)getpid(), fmt);
103
114
        else
104
 
          asprintf(&fmt2, "DEBUG: pid %d: %s\n", (int)getpid(), fmt);
 
115
          len = asprintf(&fmt2, "DEBUG: pid %d: %s\n", (int)getpid(), fmt);
105
116
 
106
 
   if (fmt2)
 
117
   if (len >= 0 && fmt2)
107
118
   {
108
119
     va_start(ap, fmt);
109
120
     vfprintf(stderr, fmt2, ap);
130
141
        va_list         ap;
131
142
#ifdef HAVE_ASPRINTF
132
143
        char            *fmt2;
 
144
    int         len;
133
145
#endif
134
146
 
135
147
#ifdef HAVE_SIGPROCMASK
142
154
 
143
155
        if (pool_config->print_timestamp)
144
156
#ifdef HAVE_ASPRINTF
145
 
          asprintf(&fmt2, "%s LOG:   pid %d: %s\n", nowsec(), (int)getpid(), fmt);
 
157
          len = asprintf(&fmt2, "%s LOG:   pid %d: %s\n", nowsec(), (int)getpid(), fmt);
146
158
        else
147
 
          asprintf(&fmt2, "LOG:   pid %d: %s\n", (int)getpid(), fmt);
 
159
          len = asprintf(&fmt2, "LOG:   pid %d: %s\n", (int)getpid(), fmt);
148
160
 
149
 
   if (fmt2)
 
161
   if (len >= 0 && fmt2)
150
162
   {
151
163
     va_start(ap, fmt);
152
164
     vfprintf(stderr, fmt2, ap);