Discussion:
[Polipo-users] MinGW build with IPv6
Gabriel Klyber
2016-01-14 04:36:56 UTC
Permalink
I have been experimenting with Polipo on Windows using MinGW_w64. I
found that the following enables some native IPv6 functions in
winsock2 on Windows 8 and above:
#define WINVER 0x0603

I have made a number of source code tweaks, but found that yuuboshi's
patches covered most of what I modified.

I continued to have problems with unlinking files in the cache and
pages from slashdot.org failing to load (among other sites). It does
appear that some changes to unlinking code needs to be made. I started
to work on building a list of files ready to be unlinked and searching
the disk cache, but have not worked out all of the code for it.
Specifically, the rewriteEntry code in diskcache.c does some things
that will not work on Windows. Rather than move the entry to a
temporary file and rebuild it, I changed the code to just destroy the
file and create a new entry. So far, this has not executed, so it must
not be a very common case.

I played with settings and have found the following to be much more
stable than defaults:
#define CHUNK_SIZE 16384
chunkHighMark = 536870912
objectHighMark = 262144
maxDiskEntries = 1000

Windows has a file handle restriction of 2048 handles per process
using standard C I/O functions. It seems that with 1000
maxDiskEntries, the cache does not have unlinking errors. Will it
still write files out if it has the ability to keep so many open?

Increasing CHUNK_SIZE helped slashdot.org load and eliminated most
errors about failing to read from the server. I still occasionally get
errors about not being able to write to the client. CHUNK_SIZE of
32768 or 65536 seemed to work a little better for loading some pages,
but caused crashes in other cases (suspecting overflows in
calculations).

I tried setting higher chunkHighMark settings, but there were places
in the code that would overflow if it was set too high.

Either way, I have been very happy for the past few days with these
configuration changes. IPv6 has been stable, though I did have some
issues listening on an IPv6 address. My needs are met with just
listening on IPv4.

I am happy with the memory usage. If some of the variables were
64-bit, I suspect that the chunkHighMark and CHUNK_SIZE limitations
may be eliminated. The only concern I have is that file handles seem
to not be released. With such a high maxDiskEntries, does the cache
keep the files open until the max value? It would seem to make sense
to close them after some amount of time. Regardless, it is working
well enough that I may not mess with it for now.

Regards,
Gabe Klyber
Juliusz Chroboczek
2016-01-21 09:50:35 UTC
Permalink
Please send patches generated with "diff -u".

-- Juliusz
Gabriel Klyber
2016-01-22 06:16:22 UTC
Permalink
These modifications require Windows Vista or newer. I am not sure how
early you need to define WINVER, but in my environment, mingw.h was
too late. #define FD_SETSIZE 1024 before including winsock2.h is the
most important change and will benefit any builds without making the
other modifications. Without it, select/win32_poll only handles up to
64 connections.

--- ../polipo-master/polipo.h 2015-12-07 07:15:40.000000000 -0700
+++ polipo.h 2016-01-21 22:31:39.900940000 -0700
@@ -26,6 +26,13 @@

#ifndef WIN32
#include <sys/param.h>
+#else
+#ifndef WINVER
+#define WINVER 0x0600
+#endif
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0600
+#endif
#endif

#include <limits.h>

--- ../polipo-master/mingw.h 2015-12-07 07:15:40.000000000 -0700
+++ mingw.h 2016-01-21 22:29:32.762496900 -0700
@@ -37,14 +37,6 @@
/* Unfortunately, there's no hiding it. */
#define HAVE_WINSOCK 1

-#ifndef WINVER
-#define WINVER 0x0501
-#endif
-
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0501
-#endif
-
#ifndef _WIN32_WINDOWS
#define _WIN32_WINDOWS 0x0410
#endif
@@ -56,12 +48,13 @@
/* At time of writing, a fair bit of stuff doesn't work under Mingw.
* Hopefully they will be fixed later (especially the disk-cache).
*/
-#define NO_IPv6 1
-
-#define S_IROTH S_IREAD

