Compare commits

...

5 Commits
3.7 ... 3.8

19 changed files with 2553 additions and 28 deletions

View File

@ -1,6 +1,11 @@
untrusted comment: verify with /etc/ports/compat-32.pub
RWSwxGo/zH7eXaf9DbwK6/mMIQa09AxY9Fh3s474XP9tc9PLadby1edVu8NqNMr4VeabJ5YZwODNmU+970k/bcQB3yY5IUPDkAs=
SHA256 (Pkgfile) = bbc4f26b7d3c6a73b74a4c5589679410f8123a6b3f67fc80d59bff4531d56249
RWSwxGo/zH7eXVfV589sT6uuxahtD8tA40lMYAiqbZLZ2NY+xnD7LJFWFQB9aYVbHxwCmv9hXdqYYwTqnftMt6nuCbE7fs2mPQI=
SHA256 (Pkgfile) = 17017f398ae3867429dc2ff324b27779300a2537fdb4a3a2df2296731f7ce025
SHA256 (.footprint) = f48dabc8d96d2d29b1e4772033c3f0056ebfe7498829bbb79da1db9267f16314
SHA256 (db-5.3.28.tar.gz) = e0a992d740709892e81f9d93f06daf305cf73fb81b545afe72478043172c3628
SHA256 (db-5.3.21-memp_stat-upstream-fix.patch) = 80714b9fc9f15f83452e85849897e53526685c5f611cb156decc48ebcac4009d
SHA256 (db-5.3.21-mutex_leak.patch) = 0bba53c23da0c15eae7ddf409e0c70f25946d7bcd5565ffcf9df1fadbff3e308
SHA256 (db-5.3.28-lemon_hash.patch) = 285e210c4e722b6644f0c7de43fa0ef324881875d3c083aa7b6cad0ed666e8e4
SHA256 (db-5.3.28-mmap-high-cpu-usage.patch) = 45b76375ffab07882df57999a492463e7bed36c25edf3b1d2d5dbca8c11c93ac
SHA256 (db-5.3.28_cve-2019-2708.patch) = f538d843acf0708b4a2d15678dfc6ee53b1e4e52a6c6a782dfc1a058395952c6
SHA256 (0001-atomic-Rename-local-__atomic_compare_exchange-to-avo.patch) = 696ac5af5473f0d85ecc6af44a85333c91500721fb5c33028c05e843429058d1

View File

