- fix dead lock from upstream
[packages/db4.7.git] / patch.4.6.21.1
1 *** dbinc/mp.h  2007-09-28 01:28:25.000000000 +1000
2 --- dbinc/mp.h  2008-02-14 01:22:09.000000000 +1100
3 ***************
4 *** 639,644 ****
5 --- 639,647 ----
6    */
7   #define       MP_TRUNC_RECOVER        0x01
8   
9 + /* Private flags to DB_MPOOLFILE->close. */
10 + #define       DB_MPOOL_NOLOCK         0x002   /* Already have mpf locked. */
11
12   #if defined(__cplusplus)
13   }
14   #endif
15 *** mp/mp_fopen.c       2007-05-18 03:18:01.000000000 +1000
16 --- mp/mp_fopen.c       2008-02-12 16:09:42.000000000 +1100
17 ***************
18 *** 888,894 ****
19          * when we try to flush them.
20          */
21         deleted = 0;
22 !       MUTEX_LOCK(dbenv, mfp->mutex);
23         if (F_ISSET(dbmfp, MP_MULTIVERSION))
24                 --mfp->multiversion;
25         if (--mfp->mpf_cnt == 0 || LF_ISSET(DB_MPOOL_DISCARD)) {
26 --- 888,895 ----
27          * when we try to flush them.
28          */
29         deleted = 0;
30 !       if (!LF_ISSET(DB_MPOOL_NOLOCK))
31 !               MUTEX_LOCK(dbenv, mfp->mutex);
32         if (F_ISSET(dbmfp, MP_MULTIVERSION))
33                 --mfp->multiversion;
34         if (--mfp->mpf_cnt == 0 || LF_ISSET(DB_MPOOL_DISCARD)) {
35 ***************
36 *** 909,921 ****
37                         }
38                 }
39                 if (mfp->block_cnt == 0) {
40                         if ((t_ret =
41                             __memp_mf_discard(dbmp, mfp)) != 0 && ret == 0)
42                                 ret = t_ret;
43                         deleted = 1;
44                 }
45         }
46 !       if (!deleted)
47                 MUTEX_UNLOCK(dbenv, mfp->mutex);
48   
49   done: /* Discard the DB_MPOOLFILE structure. */
50 --- 910,928 ----
51                         }
52                 }
53                 if (mfp->block_cnt == 0) {
54 +                       /*
55 +                        * We should never discard this mp file if our caller
56 +                        * is holding the lock on it.  See comment in
57 +                        * __memp_sync_file.
58 +                        */
59 +                       DB_ASSERT(dbenv, !LF_ISSET(DB_MPOOL_NOLOCK));
60                         if ((t_ret =
61                             __memp_mf_discard(dbmp, mfp)) != 0 && ret == 0)
62                                 ret = t_ret;
63                         deleted = 1;
64                 }
65         }
66 !       if (!deleted && !LF_ISSET(DB_MPOOL_NOLOCK))
67                 MUTEX_UNLOCK(dbenv, mfp->mutex);
68   
69   done: /* Discard the DB_MPOOLFILE structure. */
70 *** mp/mp_sync.c        2007-06-02 04:32:44.000000000 +1000
71 --- mp/mp_sync.c        2008-02-12 16:09:42.000000000 +1100
72 ***************
73 *** 755,761 ****
74          * This is important since we are called with the hash bucket
75          * locked.  The mfp will get freed via the cleanup pass.
76          */
77 !       if (dbmfp != NULL && (t_ret = __memp_fclose(dbmfp, 0)) != 0 && ret == 0)
78                 ret = t_ret;
79   
80         --mfp->mpf_cnt;
81 --- 755,762 ----
82          * This is important since we are called with the hash bucket
83          * locked.  The mfp will get freed via the cleanup pass.
84          */
85 !       if (dbmfp != NULL &&
86 !           (t_ret = __memp_fclose(dbmfp, DB_MPOOL_NOLOCK)) != 0 && ret == 0)
87                 ret = t_ret;
88   
89         --mfp->mpf_cnt;
90
This page took 0.079153 seconds and 3 git commands to generate.