~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/backend/storage/ipc/procarray.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 *
24
24
 *
25
25
 * IDENTIFICATION
26
 
 *        $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.49 2009/04/04 17:40:36 tgl Exp $
 
26
 *        $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.50 2009/06/11 14:49:02 momjian Exp $
27
27
 *
28
28
 *-------------------------------------------------------------------------
29
29
 */
829
829
        snapshot->curcid = GetCurrentCommandId(false);
830
830
 
831
831
        /*
832
 
         * This is a new snapshot, so set both refcounts are zero, and mark it
833
 
         * as not copied in persistent memory.
 
832
         * This is a new snapshot, so set both refcounts are zero, and mark it as
 
833
         * not copied in persistent memory.
834
834
         */
835
835
        snapshot->active_count = 0;
836
836
        snapshot->regd_count = 0;
1038
1038
 * some snapshot we have.  Since we examine the procarray with only shared
1039
1039
 * lock, there are race conditions: a backend could set its xmin just after
1040
1040
 * we look.  Indeed, on multiprocessors with weak memory ordering, the
1041
 
 * other backend could have set its xmin *before* we look.  We know however
 
1041
 * other backend could have set its xmin *before* we look.      We know however
1042
1042
 * that such a backend must have held shared ProcArrayLock overlapping our
1043
1043
 * own hold of ProcArrayLock, else we would see its xmin update.  Therefore,
1044
1044
 * any snapshot the other backend is taking concurrently with our scan cannot
1133
1133
                 *
1134
1134
                 * If someone just decremented numProcs, 'proc' could also point to a
1135
1135
                 * PGPROC entry that's no longer in the array. It still points to a
1136
 
                 * PGPROC struct, though, because freed PGPPROC entries just go to
1137
 
                 * the free list and are recycled. Its contents are nonsense in that
1138
 
                 * case, but that's acceptable for this function.
 
1136
                 * PGPROC struct, though, because freed PGPPROC entries just go to the
 
1137
                 * free list and are recycled. Its contents are nonsense in that case,
 
1138
                 * but that's acceptable for this function.
1139
1139
                 */
1140
1140
                if (proc != NULL)
1141
1141
                        continue;
1235
1235
CountOtherDBBackends(Oid databaseId, int *nbackends, int *nprepared)
1236
1236
{
1237
1237
        ProcArrayStruct *arrayP = procArray;
1238
 
#define MAXAUTOVACPIDS  10              /* max autovacs to SIGTERM per iteration */
 
1238
 
 
1239
#define MAXAUTOVACPIDS  10              /* max autovacs to SIGTERM per iteration */
1239
1240
        int                     autovac_pids[MAXAUTOVACPIDS];
1240
1241
        int                     tries;
1241
1242
 
1280
1281
                        return false;           /* no conflicting backends, so done */
1281
1282
 
1282
1283
                /*
1283
 
                 * Send SIGTERM to any conflicting autovacuums before sleeping.
1284
 
                 * We postpone this step until after the loop because we don't
1285
 
                 * want to hold ProcArrayLock while issuing kill().
1286
 
                 * We have no idea what might block kill() inside the kernel...
 
1284
                 * Send SIGTERM to any conflicting autovacuums before sleeping. We
 
1285
                 * postpone this step until after the loop because we don't want to
 
1286
                 * hold ProcArrayLock while issuing kill(). We have no idea what might
 
1287
                 * block kill() inside the kernel...
1287
1288
                 */
1288
1289
                for (index = 0; index < nautovacs; index++)
1289
1290
                        (void) kill(autovac_pids[index], SIGTERM);      /* ignore any error */