@ -1,24 +1,37 @@
# Description: Berkeley DB
# URL: http://www.oracle.com/database/berkeley-db/index.html
# Maintainer: CRUX compat-32 Team, compat-32-ports at crux dot nu
# URL: http://www.oracle.com/database/berkeley-db/index.html
# Maintainer: CRUX compat-32 Team, compat-32-ports at crux dot nu
name=db-32
version=5.3.28
release=2
release=3
source=(https://download.oracle.com/berkeley-db/db-$version.tar.gz
0001-atomic-Rename-local-__atomic_compare_exchange-to-avo.patch)
db-5.3.21-memp_stat-upstream-fix.patch
db-5.3.21-mutex_leak.patch
db-5.3.28-lemon_hash.patch
db-5.3.28-mmap-high-cpu-usage.patch
db-5.3.28_cve-2019-2708.patch
0001-atomic-Rename-local-__atomic_compare_exchange-to-avo.patch)
build() {
cd db-$version/build_unix
cd db-$version
patch -p1 -d .. -i $SRC/0001-atomic-Rename-local-__atomic_compare_exchange-to-avo.patch
patch -p1 -i $SRC/0001-atomic-Rename-local-__atomic_compare_exchange-to-avo.patch
patch -p1 -i $SRC/db-5.3.21-memp_stat-upstream-fix.patch
patch -p1 -i $SRC/db-5.3.21-mutex_leak.patch
patch -p1 -i $SRC/db-5.3.28-lemon_hash.patch
patch -p1 -i $SRC/db-5.3.28-mmap-high-cpu-usage.patch
patch -p1 -i $SRC/db-5.3.28_cve-2019-2708.patch
cd build_unix
CFLAGS="$CFLAGS -Wno-error=implicit-int" \
../dist/configure --prefix=/usr \
--libdir=/usr/lib32 \
--enable-compat185 \
--enable-shared \
--enable-static \
--enable-cxx
--libdir=/usr/lib32 \
--enable-compat185 \
--enable-shared \
--enable-static \
--enable-cxx
make
make DESTDIR=$PKG install
rm -r $PKG/usr/docs

View File

@ -0,0 +1,183 @@
diff -r -u db-5.3.21_orig/src/mp/mp_stat.c db-5.3.21/src/mp/mp_stat.c
--- db-5.3.21_orig/src/mp/mp_stat.c 2012-05-12 01:57:53.000000000 +0800
+++ db-5.3.21/src/mp/mp_stat.c 2015-05-19 15:07:09.000000000 +0800
@@ -87,6 +87,13 @@
u_int32_t i;
uintmax_t tmp_wait, tmp_nowait;
+ /*
+ * The array holding the lengths related to the buffer allocated for *fspp.
+ * The first element of the array holds the number of entries allocated.
+ * The second element of the array holds the total number of bytes allocated.
+ */
+ u_int32_t fsp_len[2];
+
dbmp = env->mp_handle;
mp = dbmp->reginfo[0].primary;
@@ -193,32 +200,53 @@
if (fspp != NULL) {
*fspp = NULL;
- /* Count the MPOOLFILE structures. */
- i = 0;
- len = 0;
- if ((ret = __memp_walk_files(env,
- mp, __memp_count_files, &len, &i, flags)) != 0)
- return (ret);
+ while (*fspp == NULL) {
+ /* Count the MPOOLFILE structures. */
+ i = 0;
+ /*
+ * Allow space for the first __memp_get_files() to align the
+ * structure array to uintmax_t, DB_MPOOL_STAT's most
+ * restrictive field. [#23150]
+ */
+ len = sizeof(uintmax_t);
+ if ((ret = __memp_walk_files(env,
+ mp, __memp_count_files, &len, &i, flags)) != 0)
+ return (ret);
+
+ if (i == 0)
+ return (0);
+
+ /*
+ * Copy the number of DB_MPOOL_FSTAT entries and the number of
+ * bytes allocated for them into fsp_len. Do not count the space
+ * reserved for allignment.
+ */
+ fsp_len[0] = i;
+ fsp_len[1] = len - sizeof(uintmax_t);
- if (i == 0)
- return (0);
- len += sizeof(DB_MPOOL_FSTAT *); /* Trailing NULL */
+ len += sizeof(DB_MPOOL_FSTAT *); /* Trailing NULL */
- /* Allocate space */
- if ((ret = __os_umalloc(env, len, fspp)) != 0)
- return (ret);
+ /* Allocate space */
+ if ((ret = __os_umalloc(env, len, fspp)) != 0)
+ return (ret);
- tfsp = *fspp;
- *tfsp = NULL;
-
- /*
- * Files may have been opened since we counted, don't walk
- * off the end of the allocated space.
- */
- if ((ret = __memp_walk_files(env,
- mp, __memp_get_files, &tfsp, &i, flags)) != 0)
- return (ret);
+ tfsp = *fspp;
+ *tfsp = NULL;
+ /*
+ * Files may have been opened since we counted, if we walk off
+ * the end of the allocated space specified in fsp_len, retry.
+ */
+ if ((ret = __memp_walk_files(env,
+ mp, __memp_get_files, &tfsp, fsp_len, flags)) != 0) {
+ if (ret == DB_BUFFER_SMALL) {
+ __os_ufree(env, *fspp);
+ *fspp = NULL;
+ tfsp = NULL;
+ } else
+ return (ret);
+ }
+ }
*++tfsp = NULL;
}
@@ -286,28 +314,35 @@
* for the text file names.
*/
static int
-__memp_get_files(env, mfp, argp, countp, flags)
+__memp_get_files(env, mfp, argp, fsp_len, flags)
ENV *env;
MPOOLFILE *mfp;
void *argp;
- u_int32_t *countp;
+ u_int32_t fsp_len[];
u_int32_t flags;
{
DB_MPOOL *dbmp;
DB_MPOOL_FSTAT **tfsp, *tstruct;
char *name, *tname;
- size_t nlen;
+ size_t nlen, tlen;
- if (*countp == 0)
- return (0);
+ /* We walked through more files than argp was allocated for. */
+ if (fsp_len[0] == 0)
+ return DB_BUFFER_SMALL;
dbmp = env->mp_handle;
tfsp = *(DB_MPOOL_FSTAT ***)argp;
if (*tfsp == NULL) {
- /* Add 1 to count because we need to skip over the NULL. */
- tstruct = (DB_MPOOL_FSTAT *)(tfsp + *countp + 1);
- tname = (char *)(tstruct + *countp);
+ /*
+ * Add 1 to count because to skip over the NULL end marker.
+ * Align it further for DB_MPOOL_STAT's most restrictive field
+ * because uintmax_t might require stricter alignment than
+ * pointers; e.g., IP32 LL64 SPARC. [#23150]
+ */
+ tstruct = (DB_MPOOL_FSTAT *)&tfsp[fsp_len[0] + 1];
+ tstruct = ALIGNP_INC(tstruct, sizeof(uintmax_t));
+ tname = (char *)&tstruct[fsp_len[0]];
*tfsp = tstruct;
} else {
tstruct = *tfsp + 1;
@@ -317,6 +352,15 @@
name = __memp_fns(dbmp, mfp);
nlen = strlen(name) + 1;
+
+ /* The space required for file names is larger than argp was allocated for. */
+ tlen = sizeof(DB_MPOOL_FSTAT *) + sizeof(DB_MPOOL_FSTAT) + nlen;
+ if (fsp_len[1] < tlen)
+ return DB_BUFFER_SMALL;
+ else
+ /* Count down the number of bytes left in argp. */
+ fsp_len[1] -= tlen;
+
memcpy(tname, name, nlen);
memcpy(tstruct, &mfp->stat, sizeof(mfp->stat));
tstruct->file_name = tname;
@@ -325,7 +369,9 @@
tstruct->st_pagesize = mfp->pagesize;
*(DB_MPOOL_FSTAT ***)argp = tfsp;
- (*countp)--;
+
+ /* Count down the number of entries left in argp. */
+ fsp_len[0]--;
if (LF_ISSET(DB_STAT_CLEAR))
memset(&mfp->stat, 0, sizeof(mfp->stat));
diff -r -u db-5.3.21_orig/src/mp/mp_sync.c db-5.3.21/src/mp/mp_sync.c
--- db-5.3.21_orig/src/mp/mp_sync.c 2012-05-12 01:57:53.000000000 +0800
+++ db-5.3.21/src/mp/mp_sync.c 2015-05-19 15:08:05.000000000 +0800
@@ -57,11 +57,13 @@
if ((t_ret = func(env,
mfp, arg, countp, flags)) != 0 && ret == 0)
ret = t_ret;
- if (ret != 0 && !LF_ISSET(DB_STAT_MEMP_NOERROR))
+ if (ret != 0 &&
+ (!LF_ISSET(DB_STAT_MEMP_NOERROR) || ret == DB_BUFFER_SMALL))
break;
}
MUTEX_UNLOCK(env, hp->mtx_hash);
- if (ret != 0 && !LF_ISSET(DB_STAT_MEMP_NOERROR))
+ if (ret != 0 &&
+ (!LF_ISSET(DB_STAT_MEMP_NOERROR) || ret == DB_BUFFER_SMALL))
break;
}
return (ret);

View File

@ -0,0 +1,718 @@
diff -U 5 -r db-5.3.21.old/src/dbinc_auto/int_def.in db-5.3.21/src/dbinc_auto/int_def.in
--- db-5.3.21.old/src/dbinc_auto/int_def.in 2012-05-12 01:57:53.000000000 +0800
+++ db-5.3.21/src/dbinc_auto/int_def.in 2016-10-25 22:40:58.000000000 +0800
@@ -1371,10 +1371,11 @@
#define __memp_failchk __memp_failchk@DB_VERSION_UNIQUE_NAME@
#define __memp_bhwrite __memp_bhwrite@DB_VERSION_UNIQUE_NAME@
#define __memp_pgread __memp_pgread@DB_VERSION_UNIQUE_NAME@
#define __memp_pg __memp_pg@DB_VERSION_UNIQUE_NAME@
#define __memp_bhfree __memp_bhfree@DB_VERSION_UNIQUE_NAME@
+#define __memp_bh_clear_dirty __memp_bh_clear_dirty@DB_VERSION_UNIQUE_NAME@
#define __memp_fget_pp __memp_fget_pp@DB_VERSION_UNIQUE_NAME@
#define __memp_fget __memp_fget@DB_VERSION_UNIQUE_NAME@
#define __memp_fcreate_pp __memp_fcreate_pp@DB_VERSION_UNIQUE_NAME@
#define __memp_fcreate __memp_fcreate@DB_VERSION_UNIQUE_NAME@
#define __memp_set_clear_len __memp_set_clear_len@DB_VERSION_UNIQUE_NAME@
@@ -1395,10 +1396,11 @@
#define __memp_fopen __memp_fopen@DB_VERSION_UNIQUE_NAME@
#define __memp_fclose_pp __memp_fclose_pp@DB_VERSION_UNIQUE_NAME@
#define __memp_fclose __memp_fclose@DB_VERSION_UNIQUE_NAME@
#define __memp_mf_discard __memp_mf_discard@DB_VERSION_UNIQUE_NAME@
#define __memp_inmemlist __memp_inmemlist@DB_VERSION_UNIQUE_NAME@
+#define __memp_mf_mark_dead __memp_mf_mark_dead@DB_VERSION_UNIQUE_NAME@
#define __memp_fput_pp __memp_fput_pp@DB_VERSION_UNIQUE_NAME@
#define __memp_fput __memp_fput@DB_VERSION_UNIQUE_NAME@
#define __memp_unpin_buffers __memp_unpin_buffers@DB_VERSION_UNIQUE_NAME@
#define __memp_dirty __memp_dirty@DB_VERSION_UNIQUE_NAME@
#define __memp_shared __memp_shared@DB_VERSION_UNIQUE_NAME@
@@ -1453,10 +1455,11 @@
#define __memp_fsync_pp __memp_fsync_pp@DB_VERSION_UNIQUE_NAME@
#define __memp_fsync __memp_fsync@DB_VERSION_UNIQUE_NAME@
#define __mp_xxx_fh __mp_xxx_fh@DB_VERSION_UNIQUE_NAME@
#define __memp_sync_int __memp_sync_int@DB_VERSION_UNIQUE_NAME@
#define __memp_mf_sync __memp_mf_sync@DB_VERSION_UNIQUE_NAME@
+#define __memp_purge_dead_files __memp_purge_dead_files@DB_VERSION_UNIQUE_NAME@
#define __memp_trickle_pp __memp_trickle_pp@DB_VERSION_UNIQUE_NAME@
#define __mutex_alloc __mutex_alloc@DB_VERSION_UNIQUE_NAME@
#define __mutex_alloc_int __mutex_alloc_int@DB_VERSION_UNIQUE_NAME@
#define __mutex_free __mutex_free@DB_VERSION_UNIQUE_NAME@
#define __mutex_free_int __mutex_free_int@DB_VERSION_UNIQUE_NAME@
diff -U 5 -r db-5.3.21.old/src/dbinc_auto/mp_ext.h db-5.3.21/src/dbinc_auto/mp_ext.h
--- db-5.3.21.old/src/dbinc_auto/mp_ext.h 2012-05-12 01:57:53.000000000 +0800
+++ db-5.3.21/src/dbinc_auto/mp_ext.h 2016-10-25 22:40:58.000000000 +0800
@@ -14,10 +14,11 @@
int __memp_failchk __P((ENV *));
int __memp_bhwrite __P((DB_MPOOL *, DB_MPOOL_HASH *, MPOOLFILE *, BH *, int));
int __memp_pgread __P((DB_MPOOLFILE *, BH *, int));
int __memp_pg __P((DB_MPOOLFILE *, db_pgno_t, void *, int));
int __memp_bhfree __P((DB_MPOOL *, REGINFO *, MPOOLFILE *, DB_MPOOL_HASH *, BH *, u_int32_t));
+void __memp_bh_clear_dirty __P((ENV*, DB_MPOOL_HASH *, BH *));
int __memp_fget_pp __P((DB_MPOOLFILE *, db_pgno_t *, DB_TXN *, u_int32_t, void *));
int __memp_fget __P((DB_MPOOLFILE *, db_pgno_t *, DB_THREAD_INFO *, DB_TXN *, u_int32_t, void *));
int __memp_fcreate_pp __P((DB_ENV *, DB_MPOOLFILE **, u_int32_t));
int __memp_fcreate __P((ENV *, DB_MPOOLFILE **));
int __memp_set_clear_len __P((DB_MPOOLFILE *, u_int32_t));
@@ -38,10 +39,11 @@
int __memp_fopen __P((DB_MPOOLFILE *, MPOOLFILE *, const char *, const char **, u_int32_t, int, size_t));
int __memp_fclose_pp __P((DB_MPOOLFILE *, u_int32_t));
int __memp_fclose __P((DB_MPOOLFILE *, u_int32_t));
int __memp_mf_discard __P((DB_MPOOL *, MPOOLFILE *, int));
int __memp_inmemlist __P((ENV *, char ***, int *));
+void __memp_mf_mark_dead __P((DB_MPOOL *, MPOOLFILE *, int*));
int __memp_fput_pp __P((DB_MPOOLFILE *, void *, DB_CACHE_PRIORITY, u_int32_t));
int __memp_fput __P((DB_MPOOLFILE *, DB_THREAD_INFO *, void *, DB_CACHE_PRIORITY));
int __memp_unpin_buffers __P((ENV *, DB_THREAD_INFO *));
int __memp_dirty __P((DB_MPOOLFILE *, void *, DB_THREAD_INFO *, DB_TXN *, DB_CACHE_PRIORITY, u_int32_t));
int __memp_shared __P((DB_MPOOLFILE *, void *));
@@ -96,10 +98,11 @@
int __memp_fsync_pp __P((DB_MPOOLFILE *));
int __memp_fsync __P((DB_MPOOLFILE *));
int __mp_xxx_fh __P((DB_MPOOLFILE *, DB_FH **));
int __memp_sync_int __P((ENV *, DB_MPOOLFILE *, u_int32_t, u_int32_t, u_int32_t *, int *));
int __memp_mf_sync __P((DB_MPOOL *, MPOOLFILE *, int));
+int __memp_purge_dead_files __P((ENV *));
int __memp_trickle_pp __P((DB_ENV *, int, int *));
#if defined(__cplusplus)
}
#endif
diff -U 5 -r db-5.3.21.old/src/mp/mp_bh.c db-5.3.21/src/mp/mp_bh.c
--- db-5.3.21.old/src/mp/mp_bh.c 2012-05-12 01:57:53.000000000 +0800
+++ db-5.3.21/src/mp/mp_bh.c 2016-10-25 17:09:35.000000000 +0800
@@ -472,15 +472,12 @@
* a shared latch.
*/
if (F_ISSET(bhp, BH_DIRTY | BH_TRASH)) {
MUTEX_LOCK(env, hp->mtx_hash);
DB_ASSERT(env, !SH_CHAIN_HASNEXT(bhp, vc));
- if (ret == 0 && F_ISSET(bhp, BH_DIRTY)) {
- F_CLR(bhp, BH_DIRTY | BH_DIRTY_CREATE);
- DB_ASSERT(env, atomic_read(&hp->hash_page_dirty) > 0);
- atomic_dec(env, &hp->hash_page_dirty);
- }
+ if (ret == 0)
+ __memp_bh_clear_dirty(env, hp, bhp);
/* put the page back if necessary. */
if ((ret != 0 || BH_REFCOUNT(bhp) > 1) &&
F_ISSET(bhp, BH_TRASH)) {
ret = __memp_pg(dbmfp, bhp->pgno, bhp->buf, 1);
@@ -686,5 +683,31 @@
} else
MUTEX_UNLOCK(env, mfp->mutex);
return (ret);
}
+
+/*
+ * __memp_bh_clear_dirty --
+ * Clear the dirty flag of of a buffer. Calls on the same buffer must be
+ * serialized to get the accounting correct. This can be achieved by
+ * acquiring an exclusive lock on the buffer, a shared lock on the
+ * buffer plus an exclusive lock on the hash bucket, or some other
+ * mechanism that guarantees single-thread access to the entire region
+ * (e.g. during __memp_region_bhfree()).
+ *
+ * PUBLIC: void __memp_bh_clear_dirty __P((ENV*, DB_MPOOL_HASH *, BH *));
+ */
+void
+__memp_bh_clear_dirty(env, hp, bhp)
+ ENV *env;
+ DB_MPOOL_HASH *hp;
+ BH *bhp;
+{
+ COMPQUIET(env, env);
+ if (F_ISSET(bhp, BH_DIRTY)) {
+ F_CLR(bhp, BH_DIRTY | BH_DIRTY_CREATE);
+ DB_ASSERT(env, atomic_read(&hp->hash_page_dirty) > 0);
+ (void)atomic_dec(env, &hp->hash_page_dirty);
+ }
+}
+
diff -U 5 -r db-5.3.21.old/src/mp/mp_fget.c db-5.3.21/src/mp/mp_fget.c
--- db-5.3.21.old/src/mp/mp_fget.c 2012-05-12 01:57:53.000000000 +0800
+++ db-5.3.21/src/mp/mp_fget.c 2016-10-25 17:11:08.000000000 +0800
@@ -437,16 +437,11 @@
* complain and get out.
*/
if (flags == DB_MPOOL_FREE) {
freebuf: MUTEX_LOCK(env, hp->mtx_hash);
h_locked = 1;
- if (F_ISSET(bhp, BH_DIRTY)) {
- F_CLR(bhp, BH_DIRTY | BH_DIRTY_CREATE);
- DB_ASSERT(env,
- atomic_read(&hp->hash_page_dirty) > 0);
- atomic_dec(env, &hp->hash_page_dirty);
- }
+ __memp_bh_clear_dirty(env, hp, bhp);
/*
* If the buffer we found is already freed, we're done.
* If the ref count is not 1 then someone may be
* peeking at the buffer. We cannot free it until they
diff -U 5 -r db-5.3.21.old/src/mp/mp_fopen.c db-5.3.21/src/mp/mp_fopen.c
--- db-5.3.21.old/src/mp/mp_fopen.c 2012-05-12 01:57:53.000000000 +0800
+++ db-5.3.21/src/mp/mp_fopen.c 2016-10-25 22:31:05.000000000 +0800
@@ -12,10 +12,11 @@
#include "dbinc/log.h"
#include "dbinc/mp.h"
#include "dbinc/db_page.h"
#include "dbinc/hash.h"
+static int __memp_count_dead_mutex __P((DB_MPOOL *, u_int32_t *));
static int __memp_mpf_alloc __P((DB_MPOOL *,
DB_MPOOLFILE *, const char *, u_int32_t, u_int32_t, MPOOLFILE **));
static int __memp_mpf_find __P((ENV *,
DB_MPOOLFILE *, DB_MPOOL_HASH *, const char *, u_int32_t, MPOOLFILE **));
@@ -709,11 +710,15 @@
* We should be able to set mfp to NULL and break out of the
* loop, but I like the idea of checking all the entries.
*/
if (LF_ISSET(DB_TRUNCATE)) {
MUTEX_LOCK(env, mfp->mutex);
- mfp->deadfile = 1;
+ /*
+ * We cannot purge dead files here, because the caller
+ * is holding the mutex of the hash bucket of mfp.
+ */
+ __memp_mf_mark_dead(dbmp, mfp, NULL);
MUTEX_UNLOCK(env, mfp->mutex);
continue;
}
/*
@@ -907,14 +912,15 @@
DB_MPOOL *dbmp;
ENV *env;
MPOOLFILE *mfp;
char *rpath;
u_int32_t ref;
- int deleted, ret, t_ret;
+ int deleted, purge_dead, ret, t_ret;
env = dbmfp->env;
dbmp = env->mp_handle;
+ purge_dead = 0;
ret = 0;
/*
* Remove the DB_MPOOLFILE from the process' list.
*
@@ -1004,11 +1010,11 @@
}
DB_ASSERT(env, mfp->neutral_cnt < mfp->mpf_cnt);
if (--mfp->mpf_cnt == 0 || LF_ISSET(DB_MPOOL_DISCARD)) {
if (LF_ISSET(DB_MPOOL_DISCARD) ||
F_ISSET(mfp, MP_TEMP) || mfp->unlink_on_close) {
- mfp->deadfile = 1;
+ __memp_mf_mark_dead(dbmp, mfp, &purge_dead);
}
if (mfp->unlink_on_close) {
if ((t_ret = __db_appname(dbmp->env, DB_APP_DATA,
R_ADDR(dbmp->reginfo, mfp->path_off), NULL,
&rpath)) != 0 && ret == 0)
@@ -1037,10 +1043,12 @@
deleted = 1;
}
}
if (!deleted && !LF_ISSET(DB_MPOOL_NOLOCK))
MUTEX_UNLOCK(env, mfp->mutex);
+ if (purge_dead)
+ (void)__memp_purge_dead_files(env);
done: /* Discard the DB_MPOOLFILE structure. */
if (dbmfp->pgcookie != NULL) {
__os_free(env, dbmfp->pgcookie->data);
__os_free(env, dbmfp->pgcookie);
@@ -1091,11 +1099,11 @@
/*
* We have to release the MPOOLFILE mutex before acquiring the region
* mutex so we don't deadlock. Make sure nobody ever looks at this
* structure again.
*/
- mfp->deadfile = 1;
+ __memp_mf_mark_dead(dbmp, mfp, NULL);
/* Discard the mutex we're holding and return it too the pool. */
MUTEX_UNLOCK(env, mfp->mutex);
if ((t_ret = __mutex_free(env, &mfp->mutex)) != 0 && ret == 0)
ret = t_ret;
@@ -1216,5 +1224,106 @@
/* Make sure we don't return any garbage. */
*cntp = 0;
*namesp = NULL;
return (ret);
}
+
+/*
+ * __memp_mf_mark_dead --
+ * Mark an MPOOLFILE as dead because its contents are no longer necessary.
+ * This happens when removing, truncation, or closing an unnamed in-memory
+ * database. Return, in the purgep parameter, whether the caller should
+ * call __memp_purge_dead_files() after the lock on mfp is released. The
+ * caller must hold an exclusive lock on the mfp handle.
+ *
+ * PUBLIC: void __memp_mf_mark_dead __P((DB_MPOOL *, MPOOLFILE *, int*));
+ */
+void
+__memp_mf_mark_dead(dbmp, mfp, purgep)
+ DB_MPOOL *dbmp;
+ MPOOLFILE *mfp;
+ int *purgep;
+{
+ ENV *env;
+#ifdef HAVE_MUTEX_SUPPORT
+ REGINFO *infop;
+ DB_MUTEXREGION *mtxregion;
+ u_int32_t mutex_max, mutex_inuse, dead_mutex;
+#endif
+
+ if (purgep != NULL)
+ *purgep = 0;
+
+ env = dbmp->env;
+
+#ifdef HAVE_MUTEX_SUPPORT
+ MUTEX_REQUIRED(env, mfp->mutex);
+
+ if (MUTEX_ON(env) && mfp->deadfile == 0) {
+ infop = &env->mutex_handle->reginfo;
+ mtxregion = infop->primary;
+
+ mutex_inuse = mtxregion->stat.st_mutex_inuse;
+ if ((mutex_max = env->dbenv->mutex_max) == 0)
+ mutex_max = infop->rp->max / mtxregion->mutex_size;
+
+ /*
+ * Purging dead pages requires a full scan of the entire cache
+ * buffer, so it is a slow operation. We only want to do it
+ * when it is necessary and provides enough benefits. Below is
+ * a simple heuristic that determines when to purge all dead
+ * pages.
+ */
+ if (purgep != NULL && mutex_inuse > mutex_max - 200) {
+ /*
+ * If the mutex region is almost full and there are
+ * many mutexes held by dead files, purge dead files.
+ */
+ (void)__memp_count_dead_mutex(dbmp, &dead_mutex);
+ dead_mutex += mfp->block_cnt + 1;
+
+ if (dead_mutex > mutex_inuse / 20)
+ *purgep = 1;
+ }
+ }
+#endif
+
+ mfp->deadfile = 1;
+}
+
+/*
+ * __memp_count_dead_mutex --
+ * Estimate the number of mutexes held by dead files.
+ */
+static int
+__memp_count_dead_mutex(dbmp, dead_mutex)
+ DB_MPOOL *dbmp;
+ u_int32_t *dead_mutex;
+{
+ ENV *env;
+ DB_MPOOL_HASH *hp;
+ MPOOL *mp;
+ MPOOLFILE *mfp;
+ u_int32_t mutex_per_file;
+ int busy, i;
+
+ env = dbmp->env;
+ *dead_mutex = 0;
+ mutex_per_file = 1;
+#ifndef HAVE_ATOMICFILEREAD
+ mutex_per_file = 2;
+#endif
+ mp = dbmp->reginfo[0].primary;
+ hp = R_ADDR(dbmp->reginfo, mp->ftab);
+ for (i = 0; i < MPOOL_FILE_BUCKETS; i++, hp++) {
+ busy = MUTEX_TRYLOCK(env, hp->mtx_hash);
+ if (busy)
+ continue;
+ SH_TAILQ_FOREACH(mfp, &hp->hash_bucket, q, __mpoolfile) {
+ if (mfp->deadfile)
+ *dead_mutex += mfp->block_cnt + mutex_per_file;
+ }
+ MUTEX_UNLOCK(env, hp->mtx_hash);
+ }
+
+ return (0);
+}
diff -U 5 -r db-5.3.21.old/src/mp/mp_method.c db-5.3.21/src/mp/mp_method.c
--- db-5.3.21.old/src/mp/mp_method.c 2012-05-12 01:57:53.000000000 +0800
+++ db-5.3.21/src/mp/mp_method.c 2016-10-25 17:22:23.000000000 +0800
@@ -638,11 +638,11 @@
DB_MPOOL_HASH *hp, *nhp;
MPOOL *mp;
MPOOLFILE *mfp;
roff_t newname_off;
u_int32_t bucket;
- int locked, ret;
+ int locked, purge_dead, ret;
size_t nlen;
void *p;
#undef op_is_remove
#define op_is_remove (newname == NULL)
@@ -655,10 +655,11 @@
dbmp = NULL;
mfp = NULL;
nhp = NULL;
p = NULL;
locked = ret = 0;
+ purge_dead = 0;
if (!MPOOL_ON(env))
goto fsop;
dbmp = env->mp_handle;
@@ -747,11 +748,11 @@
* they do not get reclaimed as long as they exist. Since we
* are now deleting the database, we need to dec that count.
*/
if (mfp->no_backing_file)
mfp->mpf_cnt--;
- mfp->deadfile = 1;
+ __memp_mf_mark_dead(dbmp, mfp, &purge_dead);
MUTEX_UNLOCK(env, mfp->mutex);
} else {
/*
* Else, it's a rename. We've allocated memory for the new
* name. Swap it with the old one. If it's in memory we
@@ -806,10 +807,16 @@
if (locked == 1) {
MUTEX_UNLOCK(env, hp->mtx_hash);
if (nhp != NULL && nhp != hp)
MUTEX_UNLOCK(env, nhp->mtx_hash);
}
+ /*
+ * __memp_purge_dead_files() must be called when the hash bucket is
+ * unlocked.
+ */
+ if (purge_dead)
+ (void)__memp_purge_dead_files(env);
return (ret);
}
/*
* __memp_ftruncate __
diff -U 5 -r db-5.3.21.old/src/mp/mp_sync.c db-5.3.21/src/mp/mp_sync.c
--- db-5.3.21.old/src/mp/mp_sync.c 2012-05-12 01:57:53.000000000 +0800
+++ db-5.3.21/src/mp/mp_sync.c 2016-10-25 17:26:58.000000000 +0800
@@ -24,10 +24,11 @@
static int __bhcmp __P((const void *, const void *));
static int __memp_close_flush_files __P((ENV *, int));
static int __memp_sync_files __P((ENV *));
static int __memp_sync_file __P((ENV *,
MPOOLFILE *, void *, u_int32_t *, u_int32_t));
+static inline void __update_err_ret(int, int*);
/*
* __memp_walk_files --
* PUBLIC: int __memp_walk_files __P((ENV *, MPOOL *,
* PUBLIC: int (*) __P((ENV *, MPOOLFILE *, void *,
@@ -961,5 +962,125 @@
return (-1);
if (bhp1->track_pgno > bhp2->track_pgno)
return (1);
return (0);
}
+
+/*
+ * __memp_purge_dead_files --
+ * Remove all dead files and their buffers from the mpool. The caller
+ * cannot hold any lock on the dead MPOOLFILE handles, their buffers
+ * or their hash buckets.
+ *
+ * PUBLIC: int __memp_purge_dead_files __P((ENV *));
+ */
+int
+__memp_purge_dead_files(env)
+ ENV *env;
+{
+ BH *bhp;
+ DB_MPOOL *dbmp;
+ DB_MPOOL_HASH *hp, *hp_end;
+ REGINFO *infop;
+ MPOOL *c_mp, *mp;
+ MPOOLFILE *mfp;
+ u_int32_t i_cache;
+ int ret, t_ret, h_lock;
+
+ if (!MPOOL_ON(env))
+ return (0);
+
+ dbmp = env->mp_handle;
+ mp = dbmp->reginfo[0].primary;
+ ret = t_ret = h_lock = 0;
+
+ /*
+ * Walk each cache's list of buffers and free all buffers whose
+ * MPOOLFILE is marked as dead.
+ */
+ for (i_cache = 0; i_cache < mp->nreg; i_cache++) {
+ infop = &dbmp->reginfo[i_cache];
+ c_mp = infop->primary;
+
+ hp = R_ADDR(infop, c_mp->htab);
+ hp_end = &hp[c_mp->htab_buckets];
+ for (; hp < hp_end; hp++) {
+ /* Skip empty buckets. */
+ if (SH_TAILQ_FIRST(&hp->hash_bucket, __bh) == NULL)
+ continue;
+
+ /*
+ * Search for a dead buffer. Other places that call
+ * __memp_bhfree() acquire the buffer lock before the
+ * hash bucket lock. Even though we acquire the two
+ * locks in reverse order, we cannot deadlock here
+ * because we don't block waiting for the locks.
+ */
+ t_ret = MUTEX_TRYLOCK(env, hp->mtx_hash);
+ if (t_ret != 0) {
+ __update_err_ret(t_ret, &ret);
+ continue;
+ }
+ h_lock = 1;
+ SH_TAILQ_FOREACH(bhp, &hp->hash_bucket, hq, __bh) {
+ /* Skip buffers that are being used. */
+ if (BH_REFCOUNT(bhp) > 0)
+ continue;
+
+ mfp = R_ADDR(dbmp->reginfo, bhp->mf_offset);
+ if (!mfp->deadfile)
+ continue;
+
+ /* Found a dead buffer. Prepare to free it. */
+ t_ret = MUTEX_TRYLOCK(env, bhp->mtx_buf);
+ if (t_ret != 0) {
+ __update_err_ret(t_ret, &ret);
+ continue;
+ }
+
+ DB_ASSERT(env, (!F_ISSET(bhp, BH_EXCLUSIVE) &&
+ BH_REFCOUNT(bhp) == 0));
+ F_SET(bhp, BH_EXCLUSIVE);
+ (void)atomic_inc(env, &bhp->ref);
+
+ __memp_bh_clear_dirty(env, hp, bhp);
+
+ /*
+ * Free the buffer. The buffer and hash bucket
+ * are unlocked by __memp_bhfree.
+ */
+ if ((t_ret = __memp_bhfree(dbmp, infop, mfp,
+ hp, bhp, BH_FREE_FREEMEM)) == 0)
+ /*
+ * Decrement hp, so the next turn will
+ * search the same bucket again.
+ */
+ hp--;
+ else
+ __update_err_ret(t_ret, &ret);
+
+ /*
+ * The hash bucket is unlocked, we need to
+ * start over again.
+ */
+ h_lock = 0;
+ break;
+ }
+
+ if (h_lock) {
+ MUTEX_UNLOCK(env, hp->mtx_hash);
+ h_lock = 0;
+ }
+ }
+ }
+
+ return (ret);
+}
+
+static inline void
+__update_err_ret(t_ret, retp)
+ int t_ret;
+ int *retp;
+{
+ if (t_ret != 0 && t_ret != DB_LOCK_NOTGRANTED && *retp == 0)
+ *retp = t_ret;
+}
diff -U 5 -r db-5.3.21.old/src/mp/mp_trickle.c db-5.3.21/src/mp/mp_trickle.c
--- db-5.3.21.old/src/mp/mp_trickle.c 2012-05-12 01:57:53.000000000 +0800
+++ db-5.3.21/src/mp/mp_trickle.c 2016-10-25 17:27:57.000000000 +0800
@@ -65,10 +65,14 @@
"DB_ENV->memp_trickle: %d: percent must be between 1 and 100",
"%d"), pct);
return (EINVAL);
}
+ /* First we purge all dead files and their buffers. */
+ if ((ret = __memp_purge_dead_files(env)) != 0)
+ return (ret);
+
/*
* Loop through the caches counting total/dirty buffers.
*
* XXX
* Using hash_page_dirty is our only choice at the moment, but it's not
diff -U 5 -r db-5.3.21.old/src/mutex/mut_region.c db-5.3.21/src/mutex/mut_region.c
--- db-5.3.21.old/src/mutex/mut_region.c 2012-05-12 01:57:54.000000000 +0800
+++ db-5.3.21/src/mutex/mut_region.c 2016-10-25 17:34:22.000000000 +0800
@@ -15,11 +15,11 @@
#include "dbinc/txn.h"
static db_size_t __mutex_align_size __P((ENV *));
static int __mutex_region_init __P((ENV *, DB_MUTEXMGR *));
static size_t __mutex_region_size __P((ENV *));
-static size_t __mutex_region_max __P((ENV *));
+static size_t __mutex_region_max __P((ENV *, u_int32_t));
/*
* __mutex_open --
* Open a mutex region.
*
@@ -32,11 +32,11 @@
{
DB_ENV *dbenv;
DB_MUTEXMGR *mtxmgr;
DB_MUTEXREGION *mtxregion;
size_t size;
- u_int32_t cpu_count;
+ u_int32_t cpu_count, mutex_needed;
int ret;
#ifndef HAVE_ATOMIC_SUPPORT
u_int i;
#endif
@@ -59,23 +59,24 @@
cpu_count : cpu_count * MUTEX_SPINS_PER_PROCESSOR)) != 0)
return (ret);
}
/*
- * If the user didn't set an absolute value on the number of mutexes
- * we'll need, figure it out. We're conservative in our allocation,
- * we need mutexes for DB handles, group-commit queues and other things
- * applications allocate at run-time. The application may have kicked
- * up our count to allocate its own mutexes, add that in.
+ * Figure out the number of mutexes we'll need. We're conservative in
+ * our allocation, we need mutexes for DB handles, group-commit queues
+ * and other things applications allocate at run-time. The application
+ * may have kicked up our count to allocate its own mutexes, add that
+ * in.
*/
+ mutex_needed =
+ __lock_region_mutex_count(env) +
+ __log_region_mutex_count(env) +
+ __memp_region_mutex_count(env) +
+ __txn_region_mutex_count(env);
if (dbenv->mutex_cnt == 0 &&
F_ISSET(env, ENV_PRIVATE | ENV_THREAD) != ENV_PRIVATE)
- dbenv->mutex_cnt =
- __lock_region_mutex_count(env) +
- __log_region_mutex_count(env) +
- __memp_region_mutex_count(env) +
- __txn_region_mutex_count(env);
+ dbenv->mutex_cnt = mutex_needed;
if (dbenv->mutex_max != 0 && dbenv->mutex_cnt > dbenv->mutex_max)
dbenv->mutex_cnt = dbenv->mutex_max;
/* Create/initialize the mutex manager structure. */
@@ -88,12 +89,12 @@
mtxmgr->reginfo.id = INVALID_REGION_ID;
mtxmgr->reginfo.flags = REGION_JOIN_OK;
size = __mutex_region_size(env);
if (create_ok)
F_SET(&mtxmgr->reginfo, REGION_CREATE_OK);
- if ((ret = __env_region_attach(env,
- &mtxmgr->reginfo, size, size + __mutex_region_max(env))) != 0)
+ if ((ret = __env_region_attach(env, &mtxmgr->reginfo,
+ size, size + __mutex_region_max(env, mutex_needed))) != 0)
goto err;
/* If we created the region, initialize it. */
if (F_ISSET(&mtxmgr->reginfo, REGION_CREATE))
if ((ret = __mutex_region_init(env, mtxmgr)) != 0)
@@ -350,44 +351,62 @@
dbenv = env->dbenv;
s = sizeof(DB_MUTEXMGR) + 1024;
- /* We discard one mutex for the OOB slot. */
+ /*
+ * We discard one mutex for the OOB slot. Make sure mutex_cnt doesn't
+ * overflow.
+ */
s += __env_alloc_size(
- (dbenv->mutex_cnt + 1) *__mutex_align_size(env));
+ (dbenv->mutex_cnt + (dbenv->mutex_cnt == UINT32_MAX ? 0 : 1)) *
+ __mutex_align_size(env));
return (s);
}
/*
* __mutex_region_max --
* Return the amount of space needed to reach the maximum size.
*/
static size_t
-__mutex_region_max(env)
+__mutex_region_max(env, mutex_needed)
ENV *env;
+ u_int32_t mutex_needed;
{
DB_ENV *dbenv;
- u_int32_t max;
+ u_int32_t max, mutex_cnt;
dbenv = env->dbenv;
+ mutex_cnt = dbenv->mutex_cnt;
- if ((max = dbenv->mutex_max) == 0) {
+ /*
+ * We want to limit the region size to accommodate at most UINT32_MAX
+ * mutexes. If mutex_cnt is UINT32_MAX, no more space is allowed.
+ */
+ if ((max = dbenv->mutex_max) == 0 && mutex_cnt != UINT32_MAX)
if (F_ISSET(env, ENV_PRIVATE | ENV_THREAD) == ENV_PRIVATE)
- max = dbenv->mutex_inc + 1;
- else
+ if (dbenv->mutex_inc + 1 < UINT32_MAX - mutex_cnt)
+ max = dbenv->mutex_inc + 1 + mutex_cnt;
+ else
+ max = UINT32_MAX;
+ else {
max = __lock_region_mutex_max(env) +
__txn_region_mutex_max(env) +
__log_region_mutex_max(env) +
dbenv->mutex_inc + 100;
- } else if (max <= dbenv->mutex_cnt)
+ if (max < UINT32_MAX - mutex_needed)
+ max += mutex_needed;
+ else
+ max = UINT32_MAX;
+ }
+
+ if (max <= mutex_cnt)
return (0);
else
- max -= dbenv->mutex_cnt;
-
- return ( __env_alloc_size(max * __mutex_align_size(env)));
+ return (__env_alloc_size(
+ (max - mutex_cnt) * __mutex_align_size(env)));
}
#ifdef HAVE_MUTEX_SYSTEM_RESOURCES
/*
* __mutex_resource_return

View File

@ -0,0 +1,20 @@
--- db-5.3.28/lang/sql/sqlite/tool/lemon.c.lemon_hash 2013-09-09 17:35:07.000000000 +0200
+++ db-5.3.28/lang/sql/sqlite/tool/lemon.c 2017-02-22 13:12:08.564106051 +0100
@@ -3428,7 +3428,7 @@
int maxdtlength; /* Maximum length of any ".datatype" field. */
char *stddt; /* Standardized name for a datatype */
int i,j; /* Loop counters */
- int hash; /* For hashing the name of a type */
+ unsigned hash; /* For hashing the name of a type */
const char *name; /* Name of the parser */
/* Allocate and initialize types[] and allocate stddt[] */
@@ -3491,7 +3491,7 @@
break;
}
hash++;
- if( hash>=arraysize ) hash = 0;
+ if( hash>=(unsigned)arraysize ) hash = 0;
}
if( types[hash]==0 ){
sp->dtnum = hash + 1;

View File

@ -0,0 +1,19 @@
Author: Filip Januš <fjanus@redhat.com>
Date: 6 Sep 2021
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1992402
Patch was created based on the discussion in the previous link
diff -ur db-5.3.28/src/os/os_map.c db_patch/src/os/os_map.c
--- db-5.3.28/src/os/os_map.c 2013-09-09 17:35:09.000000000 +0200
+++ db_patch/src/os/os_map.c 2021-09-09 07:33:12.027328265 +0200
@@ -213,7 +213,10 @@
if (rp->max < rp->size)
rp->max = rp->size;
if (ret == 0 && F_ISSET(infop, REGION_CREATE)) {
- if (F_ISSET(dbenv, DB_ENV_REGION_INIT))
+
+ rp->size = rp->max;
+
+ if (F_ISSET(dbenv, DB_ENV_REGION_INIT))
ret = __db_file_write(env, infop->fhp,
rp->size / MEGABYTE, rp->size % MEGABYTE, 0x00);
else

View File

@ -0,0 +1,694 @@
--- db-18.1.32/src/btree/bt_cursor.c 2019-02-20 03:21:20.000000000 +0530
+++ db-18.1.40/src/btree/bt_cursor.c 2020-05-29 23:28:22.000000000 +0530
@@ -282,6 +282,8 @@
*
* Recno uses the btree bt_ovflsize value -- it's close enough.
*/
+ if (t->bt_minkey == 0)
+ return (DB_RECOVER);
cp->ovflsize = B_MINKEY_TO_OVFLSIZE(
dbp, F_ISSET(dbc, DBC_OPD) ? 2 : t->bt_minkey, dbp->pgsize);
--- db-18.1.32/src/btree/bt_verify.c 2019-02-20 03:21:20.000000000 +0530
+++ db-18.1.40/src/btree/bt_verify.c 2020-05-29 23:28:22.000000000 +0530
@@ -700,7 +700,11 @@
isbad = 1;
goto err;
default:
+ if (ret == 0) {
+ isbad = 1;
+ ret = DB_VERIFY_FATAL;
+ goto err;
+ }
- DB_ASSERT(env, ret != 0);
break;
}
@@ -1074,7 +1078,7 @@
DBT dbta, dbtb, dup_1, dup_2, *p1, *p2, *tmp;
ENV *env;
PAGE *child;
+ db_pgno_t cpgno, grandparent;
- db_pgno_t cpgno;
VRFY_PAGEINFO *pip;
db_indx_t i, *inp;
int adj, cmp, freedup_1, freedup_2, isbad, ret, t_ret;
@@ -1106,7 +1110,8 @@
buf1 = buf2 = NULL;
+ if (LF_ISSET(DB_NOORDERCHK))
+ return (EINVAL);
- DB_ASSERT(env, !LF_ISSET(DB_NOORDERCHK));
dupfunc = (dbp->dup_compare == NULL) ? __bam_defcmp : dbp->dup_compare;
if (TYPE(h) == P_LDUP)
@@ -1115,6 +1120,7 @@
func = __bam_defcmp;
if (dbp->bt_internal != NULL) {
bt = (BTREE *)dbp->bt_internal;
+ grandparent = bt->bt_root;
if (TYPE(h) == P_IBTREE && (bt->bt_compare != NULL ||
dupfunc != __bam_defcmp)) {
/*
@@ -974,8 +980,24 @@
*/
mpf = dbp->mpf;
child = h;
+ cpgno = pgno;
while (TYPE(child) == P_IBTREE) {
+ if (NUM_ENT(child) == 0) {
+ EPRINT((env, DB_STR_A("1088",
+ "Page %lu: internal page is empty and should not be",
+ "%lu"), (u_long)cpgno));
+ ret = DB_VERIFY_BAD;
+ goto err;
+ }
bi = GET_BINTERNAL(dbp, child, 0);
+ if (grandparent == bi->pgno) {
+ EPRINT((env, DB_STR_A("5552",
+ "Page %lu: found twice in the btree",
+ "%lu"), (u_long)grandparent));
+ ret = DB_VERIFY_FATAL;
+ goto err;
+ } else
+ grandparent = cpgno;
cpgno = bi->pgno;
if (child != h &&
(ret = __memp_fput(mpf,
@@ -1402,7 +1416,10 @@
*/
if (dup_1.data == NULL ||
dup_2.data == NULL) {
+ if (ovflok) {
+ isbad = 1;
+ goto err;
+ }
- DB_ASSERT(env, !ovflok);
if (pip != NULL)
F_SET(pip,
VRFY_INCOMPLETE);
@@ -1747,9 +1764,10 @@
(ret = __db_vrfy_ovfl_structure(dbp, vdp,
child->pgno, child->tlen,
flags | DB_ST_OVFL_LEAF)) != 0) {
+ if (ret == DB_VERIFY_BAD) {
- if (ret == DB_VERIFY_BAD)
isbad = 1;
+ break;
+ } else
- else
goto done;
}
@@ -1823,9 +1841,10 @@
stflags | DB_ST_TOPLEVEL,
NULL, NULL, NULL)) != 0) {
if (ret ==
+ DB_VERIFY_BAD) {
- DB_VERIFY_BAD)
isbad = 1;
+ break;
+ } else
- else
goto err;
}
}
@@ -1969,7 +1988,10 @@
*/
/* Otherwise, __db_vrfy_childput would be broken. */
+ if (child->refcnt < 1) {
+ isbad = 1;
+ goto err;
+ }
- DB_ASSERT(env, child->refcnt >= 1);
/*
* An overflow referenced more than twice here
@@ -1986,9 +2008,10 @@
if ((ret = __db_vrfy_ovfl_structure(dbp,
vdp, child->pgno, child->tlen,
flags)) != 0) {
+ if (ret == DB_VERIFY_BAD) {
- if (ret == DB_VERIFY_BAD)
isbad = 1;
+ break;
+ } else
- else
goto done;
}
}
@@ -2026,9 +2049,10 @@
if ((ret = __bam_vrfy_subtree(dbp, vdp, li->pgno,
i == 0 ? NULL : li, ri, flags, &child_level,
&child_nrecs, NULL)) != 0) {
+ if (ret == DB_VERIFY_BAD) {
- if (ret == DB_VERIFY_BAD)
isbad = 1;
+ break;
+ } else
- else
goto done;
}
@@ -2929,7 +2953,11 @@
db_pgno_t current, p;
int err_ret, ret;
+ if (pgset == NULL) {
+ EPRINT((dbp->env, DB_STR("5542",
+ "Error, database contains no visible pages.")));
+ return (DB_RUNRECOVERY);
+ }
- DB_ASSERT(dbp->env, pgset != NULL);
mpf = dbp->mpf;
h = NULL;
--- db-18.1.32/src/db/db_conv.c 2019-02-20 03:21:20.000000000 +0530
+++ db-18.1.40/src/db/db_conv.c 2020-05-29 23:28:22.000000000 +0530
@@ -493,8 +493,11 @@
db_indx_t i, *inp, len, tmp;
u_int8_t *end, *p, *pgend;
- if (pagesize == 0)
- return (0);
+ /* This function is also used to byteswap logs, so
+ * the pagesize might not be an actual page size.
+ */
+ if (!(pagesize >= 24 && pagesize <= DB_MAX_PGSIZE))
+ return (EINVAL);
if (pgin) {
M_32_SWAP(h->lsn.file);
@@ -513,26 +516,41 @@
pgend = (u_int8_t *)h + pagesize;
inp = P_INP(dbp, h);
- if ((u_int8_t *)inp >= pgend)
- goto out;
+ if ((u_int8_t *)inp > pgend)
+ return (__db_pgfmt(env, pg));
switch (TYPE(h)) {
case P_HASH_UNSORTED:
case P_HASH:
for (i = 0; i < NUM_ENT(h); i++) {
+ if ((u_int8_t*)(inp + i) >= pgend)
+ return (__db_pgfmt(env, pg));
+ if (inp[i] == 0)
+ continue;
if (pgin)
M_16_SWAP(inp[i]);
+ if (inp[i] >= pagesize)
+ return (__db_pgfmt(env, pg));
- if (P_ENTRY(dbp, h, i) >= pgend)
- continue;
+ if (P_ENTRY(dbp, h, i) >= pgend)
+ return (__db_pgfmt(env, pg));
switch (HPAGE_TYPE(dbp, h, i)) {
case H_KEYDATA:
break;
case H_DUPLICATE:
+ if (LEN_HITEM(dbp, h, pagesize, i) <
+ HKEYDATA_SIZE(0))
+ return (__db_pgfmt(env, pg));
+
len = LEN_HKEYDATA(dbp, h, pagesize, i);
p = HKEYDATA_DATA(P_ENTRY(dbp, h, i));
- for (end = p + len; p < end;) {
+
+ end = p + len;
+ if (end > pgend)
+ return (__db_pgfmt(env, pg));
+
+ while (p < end) {
if (pgin) {
P_16_SWAP(p);
memcpy(&tmp,
@@ -544,14 +562,20 @@
SWAP16(p);
}
p += tmp;
+ if (p >= end)
+ return (__db_pgfmt(env, pg));
SWAP16(p);
}
break;
case H_OFFDUP:
+ if ((inp[i] + HOFFDUP_SIZE) > pagesize)
+ return (__db_pgfmt(env, pg));
p = HOFFPAGE_PGNO(P_ENTRY(dbp, h, i));
SWAP32(p); /* pgno */
break;
case H_OFFPAGE:
+ if ((inp[i] + HOFFPAGE_SIZE) > pagesize)
+ return (__db_pgfmt(env, pg));
p = HOFFPAGE_PGNO(P_ENTRY(dbp, h, i));
SWAP32(p); /* pgno */
SWAP32(p); /* tlen */
@@ -559,7 +583,6 @@
default:
return (__db_pgfmt(env, pg));
}
-
}
/*
@@ -576,8 +599,12 @@
case P_LDUP:
case P_LRECNO:
for (i = 0; i < NUM_ENT(h); i++) {
+ if ((u_int8_t *)(inp + i) >= pgend)
+ return (__db_pgfmt(env, pg));
if (pgin)
M_16_SWAP(inp[i]);
+ if (inp[i] >= pagesize)
+ return (__db_pgfmt(env, pg));
/*
* In the case of on-page duplicates, key information
@@ -597,7 +624,7 @@
bk = GET_BKEYDATA(dbp, h, i);
if ((u_int8_t *)bk >= pgend)
- continue;
+ return (__db_pgfmt(env, pg));
switch (B_TYPE(bk->type)) {
case B_KEYDATA:
M_16_SWAP(bk->len);
@@ -605,6 +632,8 @@
case B_DUPLICATE:
case B_OVERFLOW:
bo = (BOVERFLOW *)bk;
+ if (((u_int8_t *)bo + BOVERFLOW_SIZE) > pgend)
+ return (__db_pgfmt(env, pg));
M_32_SWAP(bo->pgno);
M_32_SWAP(bo->tlen);
break;
@@ -618,12 +647,17 @@
break;
case P_IBTREE:
for (i = 0; i < NUM_ENT(h); i++) {
+ if ((u_int8_t *)(inp + i) > pgend)
+ return (__db_pgfmt(env, pg));
if (pgin)
M_16_SWAP(inp[i]);
+ if ((u_int16_t)(inp[i] +
+ BINTERNAL_SIZE(0) - 1) > pagesize)
+ break;
bi = GET_BINTERNAL(dbp, h, i);
- if ((u_int8_t *)bi >= pgend)
- continue;
+ if (((u_int8_t *)bi + BINTERNAL_SIZE(0)) > pgend)
+ return (__db_pgfmt(env, pg));
M_16_SWAP(bi->len);
M_32_SWAP(bi->pgno);
@@ -634,6 +668,10 @@
break;
case B_DUPLICATE:
case B_OVERFLOW:
+ if ((u_int16_t)(inp[i] +
+ BINTERNAL_SIZE(BOVERFLOW_SIZE) - 1) >
+ pagesize)
+ goto out;
bo = (BOVERFLOW *)bi->data;
M_32_SWAP(bo->pgno);
M_32_SWAP(bo->tlen);
@@ -648,12 +686,16 @@
break;
case P_IRECNO:
for (i = 0; i < NUM_ENT(h); i++) {
+ if ((u_int8_t *)(inp + i) >= pgend)
+ return (__db_pgfmt(env, pg));
if (pgin)
M_16_SWAP(inp[i]);
+ if (inp[i] >= pagesize)
+ return (__db_pgfmt(env, pg));
ri = GET_RINTERNAL(dbp, h, i);
- if ((u_int8_t *)ri >= pgend)
- continue;
+ if ((((u_int8_t *)ri) + RINTERNAL_SIZE) > pgend)
+ return (__db_pgfmt(env, pg));
M_32_SWAP(ri->pgno);
M_32_SWAP(ri->nrecs);
--- db-18.1.32/src/db/db_vrfy.c 2019-02-20 03:21:20.000000000 +0530
+++ db-18.1.40/src/db/db_vrfy.c 2020-05-29 23:28:22.000000000 +0530
@@ -381,8 +381,10 @@
vdp, name, 0, lp, rp, flags)) != 0) {
if (t_ret == DB_VERIFY_BAD)
isbad = 1;
+ else {
+ ret = t_ret;
+ goto err;
+ }
- else
- goto err;
}
/*
@@ -771,9 +773,10 @@
*/
if ((t_ret = __memp_fget(mpf, &i,
vdp->thread_info, NULL, 0, &h)) != 0) {
+ if ((dbp->type == DB_HASH ||
- if (dbp->type == DB_HASH ||
(dbp->type == DB_QUEUE &&
+ F_ISSET(dbp, DB_AM_INMEM))) &&
+ t_ret != DB_RUNRECOVERY) {
- F_ISSET(dbp, DB_AM_INMEM))) {
if ((t_ret =
__db_vrfy_getpageinfo(vdp, i, &pip)) != 0)
goto err1;
@@ -945,6 +948,8 @@
return (ret == 0 ? t_ret : ret);
}
+ if (ret == DB_PAGE_NOTFOUND && isbad == 1)
+ ret = 0;
return ((isbad == 1 && ret == 0) ? DB_VERIFY_BAD : ret);
}
@@ -1581,7 +1586,7 @@
if (pgno == PGNO_BASE_MD &&
dbtype != DB_QUEUE && meta->last_pgno != vdp->last_pgno) {
#ifdef HAVE_FTRUNCATE
+ ret = DB_VERIFY_FATAL;
- isbad = 1;
EPRINT((env, DB_STR_A("0552",
"Page %lu: last_pgno is not correct: %lu != %lu",
"%lu %lu %lu"), (u_long)pgno,
@@ -1622,7 +1627,11 @@
env = dbp->env;
pgset = vdp->pgset;
+ if (pgset == NULL) {
+ EPRINT((env, DB_STR("5543",
+ "Error, database contains no visible pages.")));
+ return (DB_RUNRECOVERY);
+ }
- DB_ASSERT(env, pgset != NULL);
if ((ret = __db_vrfy_getpageinfo(vdp, meta, &pip)) != 0)
return (ret);
@@ -2014,7 +2023,8 @@
int keyflag, ret, t_ret;
env = dbp->env;
+ if (!LF_ISSET(DB_SALVAGE))
+ return (EINVAL);
- DB_ASSERT(env, LF_ISSET(DB_SALVAGE));
/*
* !!!
@@ -2126,10 +2136,8 @@
int (*callback) __P((void *, const void *));
u_int32_t flags;
{
- ENV *env;
-
- env = dbp->env;
- DB_ASSERT(env, LF_ISSET(DB_SALVAGE));
+ if (!LF_ISSET(DB_SALVAGE))
+ return (EINVAL);
/* If we got this page in the subdb pass, we can safely skip it. */
if (__db_salvage_isdone(vdp, pgno))
@@ -2242,8 +2253,8 @@
ret = t_ret;
break;
case SALVAGE_OVERFLOW:
+ EPRINT((env, DB_STR("5544", "Invalid page type to salvage.")));
+ return (EINVAL);
- DB_ASSERT(env, 0); /* Shouldn't ever happen. */
- break;
case SALVAGE_HASH:
if ((t_ret = __ham_salvage(dbp, vdp,
pgno, h, handle, callback, flags)) != 0 && ret == 0)
@@ -2256,8 +2267,8 @@
* Shouldn't happen, but if it does, just do what the
* nice man says.
*/
+ EPRINT((env, DB_STR("5545", "Invalid page type to salvage.")));
+ return (EINVAL);
- DB_ASSERT(env, 0);
- break;
}
if ((t_ret = __memp_fput(mpf,
vdp->thread_info, h, dbp->priority)) != 0 && ret == 0)
@@ -2303,8 +2314,8 @@
ret = t_ret;
break;
default:
+ EPRINT((env, DB_STR("5546", "Invalid page type to salvage.")));
+ return (EINVAL);
- DB_ASSERT(env, 0); /* Shouldn't ever happen. */
- break;
}
if ((t_ret = __memp_fput(mpf,
vdp->thread_info, h, dbp->priority)) != 0 && ret == 0)
@@ -2361,7 +2372,10 @@
env = dbp->env;
+ if (himarkp == NULL) {
+ __db_msg(env, "Page %lu index has no end.", (u_long)pgno);
+ return (DB_VERIFY_FATAL);
+ }
- DB_ASSERT(env, himarkp != NULL);
inp = P_INP(dbp, h);
/*
@@ -2783,7 +2797,11 @@
goto err;
ovfl_bufsz = bkkey->len + 1;
}
+ if (subdbname == NULL) {
+ EPRINT((env, DB_STR("5547", "Subdatabase cannot be null.")));
+ ret = EINVAL;
+ goto err;
+ }
- DB_ASSERT(env, subdbname != NULL);
memcpy(subdbname, bkkey->data, bkkey->len);
subdbname[bkkey->len] = '\0';
}
--- db-18.1.32/src/db/db_vrfyutil.c 2019-02-20 03:21:20.000000000 +0530
+++ db-18.1.40/src/db/db_vrfyutil.c 2020-05-29 23:28:22.000000000 +0530
@@ -214,7 +214,8 @@
if ((ret = __db_get(pgdbp,
vdp->thread_info, vdp->txn, &key, &data, 0)) == 0) {
/* Found it. */
+ if (data.size != sizeof(VRFY_PAGEINFO))
+ return (DB_VERIFY_FATAL);
- DB_ASSERT(env, data.size == sizeof(VRFY_PAGEINFO));
pip = data.data;
LIST_INSERT_HEAD(&vdp->activepips, pip, links);
goto found;
@@ -342,7 +343,8 @@
F_SET(&data, DB_DBT_USERMEM);
if ((ret = __db_get(dbp, ip, txn, &key, &data, 0)) == 0) {
+ if (data.size != sizeof(int))
+ return (EINVAL);
- DB_ASSERT(dbp->env, data.size == sizeof(int));
} else if (ret == DB_NOTFOUND)
val = 0;
else
@@ -382,7 +384,8 @@
F_SET(&data, DB_DBT_USERMEM);
if ((ret = __db_get(dbp, ip, txn, &key, &data, 0)) == 0) {
+ if (data.size != sizeof(int))
+ return (DB_VERIFY_FATAL);
- DB_ASSERT(dbp->env, data.size == sizeof(int));
} else if (ret != DB_NOTFOUND)
return (ret);
@@ -419,7 +422,8 @@
if ((ret = __dbc_get(dbc, &key, &data, DB_NEXT)) != 0)
return (ret);
+ if (key.size != sizeof(db_pgno_t))
+ return (DB_VERIFY_FATAL);
- DB_ASSERT(dbc->env, key.size == sizeof(db_pgno_t));
*pgnop = pgno;
return (0);
@@ -566,7 +570,8 @@
if ((ret = __dbc_get(dbc, &key, &data, DB_SET)) != 0)
return (ret);
+ if (data.size != sizeof(VRFY_CHILDINFO))
+ return (DB_VERIFY_FATAL);
- DB_ASSERT(dbc->env, data.size == sizeof(VRFY_CHILDINFO));
*cipp = (VRFY_CHILDINFO *)data.data;
return (0);
@@ -594,7 +599,8 @@
if ((ret = __dbc_get(dbc, &key, &data, DB_NEXT_DUP)) != 0)
return (ret);
+ if (data.size != sizeof(VRFY_CHILDINFO))
+ return (DB_VERIFY_FATAL);
- DB_ASSERT(dbc->env, data.size == sizeof(VRFY_CHILDINFO));
*cipp = (VRFY_CHILDINFO *)data.data;
return (0);
@@ -721,7 +727,8 @@
return (ret);
while ((ret = __dbc_get(*dbcp, &key, &data, DB_NEXT)) == 0) {
+ if (data.size != sizeof(u_int32_t))
+ return (DB_VERIFY_FATAL);
- DB_ASSERT(dbp->env, data.size == sizeof(u_int32_t));
memcpy(&pgtype, data.data, sizeof(pgtype));
if (skip_overflow && pgtype == SALVAGE_OVERFLOW)
@@ -730,8 +737,9 @@
if ((ret = __dbc_del(*dbcp, 0)) != 0)
return (ret);
if (pgtype != SALVAGE_IGNORE) {
+ if (key.size != sizeof(db_pgno_t)
+ || data.size != sizeof(u_int32_t))
+ return (DB_VERIFY_FATAL);
- DB_ASSERT(dbp->env, key.size == sizeof(db_pgno_t));
- DB_ASSERT(dbp->env, data.size == sizeof(u_int32_t));
*pgnop = *(db_pgno_t *)key.data;
*pgtypep = *(u_int32_t *)data.data;
--- db-18.1.32/src/db/partition.c 2019-02-20 03:21:20.000000000 +0530
+++ db-18.1.40/src/db/partition.c 2020-05-29 23:28:22.000000000 +0530
@@ -461,9 +461,19 @@
} else
part->nparts = meta->nparts;
} else if (meta->nparts != 0 && part->nparts != meta->nparts) {
+ ret = EINVAL;
__db_errx(env, DB_STR("0656",
"Number of partitions does not match."));
- ret = EINVAL;
+ goto err;
+ }
+ /*
+ * There is no limit on the number of partitions, but I cannot imagine a real
+ * database having more than 10000.
+ */
+ if (meta->nparts > 10000) {
+ ret = EINVAL;
+ __db_errx(env, DB_STR_A("5553",
+ "Too many partitions %lu", "%lu"), (u_long)(meta->nparts));
goto err;
}
@@ -2106,10 +2116,13 @@
memcpy(rp->data, key->data, key->size);
B_TSET(rp->type, B_KEYDATA);
}
+vrfy: if ((t_ret = __db_verify(*pdbp, ip, (*pdbp)->fname,
+ NULL, handle, callback,
+ lp, rp, flags | DB_VERIFY_PARTITION)) != 0 && ret == 0) {
+ ret = t_ret;
+ if (ret == ENOENT)
+ break;
+ }
-vrfy: if ((t_ret = __db_verify(*pdbp, ip, (*pdbp)->fname,
- NULL, handle, callback,
- lp, rp, flags | DB_VERIFY_PARTITION)) != 0 && ret == 0)
- ret = t_ret;
}
err: if (lp != NULL)
--- db-18.1.32/src/hash/hash_page.c 2019-02-20 03:21:20.000000000 +0530
+++ db-18.1.40/src/hash/hash_page.c 2020-05-29 23:28:22.000000000 +0530
@@ -869,7 +869,11 @@
/* Validate that next, prev pointers are OK */
n = NUM_ENT(p);
dbp = dbc->dbp;
+ if (n % 2 != 0) {
+ __db_errx(dbp->env, DB_STR_A("5549",
+ "Odd number of entries on page: %lu", "%lu"), (u_long)(p->pgno));
+ return (DB_VERIFY_FATAL);
+ }
- DB_ASSERT(dbp->env, n%2 == 0 );
env = dbp->env;
t = dbp->h_internal;
@@ -940,7 +944,12 @@
if ((ret = __db_prpage(dbp, p, DB_PR_PAGE)) != 0)
return (ret);
#endif
+ if (res >= 0) {
+ __db_errx(env, DB_STR_A("5550",
+ "Odd number of entries on page: %lu", "%lu"),
+ (u_long)p->pgno);
+ return (DB_VERIFY_FATAL);
+ }
- DB_ASSERT(dbp->env, res < 0);
}
prev = curr;
--- db-18.1.32/src/hash/hash_verify.c 2019-02-20 03:21:20.000000000 +0530
+++ db-18.1.40/src/hash/hash_verify.c 2020-05-29 23:28:22.000000000 +0530
@@ -615,7 +615,7 @@
isbad = 1;
else
goto err;
+ }
- }
/*
* There may be unused hash pages corresponding to buckets
@@ -746,7 +746,7 @@
"Page %lu: impossible first page in bucket %lu", "%lu %lu"),
(u_long)pgno, (u_long)bucket));
/* Unsafe to continue. */
+ ret = DB_VERIFY_FATAL;
- isbad = 1;
goto err;
}
@@ -776,7 +776,7 @@
EPRINT((env, DB_STR_A("1116",
"Page %lu: hash page referenced twice", "%lu"),
(u_long)pgno));
+ ret = DB_VERIFY_FATAL;
- isbad = 1;
/* Unsafe to continue. */
goto err;
} else if ((ret = __db_vrfy_pgset_inc(vdp->pgset,
@@ -1307,7 +1307,11 @@
COMPQUIET(flags, 0);
ip = vdp->thread_info;
+ if (pgset == NULL) {
+ EPRINT((dbp->env, DB_STR("5548",
+ "Error, database contains no visible pages.")));
+ return (DB_VERIFY_FATAL);
+ }
- DB_ASSERT(dbp->env, pgset != NULL);
mpf = dbp->mpf;
totpgs = 0;
--- db-18.1.32/src/qam/qam_verify.c 2019-02-20 03:21:20.000000000 +0530
+++ db-18.1.40/src/qam/qam_verify.c 2020-05-29 23:28:22.000000000 +0530
@@ -465,7 +465,14 @@
/* Verify/salvage each page. */
if ((ret = __db_cursor(dbp, vdp->thread_info, NULL, &dbc, 0)) != 0)
return (ret);
-begin: for (; i <= stop; i++) {
+begin: if ((stop - i) > 100000) {
+ EPRINT((env, DB_STR_A("5551",
+"Warning, many possible extends files (%lu), will take a long time to verify",
+ "%lu"), (u_long)(stop - i)));
+ }
+ for (; i <= stop; i++) {
+ if (i == UINT32_MAX)
+ break;
/*
* If DB_SALVAGE is set, we inspect our database of completed
* pages, and skip any we've already printed in the subdb pass.

View File

@ -1,5 +1,15 @@
untrusted comment: verify with /etc/ports/compat-32.pub
RWSwxGo/zH7eXZ1RfSlRcPi26z+8DoSRN5np8fQXpSE7KaQXFTOQ8a5Zvjgl3F4F8YdbOXrUcM+Od+6oZRRRzj5pjH0dUTvITwI=
SHA256 (Pkgfile) = 152608c2c0309a24805c3d2495e2e215ea4527caededc8de961eb7946188bbec
RWSwxGo/zH7eXa+Sy23HIgL/c8QV1+GCwoMj0x13wln9Cik/7tXSANmVGNTwFGbvPjtvmgc8oEHXMro2sCHKr7dcQpb8et+okQc=
SHA256 (Pkgfile) = 6ee935100f908bd1388c31ec38829b54e7ac34e1cb8896454a05eeaf26c69dcd
SHA256 (.footprint) = ed937edd86b37309fa1dbf615db7c5585929755a2ff278e7143277eab8303b9f
SHA256 (gtk+-2.24.33.tar.xz) = ac2ac757f5942d318a311a54b0c80b5ef295f299c2a73c632f6bfb1ff49cc6da
SHA256 (icon-padding.patch) = 8846d81ceb6a5f48f116e7fd1c3ac709d9c8371425355c3695a09c9f9de7663d
SHA256 (tooltip-positioning.patch) = 80adf8cd8c0a862c101525122da769457540599e180d875718673de4c3691719
SHA256 (window-dragging.patch) = 4cf99b6d5f8c25cb7f97a041eaec6d23a3171d7bed1204aca03f257ffd9e8e34
SHA256 (gtk2-c99.patch) = a5d1ceb0850249da13e404c1c044cbd2377acea1ae5d18255650a6b774333101
SHA256 (gtk2-c89.patch) = c2517ba418f72224d1a74b1a20dda698cc99fb27ac3773d19eb18c89572cd6c3
SHA256 (gtk2-c89-2.patch) = 1dd4bee9023f76762333d557f3a59b9eb400bef508dba45dcd492053827d5ed7
SHA256 (gtk2-c89-3.patch) = b3ebdad2d887b0be6b8169d987550cadb3353d005debfb5eb1e0e63975072201
SHA256 (gtk2-c89-4.patch) = dfe109be88a41e01433b6a260876071354a576b1b46dd401463e8de73073cf6a
SHA256 (gtk2-c89-5.patch) = 89343af092e6e99496c48e7356e044ac673f49705cd039e3335c05541d6f8e85
SHA256 (gtk2-c89-6.patch) = c019553aae8ea3688b4f9f56c191789c63b57cdf251156372dcf1fbc5b578d10

View File

@ -5,23 +5,50 @@
name=gtk-32
version=2.24.33
release=1
source=(https://download.gnome.org/sources/gtk+/${version%.*}/gtk+-$version.tar.xz)
release=2
source=(https://download.gnome.org/sources/gtk+/${version%.*}/gtk+-$version.tar.xz
icon-padding.patch
tooltip-positioning.patch
window-dragging.patch
gtk2-c99.patch
gtk2-c89.patch
gtk2-c89-2.patch
gtk2-c89-3.patch
gtk2-c89-4.patch
gtk2-c89-5.patch
gtk2-c89-6.patch)
build() {
cd gtk+-$version
cd gtk+-$version
export PKG_CONFIG_PATH+=":/usr/share/pkgconfig"
export PKG_CONFIG_PATH+=":/usr/share/pkgconfig"
./configure \
--prefix=/usr \
--libdir=/usr/lib32 \
--disable-cups
patch -Np1 -i $SRC/icon-padding.patch
patch -Np1 -i $SRC/tooltip-positioning.patch
patch -Np1 -i $SRC/window-dragging.patch
patch -Np1 -i $SRC/gtk2-c99.patch
patch -Np1 -i $SRC/gtk2-c89.patch
patch -Np1 -i $SRC/gtk2-c89-2.patch
patch -Np1 -i $SRC/gtk2-c89-3.patch
patch -Np1 -i $SRC/gtk2-c89-4.patch
patch -Np1 -i $SRC/gtk2-c89-5.patch
patch -Np1 -i $SRC/gtk2-c89-6.patch
make
make DESTDIR=$PKG install
mv $PKG/usr/bin/gtk-query-immodules-2.0 $PKG/usr/bin/gtk-query-immodules-2.0-32
rm $PKG/usr/bin/{gtk-builder-convert,gtk-demo,gtk-update-icon-cache}
rm -r $PKG/usr/etc $PKG/usr/{include,share}
CFLAGS+=' -Wno-deprecated-declarations -Wno-unused-but-set-variable' \
CXXFLAGS+=' -Wno-deprecated-declarations -Wno-unused-but-set-variable' \
./configure \
--prefix=/usr \
--libdir=/usr/lib32 \
--disable-cups \
--with-xinput=yes
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
make
make DESTDIR=$PKG install
mv $PKG/usr/bin/gtk-query-immodules-2.0 $PKG/usr/bin/gtk-query-immodules-2.0-32
rm $PKG/usr/bin/{gtk-builder-convert,gtk-demo,gtk-update-icon-cache}
rm -r $PKG/usr/etc $PKG/usr/{include,share}
}

19
gtk-32/gtk2-c89-2.patch Normal file
View File

@ -0,0 +1,19 @@
commit 018a4255624928fb7d951f1d1c89196fe77e8267
Author: Cosimo Cecchi <cosimoc@gnome.org>
Date: Mon Feb 18 19:37:20 2013 -0500
immodule: fix a GCC warning
diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c
index 1fcb17a7d87f197c..445b2be87f57742f 100644
--- a/gtk/gtkimmodule.c
+++ b/gtk/gtkimmodule.c
@@ -662,7 +662,7 @@ lookup_immodule (gchar **immodules_list)
gboolean found;
gchar *context_id;
found = g_hash_table_lookup_extended (contexts_hash, *immodules_list,
- &context_id, NULL);
+ (gpointer *) &context_id, NULL);
if (found)
return context_id;
}

21
gtk-32/gtk2-c89-3.patch Normal file
View File

@ -0,0 +1,21 @@
Partial backport of:
commit 345d865ac6b2f7760503ab144dd68e6062438b80
Author: Matthias Clasen <mclasen@redhat.com>
Date: Wed Jan 18 00:57:20 2012 -0500
GtkScale: Fix late setting of marks
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 4317523fb8f1918a..a573b2f6ba203b92 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -1471,7 +1471,7 @@ gtk_scale_add_mark (GtkScale *scale,
mark->position = position;
priv->marks = g_slist_insert_sorted_with_data (priv->marks, mark,
- (GCompareFunc) compare_marks,
+ compare_marks,
GINT_TO_POINTER (
gtk_range_get_inverted (GTK_RANGE (scale))
));

16
gtk-32/gtk2-c89-4.patch Normal file
View File

@ -0,0 +1,16 @@
Return the expected GObject * type. This was not fixed upstream before
this file was removed.
diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c
index d004cf1ed3a2be11..8cbeda9e85b8f460 100644
--- a/gtk/gtkuimanager.c
+++ b/gtk/gtkuimanager.c
@@ -503,7 +503,7 @@ gtk_ui_manager_buildable_construct_child (GtkBuildable *buildable,
g_signal_connect (widget, "hierarchy-changed",
G_CALLBACK (child_hierarchy_changed_cb),
GTK_UI_MANAGER (buildable));
- return g_object_ref (widget);
+ return G_OBJECT (g_object_ref (widget));
}
static void

51
gtk-32/gtk2-c89-5.patch Normal file
View File

@ -0,0 +1,51 @@
Part of this commit upstream:
commit ca94ff10ce2ea57bfde7692aaa558b1260c9ff75
Author: Daniel Boles <dboles.src@gmail.com>
Date: Fri Jun 29 20:00:06 2018 +0100
testsuite/gtk/defaultvalue: Actually build...& fix
It looks like this got dropped during the move from autotools and never
restored. I can see why, since making it work wasn't a hugely fun task!
Notes on some less then obvious details:
* PlacesSidebar is private now and didn't seem to be to be particularly
easy to adapt to, so this moves to checking for it by name, not TYPE.
I couldn't find a (fast) better way; if you know how, please clean up
* added 2 casts to avoid warnings from the new type-propagating ref()
* GdkClipboard and GdkContentProvider need some properties dodged
* GtkToolItemGroup is gone
* fixed indentation and used TypeName:property-name syntax in a print()
diff --git a/gtk/tests/defaultvalue.c b/gtk/tests/defaultvalue.c
index 64a113c955822af0..b78dcd6f59353102 100644
--- a/gtk/tests/defaultvalue.c
+++ b/gtk/tests/defaultvalue.c
@@ -91,13 +91,13 @@ test_type (gconstpointer data)
klass = g_type_class_ref (type);
if (g_type_is_a (type, GTK_TYPE_SETTINGS))
- instance = g_object_ref (gtk_settings_get_default ());
+ instance = G_OBJECT (g_object_ref (gtk_settings_get_default ()));
else if (g_type_is_a (type, GDK_TYPE_PANGO_RENDERER))
- instance = g_object_ref (gdk_pango_renderer_get_default (gdk_screen_get_default ()));
+ instance = G_OBJECT (g_object_ref (gdk_pango_renderer_get_default (gdk_screen_get_default ())));
else if (g_type_is_a (type, GDK_TYPE_PIXMAP))
- instance = g_object_ref (gdk_pixmap_new (NULL, 1, 1, 1));
+ instance = G_OBJECT (g_object_ref (gdk_pixmap_new (NULL, 1, 1, 1)));
else if (g_type_is_a (type, GDK_TYPE_COLORMAP))
- instance = g_object_ref (gdk_colormap_new (gdk_visual_get_best (), TRUE));
+ instance = G_OBJECT (g_object_ref (gdk_colormap_new (gdk_visual_get_best (), TRUE)));
else if (g_type_is_a (type, GDK_TYPE_WINDOW))
{
GdkWindowAttr attributes;
@@ -105,7 +105,7 @@ test_type (gconstpointer data)
attributes.event_mask = 0;
attributes.width = 100;
attributes.height = 100;
- instance = g_object_ref (gdk_window_new (NULL, &attributes, 0));
+ instance = G_OBJECT (g_object_ref (gdk_window_new (NULL, &attributes, 0)));
}
else
instance = g_object_new (type, NULL);

16
gtk-32/gtk2-c89-6.patch Normal file
View File

@ -0,0 +1,16 @@
Convert to the expected pointer. This was not fixed before the file
was removed upstream.
diff --git a/modules/other/gail/gailtreeview.c b/modules/other/gail/gailtreeview.c
index 23923c59a16a6efb..ac6ff0a1c4a2fe22 100644
--- a/modules/other/gail/gailtreeview.c
+++ b/modules/other/gail/gailtreeview.c
@@ -995,7 +995,7 @@ gail_tree_view_ref_child (AtkObject *obj,
gail_cell_add_state (cell, ATK_STATE_FOCUSABLE, FALSE);
if (focus_index == i)
{
- gailview->focus_cell = g_object_ref (cell);
+ gailview->focus_cell = ATK_OBJECT (g_object_ref (cell));
gail_cell_add_state (cell, ATK_STATE_FOCUSED, FALSE);
g_signal_emit_by_name (gailview,
"active-descendant-changed",

115
gtk-32/gtk2-c89.patch Normal file
View File

@ -0,0 +1,115 @@
commit 072f06abf713d7536ce2a84a5ac266f585c88d39
Author: Matthias Clasen <mclasen@redhat.com>
Date: Fri Dec 8 17:48:47 2017 -0500
Fix fallout from g_object_ref change
g_object_ref now returns the type of the object that was
passed. Introduce cast as necessary to avoid warnings due
to this.
diff --git a/gtk/gtkcellrendererspin.c b/gtk/gtkcellrendererspin.c
index 2a3961bf203cbe59..7129d05e3b2c1ae6 100644
--- a/gtk/gtkcellrendererspin.c
+++ b/gtk/gtkcellrendererspin.c
@@ -207,7 +207,8 @@ gtk_cell_renderer_spin_set_property (GObject *object,
}
if (obj)
- priv->adjustment = g_object_ref_sink (obj);
+ priv->adjustment = GTK_ADJUSTMENT (g_object_ref_sink (obj));
+
break;
case PROP_CLIMB_RATE:
priv->climb_rate = g_value_get_double (value);
diff --git a/gtk/gtkcomboboxtext.c b/gtk/gtkcomboboxtext.c
index 9ffba687660c1214..5e75323c2c55d491 100644
--- a/gtk/gtkcomboboxtext.c
+++ b/gtk/gtkcomboboxtext.c
@@ -275,7 +275,7 @@ gtk_combo_box_text_buildable_custom_tag_start (GtkBuildable *buildable,
parser_data = g_slice_new0 (ItemParserData);
parser_data->builder = g_object_ref (builder);
- parser_data->object = g_object_ref (buildable);
+ parser_data->object = (GObject *)g_object_ref (buildable);
parser_data->domain = gtk_builder_get_translation_domain (builder);
*parser = item_parser;
*data = parser_data;
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index c47de5924f6f0b49..879586b0d9855374 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -1336,7 +1336,7 @@ gtk_label_buildable_custom_tag_start (GtkBuildable *buildable,
parser_data = g_slice_new0 (PangoParserData);
parser_data->builder = g_object_ref (builder);
- parser_data->object = g_object_ref (buildable);
+ parser_data->object = (GObject *) g_object_ref (buildable);
*parser = pango_parser;
*data = parser_data;
return TRUE;
diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c
index b984193ca3375223..ba4e472dea4ebd77 100644
--- a/gtk/gtktoolpalette.c
+++ b/gtk/gtktoolpalette.c
@@ -734,7 +734,7 @@ gtk_tool_palette_add (GtkContainer *container,
g_ptr_array_add (palette->priv->groups, info);
info->pos = palette->priv->groups->len - 1;
- info->widget = g_object_ref_sink (child);
+ info->widget = (GtkToolItemGroup *)g_object_ref_sink (child);
gtk_widget_set_parent (child, GTK_WIDGET (palette));
}
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 89301eb91d21c793..0d2d15b4883a7110 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -14147,7 +14147,7 @@ gtk_tree_view_set_search_entry (GtkTreeView *tree_view,
if (entry)
{
- tree_view->priv->search_entry = g_object_ref (entry);
+ tree_view->priv->search_entry = GTK_WIDGET (g_object_ref (entry));
tree_view->priv->search_custom_entry_set = TRUE;
if (tree_view->priv->search_entry_changed_id == 0)
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index d8f6023ba3ae164c..b6d7b815505760da 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -10686,7 +10686,7 @@ gtk_widget_buildable_custom_tag_start (GtkBuildable *buildable,
AccelGroupParserData *parser_data;
parser_data = g_slice_new0 (AccelGroupParserData);
- parser_data->object = g_object_ref (buildable);
+ parser_data->object = (GObject *)g_object_ref (buildable);
*parser = accel_group_parser;
*data = parser_data;
return TRUE;
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index 2a000dc16ff57582..e081a70c45743fd2 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -3479,7 +3479,7 @@ cups_request_ppd (GtkPrinter *printer)
g_io_channel_set_encoding (data->ppd_io, NULL, NULL);
g_io_channel_set_close_on_unref (data->ppd_io, TRUE);
- data->printer = g_object_ref (printer);
+ data->printer = (GtkPrinterCups *) g_object_ref (printer);
resource = g_strdup_printf ("/printers/%s.ppd",
gtk_printer_cups_get_ppd_name (GTK_PRINTER_CUPS (printer)));
diff --git a/tests/testentrycompletion.c b/tests/testentrycompletion.c
index 36c41f78a42fb928..c556734b72ef71b0 100644
--- a/tests/testentrycompletion.c
+++ b/tests/testentrycompletion.c
@@ -237,7 +237,7 @@ animation_timer (GtkEntryCompletion *completion)
{
g_print ("removing model!\n");
- old_store = g_object_ref (gtk_entry_completion_get_model (completion));
+ old_store = GTK_LIST_STORE (g_object_ref (gtk_entry_completion_get_model (completion)));
gtk_entry_completion_set_model (completion, NULL);
}
else

42
gtk-32/gtk2-c99.patch Normal file
View File

@ -0,0 +1,42 @@
commit bcfc53066ae54d0adbf282d5678d9a4a7083b4d3
Author: Javier Jardón <jjardon@gnome.org>
Date: Mon May 3 02:56:29 2010 +0200
tests: Too many arguments in call to 'create_menu'
diff --git a/tests/testmenubars.c b/tests/testmenubars.c
index 416a93986121d858..853d822a9b6a7925 100644
--- a/tests/testmenubars.c
+++ b/tests/testmenubars.c
@@ -21,7 +21,7 @@
#include <gtk/gtk.h>
static GtkWidget *
-create_menu (depth)
+create_menu (guint depth)
{
GtkWidget *menu;
GtkWidget *menuitem;
@@ -70,19 +70,19 @@ create_menubar (GtkPackDirection pack_dir,
menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_HOME, NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
gtk_label_set_angle (GTK_LABEL (GTK_BIN (menuitem)->child), angle);
- menu = create_menu (2, TRUE);
+ menu = create_menu (2);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
menuitem = gtk_menu_item_new_with_label ("foo");
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
gtk_label_set_angle (GTK_LABEL (GTK_BIN (menuitem)->child), angle);
- menu = create_menu (2, TRUE);
+ menu = create_menu (2);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
menuitem = gtk_menu_item_new_with_label ("bar");
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
gtk_label_set_angle (GTK_LABEL (GTK_BIN (menuitem)->child), angle);
- menu = create_menu (2, TRUE);
+ menu = create_menu (2);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
return menubar;

258
gtk-32/icon-padding.patch Normal file
View File

@ -0,0 +1,258 @@
diff -up gtk+-2.19.7/gtk/gtkstatusicon.c.icon-padding gtk+-2.19.7/gtk/gtkstatusicon.c
--- gtk+-2.19.7/gtk/gtkstatusicon.c.icon-padding 2010-03-08 08:42:22.000000000 -0500
+++ gtk+-2.19.7/gtk/gtkstatusicon.c 2010-03-10 00:40:11.165527903 -0500
@@ -170,6 +170,7 @@ static void gtk_status_icon_screen_c
GdkScreen *old_screen);
static void gtk_status_icon_embedded_changed (GtkStatusIcon *status_icon);
static void gtk_status_icon_orientation_changed (GtkStatusIcon *status_icon);
+static void gtk_status_icon_padding_changed (GtkStatusIcon *status_icon);
static gboolean gtk_status_icon_scroll (GtkStatusIcon *status_icon,
GdkEventScroll *event);
static gboolean gtk_status_icon_query_tooltip (GtkStatusIcon *status_icon,
@@ -850,6 +851,8 @@ gtk_status_icon_init (GtkStatusIcon *sta
G_CALLBACK (gtk_status_icon_embedded_changed), status_icon);
g_signal_connect_swapped (priv->tray_icon, "notify::orientation",
G_CALLBACK (gtk_status_icon_orientation_changed), status_icon);
+ g_signal_connect_swapped (priv->tray_icon, "notify::padding",
+ G_CALLBACK (gtk_status_icon_padding_changed), status_icon);
g_signal_connect_swapped (priv->tray_icon, "button-press-event",
G_CALLBACK (gtk_status_icon_button_press), status_icon);
g_signal_connect_swapped (priv->tray_icon, "button-release-event",
@@ -975,6 +978,8 @@ gtk_status_icon_finalize (GObject *objec
g_signal_handlers_disconnect_by_func (priv->tray_icon,
gtk_status_icon_orientation_changed, status_icon);
g_signal_handlers_disconnect_by_func (priv->tray_icon,
+ gtk_status_icon_padding_changed, status_icon);
+ g_signal_handlers_disconnect_by_func (priv->tray_icon,
gtk_status_icon_button_press, status_icon);
g_signal_handlers_disconnect_by_func (priv->tray_icon,
gtk_status_icon_button_release, status_icon);
@@ -1679,14 +1684,32 @@ gtk_status_icon_screen_changed (GtkStatu
#ifdef GDK_WINDOWING_X11
static void
+gtk_status_icon_padding_changed (GtkStatusIcon *status_icon)
+{
+ GtkStatusIconPrivate *priv = status_icon->priv;
+ GtkOrientation orientation;
+ gint padding;
+
+ orientation = _gtk_tray_icon_get_orientation (GTK_TRAY_ICON (priv->tray_icon));
+ padding = _gtk_tray_icon_get_padding (GTK_TRAY_ICON (priv->tray_icon));
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ gtk_misc_set_padding (GTK_MISC (priv->image), padding, 0);
+ else
+ gtk_misc_set_padding (GTK_MISC (priv->image), 0, padding);
+}
+
+static void
gtk_status_icon_embedded_changed (GtkStatusIcon *status_icon)
{
+ gtk_status_icon_padding_changed (status_icon);
g_object_notify (G_OBJECT (status_icon), "embedded");
}
static void
gtk_status_icon_orientation_changed (GtkStatusIcon *status_icon)
{
+ gtk_status_icon_padding_changed (status_icon);
g_object_notify (G_OBJECT (status_icon), "orientation");
}
@@ -1804,7 +1827,7 @@ gtk_status_icon_reset_image_data (GtkSta
g_object_notify (G_OBJECT (status_icon), "stock");
break;
-
+
case GTK_IMAGE_ICON_NAME:
g_free (priv->image_data.icon_name);
priv->image_data.icon_name = NULL;
diff -up gtk+-2.19.7/gtk/gtktrayicon.h.icon-padding gtk+-2.19.7/gtk/gtktrayicon.h
--- gtk+-2.19.7/gtk/gtktrayicon.h.icon-padding 2009-10-18 01:35:45.000000000 -0400
+++ gtk+-2.19.7/gtk/gtktrayicon.h 2010-03-10 00:40:11.169528392 -0500
@@ -69,7 +69,8 @@ void _gtk_tray_icon_cancel_mes
guint id);
GtkOrientation _gtk_tray_icon_get_orientation (GtkTrayIcon *icon);
-
+gint _gtk_tray_icon_get_padding (GtkTrayIcon *icon);
+
G_END_DECLS
#endif /* __GTK_TRAY_ICON_H__ */
diff -up gtk+-2.19.7/gtk/gtktrayicon-x11.c.icon-padding gtk+-2.19.7/gtk/gtktrayicon-x11.c
--- gtk+-2.19.7/gtk/gtktrayicon-x11.c.icon-padding 2010-03-08 21:01:28.000000000 -0500
+++ gtk+-2.19.7/gtk/gtktrayicon-x11.c 2010-03-10 00:49:48.229509604 -0500
@@ -43,23 +43,26 @@
enum {
PROP_0,
- PROP_ORIENTATION
+ PROP_ORIENTATION,
+ PROP_PADDING
};
struct _GtkTrayIconPrivate
{
guint stamp;
-
+
Atom selection_atom;
Atom manager_atom;
Atom system_tray_opcode_atom;
Atom orientation_atom;
Atom visual_atom;
+ Atom padding_atom;
Window manager_window;
GdkVisual *manager_visual;
gboolean manager_visual_rgba;
GtkOrientation orientation;
+ gint padding;
};
static void gtk_tray_icon_constructed (GObject *object);
@@ -113,6 +116,16 @@ gtk_tray_icon_class_init (GtkTrayIconCla
GTK_ORIENTATION_HORIZONTAL,
GTK_PARAM_READABLE));
+ g_object_class_install_property (gobject_class,
+ PROP_PADDING,
+ g_param_spec_int ("padding",
+ P_("Padding"),
+ P_("Padding that should be put around icons in the tray"),
+ 0,
+ G_MAXINT,
+ 0,
+ GTK_PARAM_READABLE));
+
g_type_class_add_private (class, sizeof (GtkTrayIconPrivate));
}
@@ -124,6 +137,7 @@ gtk_tray_icon_init (GtkTrayIcon *icon)
icon->priv->stamp = 1;
icon->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
+ icon->priv->padding = 0;
gtk_widget_set_app_paintable (GTK_WIDGET (icon), TRUE);
gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
@@ -161,6 +175,10 @@ gtk_tray_icon_constructed (GObject *obje
"_NET_SYSTEM_TRAY_VISUAL",
False);
+ icon->priv->padding_atom = XInternAtom (xdisplay,
+ "_NET_SYSTEM_TRAY_PADDING",
+ False);
+
/* Add a root window filter so that we get changes on MANAGER */
gdk_window_add_filter (root_window,
gtk_tray_icon_manager_filter, icon);
@@ -212,6 +230,9 @@ gtk_tray_icon_get_property (GObject *
case PROP_ORIENTATION:
g_value_set_enum (value, icon->priv->orientation);
break;
+ case PROP_PADDING:
+ g_value_set_int (value, icon->priv->padding);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -372,9 +393,58 @@ gtk_tray_icon_get_visual_property (GtkTr
XFree (prop.prop);
}
+static void
+gtk_tray_icon_get_padding_property (GtkTrayIcon *icon)
+{
+ GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (icon));
+ GdkDisplay *display = gdk_screen_get_display (screen);
+ Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
+
+ Atom type;
+ int format;
+ union {
+ gulong *prop;
+ guchar *prop_ch;
+ } prop = { NULL };
+ gulong nitems;
+ gulong bytes_after;
+ int error, result;
+
+ g_assert (icon->priv->manager_window != None);
+
+ gdk_error_trap_push ();
+ type = None;
+ result = XGetWindowProperty (xdisplay,
+ icon->priv->manager_window,
+ icon->priv->padding_atom,
+ 0, G_MAXLONG, FALSE,
+ XA_CARDINAL,
+ &type, &format, &nitems,
+ &bytes_after, &(prop.prop_ch));
+ error = gdk_error_trap_pop ();
+
+ if (!error && result == Success &&
+ type == XA_CARDINAL && nitems == 1 && format == 32)
+ {
+ gint padding;
+
+ padding = prop.prop[0];
+
+ if (icon->priv->padding != padding)
+ {
+ icon->priv->padding = padding;
+
+ g_object_notify (G_OBJECT (icon), "padding");
+ }
+ }
+
+ if (type != None)
+ XFree (prop.prop);
+}
+
static GdkFilterReturn
-gtk_tray_icon_manager_filter (GdkXEvent *xevent,
- GdkEvent *event,
+gtk_tray_icon_manager_filter (GdkXEvent *xevent,
+ GdkEvent *event,
gpointer user_data)
{
GtkTrayIcon *icon = user_data;
@@ -399,6 +469,11 @@ gtk_tray_icon_manager_filter (GdkXEvent
gtk_tray_icon_get_orientation_property (icon);
}
+ else if (xev->xany.type == PropertyNotify &&
+ xev->xproperty.atom == icon->priv->padding_atom)
+ {
+ gtk_tray_icon_get_padding_property (icon);
+ }
else if (xev->xany.type == DestroyNotify)
{
GTK_NOTE (PLUGSOCKET,
@@ -504,6 +579,7 @@ gtk_tray_icon_update_manager_window (Gtk
gtk_tray_icon_get_orientation_property (icon);
gtk_tray_icon_get_visual_property (icon);
+ gtk_tray_icon_get_padding_property (icon);
if (gtk_widget_get_realized (GTK_WIDGET (icon)))
{
@@ -740,6 +816,14 @@ _gtk_tray_icon_get_orientation (GtkTrayI
return icon->priv->orientation;
}
+gint
+_gtk_tray_icon_get_padding (GtkTrayIcon *icon)
+{
+ g_return_val_if_fail (GTK_IS_TRAY_ICON (icon), 0);
+
+ return icon->priv->padding;
+}
+
#define __GTK_TRAY_ICON_X11_C__
#include "gtkaliasdef.c"

View File

@ -0,0 +1,182 @@
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 5cc2334..204a2b6 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -903,53 +903,128 @@ gtk_tooltip_position (GtkTooltip *tooltip,
{
gint x, y;
GdkScreen *screen;
+ gint monitor_num;
+ GdkRectangle monitor;
+ GtkRequisition requisition;
+ guint cursor_size;
+ GdkRectangle bounds;
+
+#define MAX_DISTANCE 32
tooltip->tooltip_widget = new_tooltip_widget;
+ screen = gtk_widget_get_screen (new_tooltip_widget);
+
+ gtk_widget_size_request (GTK_WIDGET (tooltip->current_window), &requisition);
+
+ monitor_num = gdk_screen_get_monitor_at_point (screen,
+ tooltip->last_x,
+ tooltip->last_y);
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+ get_bounding_box (new_tooltip_widget, &bounds);
+
/* Position the tooltip */
- /* FIXME: should we swap this when RTL is enabled? */
- if (tooltip->keyboard_mode_enabled)
+
+ cursor_size = gdk_display_get_default_cursor_size (display);
+
+ /* Try below */
+ x = bounds.x + bounds.width / 2 - requisition.width / 2;
+ y = bounds.y + bounds.height + 4;
+
+ if (y + requisition.height <= monitor.y + monitor.height)
{
- GdkRectangle bounds;
+ if (tooltip->keyboard_mode_enabled)
+ goto found;
- get_bounding_box (new_tooltip_widget, &bounds);
+ if (y <= tooltip->last_y + cursor_size + MAX_DISTANCE)
+ {
+ if (tooltip->last_x + cursor_size + MAX_DISTANCE < x)
+ x = tooltip->last_x + cursor_size + MAX_DISTANCE;
+ else if (x + requisition.width < tooltip->last_x - MAX_DISTANCE)
+ x = tooltip->last_x - MAX_DISTANCE - requisition.width;
- /* For keyboard mode we position the tooltip below the widget,
- * right of the center of the widget.
- */
- x = bounds.x + bounds.width / 2;
- y = bounds.y + bounds.height + 4;
+ goto found;
+ }
+ }
+
+ /* Try above */
+ x = bounds.x + bounds.width / 2 - requisition.width / 2;
+ y = bounds.y - requisition.height - 4;
+
+ if (y >= monitor.y)
+ {
+ if (tooltip->keyboard_mode_enabled)
+ goto found;
+
+ if (y + requisition.height >= tooltip->last_y - MAX_DISTANCE)
+ {
+ if (tooltip->last_x + cursor_size + MAX_DISTANCE < x)
+ x = tooltip->last_x + cursor_size + MAX_DISTANCE;
+ else if (x + requisition.width < tooltip->last_x - MAX_DISTANCE)
+ x = tooltip->last_x - MAX_DISTANCE - requisition.width;
+
+ goto found;
+ }
}
- else
+
+ /* Try right FIXME: flip on rtl ? */
+ x = bounds.x + bounds.width + 4;
+ y = bounds.y + bounds.height / 2 - requisition.height / 2;
+
+ if (x + requisition.width <= monitor.x + monitor.width)
{
- guint cursor_size;
+ if (tooltip->keyboard_mode_enabled)
+ goto found;
- x = tooltip->last_x;
- y = tooltip->last_y;
+ if (x <= tooltip->last_x + cursor_size + MAX_DISTANCE)
+ {
+ if (tooltip->last_y + cursor_size + MAX_DISTANCE < y)
+ y = tooltip->last_y + cursor_size + MAX_DISTANCE;
+ else if (y + requisition.height < tooltip->last_y - MAX_DISTANCE)
+ y = tooltip->last_y - MAX_DISTANCE - requisition.height;
- /* For mouse mode, we position the tooltip right of the cursor,
- * a little below the cursor's center.
- */
- cursor_size = gdk_display_get_default_cursor_size (display);
- x += cursor_size / 2;
- y += cursor_size / 2;
+ goto found;
+ }
}
- screen = gtk_widget_get_screen (new_tooltip_widget);
+ /* Try left FIXME: flip on rtl ? */
+ x = bounds.x - requisition.width - 4;
+ y = bounds.y + bounds.height / 2 - requisition.height / 2;
- /* Show it */
- if (tooltip->current_window)
+ if (x >= monitor.x)
{
- gint monitor_num;
- GdkRectangle monitor;
- GtkRequisition requisition;
+ if (tooltip->keyboard_mode_enabled)
+ goto found;
- gtk_widget_size_request (GTK_WIDGET (tooltip->current_window),
- &requisition);
+ if (x + requisition.width >= tooltip->last_x - MAX_DISTANCE)
+ {
+ if (tooltip->last_y + cursor_size + MAX_DISTANCE < y)
+ y = tooltip->last_y + cursor_size + MAX_DISTANCE;
+ else if (y + requisition.height < tooltip->last_y - MAX_DISTANCE)
+ y = tooltip->last_y - MAX_DISTANCE - requisition.height;
- monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ goto found;
+ }
+ }
+ /* Fallback */
+ if (tooltip->keyboard_mode_enabled)
+ {
+ x = bounds.x + bounds.width / 2 - requisition.width / 2;
+ y = bounds.y + bounds.height + 4;
+ }
+ else
+ {
+ /* At cursor */
+ x = tooltip->last_x + cursor_size * 3 / 4;
+ y = tooltip->last_y + cursor_size * 3 / 4;
+ }
+
+found:
+ /* Show it */
+ if (tooltip->current_window)
+ {
if (x + requisition.width > monitor.x + monitor.width)
x -= x - (monitor.x + monitor.width) + requisition.width;
else if (x < monitor.x)
@@ -957,7 +1032,9 @@ gtk_tooltip_position (GtkTooltip *tooltip,
if (y + requisition.height > monitor.y + monitor.height)
y -= y - (monitor.y + monitor.height) + requisition.height;
-
+ else if (y < monitor.y)
+ y = monitor.y;
+
if (!tooltip->keyboard_mode_enabled)
{
/* don't pop up under the pointer */
@@ -965,7 +1042,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
y <= tooltip->last_y && tooltip->last_y < y + requisition.height)
y = tooltip->last_y - requisition.height - 2;
}
-
+
gtk_window_move (GTK_WINDOW (tooltip->current_window), x, y);
gtk_widget_show (GTK_WIDGET (tooltip->current_window));
}

View File

@ -0,0 +1,116 @@
diff -up gtk+-2.24.7/gtk/gtkmenushell.c.window-dragging gtk+-2.24.7/gtk/gtkmenushell.c
--- gtk+-2.24.7/gtk/gtkmenushell.c.window-dragging 2011-08-15 22:30:52.000000000 -0400
+++ gtk+-2.24.7/gtk/gtkmenushell.c 2011-10-17 19:50:52.180468086 -0400
@@ -589,18 +589,45 @@ gtk_menu_shell_button_press (GtkWidget
if (!menu_shell->active || !menu_shell->button)
{
- gtk_menu_shell_activate (menu_shell);
+ gboolean initially_active = menu_shell->active;
menu_shell->button = event->button;
- if (menu_item && _gtk_menu_item_is_selectable (menu_item) &&
- menu_item->parent == widget &&
- menu_item != menu_shell->active_menu_item)
+ if (menu_item)
{
- if (GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement == GTK_TOP_BOTTOM)
+ if (_gtk_menu_item_is_selectable (menu_item) &&
+ menu_item->parent == widget &&
+ menu_item != menu_shell->active_menu_item)
{
- menu_shell->activate_time = event->time;
- gtk_menu_shell_select_item (menu_shell, menu_item);
+ gtk_menu_shell_activate (menu_shell);
+ menu_shell->button = event->button;
+
+ if (GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement == GTK_TOP_BOTTOM)
+ {
+ menu_shell->activate_time = event->time;
+ gtk_menu_shell_select_item (menu_shell, menu_item);
+ }
+ }
+ }
+ else
+ {
+ if (!initially_active)
+ {
+ gboolean window_drag = FALSE;
+
+ gtk_widget_style_get (widget,
+ "window-dragging", &window_drag,
+ NULL);
+
+ if (window_drag)
+ {
+ gtk_menu_shell_deactivate (menu_shell);
+ gtk_window_begin_move_drag (GTK_WINDOW (gtk_widget_get_toplevel (widget)),
+ event->button,
+ event->x_root,
+ event->y_root,
+ event->time);
+ }
}
}
}
diff -up gtk+-2.24.7/gtk/gtktoolbar.c.window-dragging gtk+-2.24.7/gtk/gtktoolbar.c
--- gtk+-2.24.7/gtk/gtktoolbar.c.window-dragging 2011-10-01 11:29:06.000000000 -0400
+++ gtk+-2.24.7/gtk/gtktoolbar.c 2011-10-17 19:52:56.104463657 -0400
@@ -2701,6 +2701,8 @@ static gboolean
gtk_toolbar_button_press (GtkWidget *toolbar,
GdkEventButton *event)
{
+ GtkWidget *window;
+
if (_gtk_button_event_triggers_context_menu (event))
{
gboolean return_value;
@@ -2711,7 +2713,29 @@ gtk_toolbar_button_press (GtkWidget
return return_value;
}
-
+
+ window = gtk_widget_get_toplevel (toolbar);
+
+ if (window)
+ {
+ gboolean window_drag = FALSE;
+
+ gtk_widget_style_get (toolbar,
+ "window-dragging", &window_drag,
+ NULL);
+
+ if (window_drag)
+ {
+ gtk_window_begin_move_drag (GTK_WINDOW (window),
+ event->button,
+ event->x_root,
+ event->y_root,
+ event->time);
+
+ return TRUE;
+ }
+ }
+
return FALSE;
}
diff -up gtk+-2.24.7/gtk/gtkwidget.c.window-dragging gtk+-2.24.7/gtk/gtkwidget.c
--- gtk+-2.24.7/gtk/gtkwidget.c.window-dragging 2011-10-17 19:50:52.175468086 -0400
+++ gtk+-2.24.7/gtk/gtkwidget.c 2011-10-17 19:50:52.184468086 -0400
@@ -2467,6 +2467,13 @@ gtk_widget_class_init (GtkWidgetClass *k
0.0, 1.0, 0.04,
GTK_PARAM_READABLE));
+ gtk_widget_class_install_style_property (klass,
+ g_param_spec_boolean ("window-dragging",
+ P_("Window dragging"),
+ P_("Window dragging"),
+ FALSE,
+ GTK_PARAM_READWRITE));
+
/**
* GtkWidget:draw-border:
*