/* Pull in winsock2.h for (almost) berkeley sockets. */
+#define FD_SETSIZE 1024
#include <winsock2.h>
+#ifdef HAVE_IPv6
+#include <ws2tcpip.h>
+#endif

// here we smash the errno defines so we can smash the socket
functions later to smash errno. yay!
#ifdef ENOTCONN
@@ -108,17 +102,6 @@
* are copied from linux man pages. A poll() macro is defined to
* call the version in mingw.c.
*/
-#define POLLIN 0x0001 /* There is data to read */
-#define POLLPRI 0x0002 /* There is urgent data to read */
-#define POLLOUT 0x0004 /* Writing now will not block */
-#define POLLERR 0x0008 /* Error condition */
-#define POLLHUP 0x0010 /* Hung up */
-#define POLLNVAL 0x0020 /* Invalid request: fd not open */
-struct pollfd {
- SOCKET fd; /* file descriptor */
- short events; /* requested events */
- short revents; /* returned events */
-};
#define poll(x, y, z) win32_poll(x, y, z)

/* These wrappers do nothing special except set the global errno variable if
Juliusz Chroboczek
2016-01-22 13:21:24 UTC
Permalink
This patch is corrupt (a hunk header is missing). I could fix it up
manually, but I'm wondering if there's anything else that's missing.

-- Juliusz
Gabriel Klyber
2016-01-23 06:08:04 UTC
Permalink
Is gziped base64 okay? Most of these changes are from yuuboshi. I
highlighted the main changes I made in the previous post.

H4sICDwWo1YCA3BhdGNoAKw8aXfbOJKf7V+BeN4klHWYpG65423FlmNt25JXUpLJTs/jo0nIYoci
tSTlY3oyv32rAIIEKdKxelrdz6LAQqFQF6oKQGxnuST1LWk0Tja+62z8+toMIxqcWL63dO4bFmkk
j4f1er0c8EBXtXZd0+tql6jdgdYetNSGKj4EmlX1sFqtSgixS6euanW1R7TeQGsN1E6j2+l1tV4r
6fLzz6Tea+u1Lqnyr59/PiQcw6Xrm9GcRkCGcs5aPpuBY9659DYKyIMZ1MiD79jH8OhuaeWQ/H5I
8GOGIQ0iBQDqZ9HzhpL378n5dHI5/mhcXk+Hi8rpYR3hjhkE69xwyHtyrCxxxOMKazo9rOaBlgVA
bMSARtvAIxr8/H5IDu0yrttO+M0yrRVljJd+FfNeAtiD/bleTAK6TnR90OwP2tBL7/f7upqRQFfr
1zqkil9cAvj5nRxtwqMaOTI3G9exzMjxPaAwjEIrcDbREfleSwAjM8hDPtWxUQbamNYukBfWN4H/
9Fw3t5HPBc86VQ+gh21Gr+8hhrFCRnVEn6ITfJbf/Yav8gh/Mx/Mgjk9rd0EDz7jO66urZrWQn1t
47dgl+NFxN6u18+n6W/Lt4WODCN/jXq7oqZNgzDWwchZUwP6mRGtERfEbqx9UB+H2jVCnzZOQMMa
4VphmPc0fbYsGoaxjkpIQEPrWg5T3Baji3+lOHMNDDG0WdsgoF5kIPJG9GCE1JIm5lLvPlrFDf5y
CcPD35BGDJsEeOfbzwZ/FU/ZWpkBOaaReR+TnzZA58mn6+scxx4cM245R7UGVxAFvjujFmFqbli8
IYPe9bl0M0OIx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nPoZLn9qfN0cU1ncGpKvoBfcXA0ijF4Q
BmIOA5bhbWhsAVR5m8Gq1Ui2Qc3nBeDysKKHHq6n9XXMQsDdkTYyoODmY8Cv2yuK7W/vIMtgfU+I
+MlMX+Psa6hgt2qjDT4HfGUJHnQ6yl7owJPwu0oHB3kk/HoQ/OF4kq7sCdDagKFdgQf4Vdm9ibgr
EyLJ4rQESMsClSsnrAv8ckz8VKKa/OU+mpn2kJMrdaB3G5rWgTAs9w+PNNHu4W9vdztqjrjiHakD
UX0WN/1Eas8GHG6j1XlA2R4vRr3ZvPoordKYDGfLzEGEvPVIXCJV+X0/tZ3s/ByK4+OOt4QABLQ7
EHfdwNGHIcSBNlkG/hqPaAs60n0bVuM2Yaz5xnUipYjoGl6vAgth7z4B/gnbnOS/b2GILzBEpmb+
5+BL9np2btiX3E4JcUh2OUWaqrS9wzZ3tOTUE1tZmuwfQCi6i0vIpT16+P8BTfEAT5UXgeI0FcTH
OmMXXAIsfnOhw87g6Icmf6RUoqEFKqKhxmmC8qMOph06GEZpIh2FALEanFaQ7IJaBZqtgGe6FPBs
HqIbClquUFoMmX4A+98MfLCOsZmZjhm2oVgD9HFYqvgAHqeQyAYd1RICPYYHlgM04dGMZBfIaxBP
w4Vg7oPsK0CYCU1AyENjOEub0pLMHHBhA2FgL2sgciQUNQgNyFUgaCRHz8jc0NTQyBztgB1QMxtI
oh7AkYeyF1TXCOpf8P4TjUygZDFoPQCwIgIpBK0UQEQhaLFAnrY2aKFAcXQmkGENP0sArlgbTQCc
SjnBOmOhm0XRUkQe9KgRzLYp8ixWLRcANfmNoFlKAAA=
Derek Fawcus
2016-01-23 08:47:47 UTC
Permalink
Post by Gabriel Klyber
Is gziped base64 okay? Most of these changes are from yuuboshi. I
highlighted the main changes I made in the previous post.
The MIME structure was missing, but it was possible to decode it.
Attached below as diffs.

DF
Gisle Vanem
2016-01-22 16:10:30 UTC
Permalink
Post by Gabriel Klyber
These modifications require Windows Vista or newer. I am not sure how
early you need to define WINVER, but in my environment, mingw.h was
too late.
I'm not sure if your patch would pull in some Vista+ exports
from ws2_32.dll? Making it impossible to run Polipo on Win-XP.

But to just use 'struct pollfd', one can do:

struct win32_pollfd {
SOCKET fd; /* file descriptor */
short events; /* requested events */
short revents; /* returned events */
};
#define pollfd win32_pollfd
#define poll(x, y, z) win32_poll(x, y, z)


