The unified diff between revisions [750f4172..] and [b9ef2977..] is displayed below. It can also be downloaded as a raw diff.
#
#
# add_file "src/dump_storelog.c"
# content [e708a55bd0b15c97772181795c78eef592323abe]
#
# patch "src/forward.c"
# from [0cd445517e0ef996cf13bf0240590d59f635a1ac]
# to [254eaea3ca5b17eca842698617ef8c65ce15a8bf]
#
============================================================
--- src/dump_storelog.c e708a55bd0b15c97772181795c78eef592323abe
+++ src/dump_storelog.c e708a55bd0b15c97772181795c78eef592323abe
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "squid.h"
+
+
+void
+usage(void)
+{
+ printf("ERROR: I need the path to the swap log!\n");
+ exit(1);
+}
+
+#define NUMPERGO 1024
+
+void
+parse_store_records(storeSwapLogData *s, int num)
+{
+ int i;
+ printf("read %d records\n", num);
+ for (i = 0; i < num; i++) {
+#if 0
+ printf("Object: Op %s, lastref %d, timestamp %d, size %d, lastmod %d\n",
+ swap_log_op_str[(int)s[i].op],
+ (int) s[i].lastref,
+ (int) s[i].timestamp,
+ (int) s[i].swap_file_sz,
+ (int) s[i].lastmod);
+#endif
+ printf("%d\n", s[i].swap_file_sz);
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ storeSwapLogData s[NUMPERGO];
+ size_t ss = sizeof(s);
+ int fd, retval;
+
+ if (argc < 2) {
+ usage();
+ }
+ printf("NOTICE: opening: %s\n", argv[1]);
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0) {
+ perror("open");
+ exit(1);
+ }
+ do {
+ retval = read(fd, s, ss);
+ if (retval <= 0)
+ break;
+ parse_store_records(s, retval / sizeof(storeSwapLogData));
+ } while (retval > 0);
+
+ close(fd);
+ exit(0);
+}
============================================================
--- src/forward.c 0cd445517e0ef996cf13bf0240590d59f635a1ac
+++ src/forward.c 254eaea3ca5b17eca842698617ef8c65ce15a8bf
@@ -742,8 +742,10 @@ fwdCheckDeferRead(int fd, void *data)
int i = delayMostBytesWanted(mem, INT_MAX);
if (0 == i) {
#if HAVE_EPOLL
- mem->serverfd=fd;
- commDeferFD(fd);
+ if (fd >= 0) {
+ mem->serverfd=fd;
+ commDeferFD(fd);
+ }
#endif
return 1;
}
@@ -764,16 +766,16 @@ fwdCheckDeferRead(int fd, void *data)
* is disk clients pending on a too large object being fetched and a
* few other corner cases.
*/
- if (mem->inmem_hi - mem->inmem_lo > SM_PAGE_SIZE + Config.Store.maxInMemObjSize + READ_AHEAD_GAP) {
+ if (fd >= 0 && mem->inmem_hi - mem->inmem_lo > SM_PAGE_SIZE + Config.Store.maxInMemObjSize + READ_AHEAD_GAP) {
+#if HAVE_EPOLL
EBIT_SET(e->flags, ENTRY_DEFER_READ);
-#if HAVE_EPOLL
mem->serverfd=fd;
commDeferFD(fd);
#endif
return 1;
}
}
- if (mem->inmem_hi - storeLowestMemReaderOffset(e) > READ_AHEAD_GAP) {
+ if (fd >= 0 && mem->inmem_hi - storeLowestMemReaderOffset(e) > READ_AHEAD_GAP) {
EBIT_SET(e->flags, ENTRY_DEFER_READ);
#if HAVE_EPOLL
mem->serverfd=fd;