squid: add posix-shmem support
This commit is contained in:
parent
6be71c658c
commit
2745042f62
|
@ -4,11 +4,14 @@ TERMUX_PKG_LICENSE="GPL-2.0"
|
|||
TERMUX_PKG_VERSION=4.12
|
||||
TERMUX_PKG_SRCURL=http://squid.mirror.globo.tech/archive/4/squid-$TERMUX_PKG_VERSION.tar.xz
|
||||
TERMUX_PKG_SHA256=f42a03c8b3dc020722c88bf1a87da8cb0c087b2f66b41d8256c77ee1b527e317
|
||||
TERMUX_PKG_DEPENDS="libc++, libcrypt, libxml2, libltdl, openssl, resolv-conf"
|
||||
TERMUX_PKG_DEPENDS="libc++, libcrypt, libxml2, libltdl, libgnutls, resolv-conf"
|
||||
|
||||
# disk-io uses XSI message queue which are not available on Android.
|
||||
# Option 'cache_dir' will be unusable.
|
||||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
|
||||
ac_cv_func_memrchr=yes
|
||||
ac_cv_func_strtoll=yes
|
||||
ac_cv_search_shm_open=
|
||||
ac_cv_lib_sasl2_sasl_errstring=no
|
||||
ac_cv_dbopen_libdb=no
|
||||
squid_cv_gnu_atomics=yes
|
||||
|
@ -33,11 +36,11 @@ squid_cv_gnu_atomics=yes
|
|||
--disable-storeio
|
||||
--enable-translation
|
||||
--with-dl
|
||||
--with-openssl
|
||||
--enable-ssl-crtd
|
||||
--without-openssl
|
||||
--disable-ssl-crtd
|
||||
--with-size-optimizations
|
||||
--without-gnutls
|
||||
--without-libnettle
|
||||
--with-gnutls
|
||||
--with-libnettle
|
||||
--without-mit-krb5
|
||||
--with-maxfd=256
|
||||
"
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
diff -uNr squid-4.12/src/ipc/mem/Segment.cc squid-4.12.mod/src/ipc/mem/Segment.cc
|
||||
--- squid-4.12/src/ipc/mem/Segment.cc 2020-06-07 18:42:16.000000000 +0300
|
||||
+++ squid-4.12.mod/src/ipc/mem/Segment.cc 2020-08-07 22:10:14.210431881 +0300
|
||||
@@ -31,6 +31,65 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
+static int termux_shm_unlink(const char *name) {
|
||||
+ size_t namelen;
|
||||
+ char *fname;
|
||||
+
|
||||
+ /* Construct the filename. */
|
||||
+ while (name[0] == '/') ++name;
|
||||
+
|
||||
+ if (name[0] == '\0') {
|
||||
+ /* The name "/" is not supported. */
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ namelen = strlen(name);
|
||||
+ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1);
|
||||
+ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1);
|
||||
+ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1);
|
||||
+
|
||||
+ return unlink(fname);
|
||||
+}
|
||||
+
|
||||
+static int termux_shm_open(const char *name, int oflag, mode_t mode) {
|
||||
+ size_t namelen;
|
||||
+ char *fname;
|
||||
+ int fd;
|
||||
+
|
||||
+ /* Construct the filename. */
|
||||
+ while (name[0] == '/') ++name;
|
||||
+
|
||||
+ if (name[0] == '\0') {
|
||||
+ /* The name "/" is not supported. */
|
||||
+ errno = EINVAL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ namelen = strlen(name);
|
||||
+ fname = (char *) alloca(sizeof("@TERMUX_PREFIX@/tmp/") - 1 + namelen + 1);
|
||||
+ memcpy(fname, "@TERMUX_PREFIX@/tmp/", sizeof("@TERMUX_PREFIX@/tmp/") - 1);
|
||||
+ memcpy(fname + sizeof("@TERMUX_PREFIX@/tmp/") - 1, name, namelen + 1);
|
||||
+
|
||||
+ fd = open(fname, oflag, mode);
|
||||
+ if (fd != -1) {
|
||||
+ /* We got a descriptor. Now set the FD_CLOEXEC bit. */
|
||||
+ int flags = fcntl(fd, F_GETFD, 0);
|
||||
+ flags |= FD_CLOEXEC;
|
||||
+ flags = fcntl(fd, F_SETFD, flags);
|
||||
+
|
||||
+ if (flags == -1) {
|
||||
+ /* Something went wrong. We cannot return the descriptor. */
|
||||
+ int save_errno = errno;
|
||||
+ close(fd);
|
||||
+ fd = -1;
|
||||
+ errno = save_errno;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return fd;
|
||||
+}
|
||||
+
|
||||
// test cases change this
|
||||
const char *Ipc::Mem::Segment::BasePath = DEFAULT_STATEDIR;
|
||||
|
||||
@@ -134,7 +193,7 @@
|
||||
{
|
||||
assert(theFD < 0);
|
||||
|
||||
- theFD = shm_open(theName.termedBuf(), O_RDWR, 0);
|
||||
+ theFD = termux_shm_open(theName.termedBuf(), O_RDWR, 0);
|
||||
if (theFD < 0) {
|
||||
int xerrno = errno;
|
||||
debugs(54, 5, "shm_open " << theName << ": " << xstrerr(xerrno));
|
||||
@@ -154,7 +213,7 @@
|
||||
bool
|
||||
Ipc::Mem::Segment::createFresh(int &xerrno)
|
||||
{
|
||||
- theFD = shm_open(theName.termedBuf(),
|
||||
+ theFD = termux_shm_open(theName.termedBuf(),
|
||||
O_EXCL | O_CREAT | O_RDWR,
|
||||
S_IRUSR | S_IWUSR);
|
||||
xerrno = errno;
|
||||
@@ -237,7 +296,7 @@
|
||||
void
|
||||
Ipc::Mem::Segment::unlink()
|
||||
{
|
||||
- if (shm_unlink(theName.termedBuf()) != 0) {
|
||||
+ if (termux_shm_unlink(theName.termedBuf()) != 0) {
|
||||
int xerrno = errno;
|
||||
debugs(54, 5, "shm_unlink(" << theName << "): " << xstrerr(xerrno));
|
||||
} else
|
Loading…
Reference in New Issue