I'm not sure it's a god idea to *require* a specific WINVER
to build Polipo (default here in my SDK 8.1 is 0x0501).
There is AFAICS nothing in Polipo that needs anything more advanced
than is already in Win-XP (0x0501).


--gv
--
--gv
Gabriel Klyber
2016-01-23 00:14:17 UTC
Permalink
I prefer not to use the winsock pollfd strict since polipo does not use the
corresponding and broken WSApoll. I pulled in Windows Vista to get some
IPv6 functionality. Maybe it was for getaddrinfo. I will look at it
tonight, clean up some of the unlink code in diskcache and post a full diff.

Gabe
Post by Gisle Vanem
Post by Gabriel Klyber
These modifications require Windows Vista or newer. I am not sure how
early you need to define WINVER, but in my environment, mingw.h was
too late.
I'm not sure if your patch would pull in some Vista+ exports
from ws2_32.dll? Making it impossible to run Polipo on Win-XP.
struct win32_pollfd {
SOCKET fd; /* file descriptor */
short events; /* requested events */
short revents; /* returned events */
};
#define pollfd win32_pollfd
#define poll(x, y, z) win32_poll(x, y, z)
I'm not sure it's a god idea to *require* a specific WINVER
to build Polipo (default here in my SDK 8.1 is 0x0501).
There is AFAICS nothing in Polipo that needs anything more advanced
than is already in Win-XP (0x0501).
--gv
--
--gv
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Polipo-users mailing list
https://lists.sourceforge.net/lists/listinfo/polipo-users
Gabriel Klyber
2016-01-23 06:05:44 UTC
Permalink
You were right about Windows XP compatibility. Here are the key
changes I made. Full diff is in a follow-up post:
diff -u ../polipo-master/diskcache.c ./diskcache.c
--- ../polipo-master/diskcache.c 2015-12-07 07:15:40.000000000 -0700
+++ ./diskcache.c 2016-01-22 22:39:50.029992000 -0700
@@ -719,6 +719,7 @@
{ "ps", "application/postscript" },
{ "tar", "application/x-tar" },
{ "pac", "application/x-ns-proxy-autoconfig" },
+ { "dat", "application/x-ns-proxy-autoconfig" },
{ "css", "text/css" },
{ "js", "application/x-javascript" },
{ "xml", "text/xml" },
@@ -854,14 +855,14 @@
int dummy;
int code;
AtomPtr headers;
- time_t date, last_modified, expires, polipo_age, polipo_access;
+ time_t date = -1, last_modified = -1, expires = -1, polipo_age =
-1, polipo_access = current_time.tv_sec;
int length;
off_t offset = -1;
int body_offset;
- char *etag;
+ char *etag = NULL;
AtomPtr via;
CacheControlRec cache_control;
- char *location;
+ char *location = NULL;
AtomPtr message;
int dirty = 0;

@@ -1008,8 +1009,10 @@
}
}

- if(location)
+ if(location) {
free(location);
+ location = NULL;
+ }

if(headers) {
if(!object->headers)
@@ -1051,8 +1054,10 @@
if(!object->etag)
object->etag = etag;
else {
- if(etag)
+ if(etag) {
free(etag);
+ etag = NULL;
+ }
}
releaseAtom(message);

@@ -1234,12 +1239,12 @@
rc = writeHeaders(fd, &body_offset, object, data, dsize);
if(rc < 0) {
do_log_error(L_ERROR, errno, "Couldn't write headers");
+ close(fd);
rc = unlink(buf);
if(rc < 0 && errno != ENOENT)
do_log_error(L_ERROR, errno,
"Couldn't unlink truncated entry %s",
scrub(buf));
- close(fd);
return NULL;
}
assert(rc >= body_offset);
@@ -1422,16 +1427,8 @@
/* See writeoutToDisk */
d = 1;
}
-
- if(d) {
- entry->object->flags &= ~OBJECT_DISK_ENTRY_COMPLETE;
- if(entry->filename) {
- urc = unlink(entry->filename);
- if(urc < 0)
- do_log_error(L_WARN, errno,
- "Couldn't unlink %s", scrub(entry->filename));
- }
- } else {
+
+ if(!d) {
if(entry && entry->metadataDirty)
writeoutMetadata(object);
makeDiskEntry(object, 0);
@@ -1446,13 +1443,24 @@
return 0;
}
}
- again:
+
+again:
rc = close(entry->fd);
if(rc < 0 && errno == EINTR)
goto again;

entry->fd = -1;

+ if(d) {
+ entry->object->flags &= ~OBJECT_DISK_ENTRY_COMPLETE;
+ if(entry->filename) {
+ urc = unlink(entry->filename);
+ if(urc < 0)
+ do_log_error(L_WARN, errno,
+ "Couldn't unlink %s", scrub(entry->filename));
+ }
+ }
+
if(entry->filename)
free(entry->filename);
entry->filename = NULL;
@@ -1753,7 +1761,15 @@

rc = writeHeaders(entry->fd, &entry->body_offset, object, NULL, 0);
if(rc == -2) {
+#ifndef WIN32
rc = rewriteEntry(object);
+#else
+ /* This is a hack that deletes the file instead of rewriting it.
+ It would be better to rename the file to a temporary name and
+ copy the contents to a new file with the original name. */
+ rc = destroyDiskEntry(object, 1);
+ rc = makeDiskEntry(object, 1);
+#endif
if(rc < 0) return 0;
return 1;
}
@@ -2433,7 +2449,9 @@
long left = 0, total = 0;

if(diskCacheRoot == NULL ||
- diskCacheRoot->length <= 0 || diskCacheRoot->string[0] != '/')
+ diskCacheRoot->length <= 0 ||
+ !(isalpha(diskCacheRoot->string[0]) &&
(diskCacheRoot->string[1] == ':') &&
+ ((diskCacheRoot->string[2] == '/') ||
(diskCacheRoot->string[2] == '\\'))))
return;

fts_argv[0] = diskCacheRoot->string;
diff -u ../polipo-master/mingw.h ./mingw.h
--- ../polipo-master/mingw.h 2015-12-07 07:15:40.000000000 -0700
+++ ./mingw.h 2016-01-22 22:10:44.091300600 -0700
@@ -56,12 +56,13 @@
/* At time of writing, a fair bit of stuff doesn't work under Mingw.
* Hopefully they will be fixed later (especially the disk-cache).
*/
-#define NO_IPv6 1
-
-#define S_IROTH S_IREAD

/* Pull in winsock2.h for (almost) berkeley sockets. */
+#define FD_SETSIZE 1024
#include <winsock2.h>
+#ifdef HAVE_IPv6
+#include <ws2tcpip.h>
+#endif

// here we smash the errno defines so we can smash the socket
functions later to smash errno. yay!
#ifdef ENOTCONN
Post by Gabriel Klyber
I prefer not to use the winsock pollfd strict since polipo does not use the
corresponding and broken WSApoll. I pulled in Windows Vista to get some IPv6
functionality. Maybe it was for getaddrinfo. I will look at it tonight,
clean up some of the unlink code in diskcache and post a full diff.
Gabe
Post by Gisle Vanem
Post by Gabriel Klyber
These modifications require Windows Vista or newer. I am not sure how
early you need to define WINVER, but in my environment, mingw.h was
too late.
I'm not sure if your patch would pull in some Vista+ exports
from ws2_32.dll? Making it impossible to run Polipo on Win-XP.
struct win32_pollfd {
SOCKET fd; /* file descriptor */
short events; /* requested events */
short revents; /* returned events */
};
#define pollfd win32_pollfd
#define poll(x, y, z) win32_poll(x, y, z)
I'm not sure it's a god idea to *require* a specific WINVER
to build Polipo (default here in my SDK 8.1 is 0x0501).
There is AFAICS nothing in Polipo that needs anything more advanced
than is already in Win-XP (0x0501).
--gv
--
--gv
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Polipo-users mailing list
https://lists.sourceforge.net/lists/listinfo/polipo-users
Juliusz Chroboczek
2016-01-30 18:39:34 UTC
Permalink
Post by Gabriel Klyber
You were right about Windows XP compatibility. Here are the key
changes I made. Full diff is in a follow-up post
Gabriel,

Just so there's no misunderstanding, if you want me to apply Windows
patches you will need to:

1. provide a proper patch series (as generated by git-format-patch or
git-send-email);
2. with proper attribution in the patch header (patches due to yuuboshi
must be attributed to yuuboshi);
3. make sure that it still compiles using Mingw64 on Linux.

Windows XP compatibility should be preserved, unless there are good
reasons not to do so. Compatibility with free development tools (Mingw64)
is a hard requirement.

-- Juliusz

Loading...