forked from clowwindy/iProxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolipo.diff
220 lines (204 loc) · 6.13 KB
/
polipo.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
diff -u polipo-20091115.orig/chunk.c polipo-20091115/chunk.c
--- polipo-20091115.orig/chunk.c 2009-12-12 20:43:56.000000000 +0100
+++ polipo-20091115/chunk.c 2010-09-25 23:03:33.000000000 +0200
@@ -320,7 +320,7 @@
chunkArenas = malloc(numArenas * sizeof(ChunkArenaRec));
if(chunkArenas == NULL) {
do_log(L_ERROR, "Couldn't allocate chunk arenas.\n");
- polipoExit();
+ polipo_exit();
}
for(i = 0; i < numArenas; i++) {
chunkArenas[i].bitmap = EMPTY_BITMAP;
diff -u polipo-20091115.orig/client.c polipo-20091115/client.c
--- polipo-20091115.orig/client.c 2009-12-12 20:43:56.000000000 +0100
+++ polipo-20091115/client.c 2010-09-25 23:03:33.000000000 +0200
@@ -34,7 +34,7 @@
newevent = schedule_accept(fd, httpAccept, NULL);
if(newevent == NULL) {
do_log(L_ERROR, "Couldn't schedule accept.\n");
- polipoExit();
+ polipo_exit();
}
}
return 1;
@@ -64,12 +64,12 @@
sizeof(request->fd), &request->fd);
if(!again) {
do_log(L_ERROR, "Couldn't schedule accept -- aborting.\n");
- polipoExit();
+ polipo_exit();
}
}
return 1;
} else {
- polipoExit();
+ polipo_exit();
return 1;
}
}
@@ -306,7 +306,7 @@
if(!handler) {
do_log(L_ERROR,
"Couldn't schedule delayed shutdown -- aborting.\n");
- polipoExit();
+ polipo_exit();
}
}
return 1;
diff -u polipo-20091115.orig/event.c polipo-20091115/event.c
--- polipo-20091115.orig/event.c 2009-12-12 20:43:56.000000000 +0100
+++ polipo-20091115/event.c 2010-09-25 23:03:33.000000000 +0200
@@ -43,6 +43,8 @@
static int fds_invalid = 0;
+static int exit_pipe[2] = {0,0};
+
static inline int
timeval_cmp(struct timeval *t1, struct timeval *t2)
{
@@ -141,6 +143,13 @@
poll_fds = NULL;
fdEvents = NULL;
fdEventsLast = NULL;
+
+ if (pipe(exit_pipe) != 0) {
+ fprintf(stderr, "Could not create exit pipe\n");
+ return;
+ }
+
+ allocateFdEventNum(exit_pipe[0]);
}
void
@@ -180,6 +189,9 @@
sa.sa_flags = 0;
sigaction(SIGUSR2, &sa, NULL);
#endif
+
+ close(exit_pipe[0]);
+ close(exit_pipe[1]);
}
#ifdef HAVE_FORK
@@ -627,6 +639,8 @@
FdEventHandlerPtr event;
int fd0;
+ exitFlag = 0;
+
gettimeofday(¤t_time, NULL);
while(1) {
@@ -827,8 +841,12 @@
in_signalCondition--;
}
+// -----------------
+
void
-polipoExit()
+polipo_exit()
{
exitFlag = 3;
-}
+ char c = 0;
+ write(exit_pipe[1], &c, 1);
+}
\ No newline at end of file
diff -u polipo-20091115.orig/event.h polipo-20091115/event.h
--- polipo-20091115.orig/event.h 2009-12-12 20:43:56.000000000 +0100
+++ polipo-20091115/event.h 2010-09-25 23:03:33.000000000 +0200
@@ -85,4 +85,4 @@
int dsize, void *data);
void unregisterConditionHandler(ConditionHandlerPtr);
void abortConditionHandler(ConditionHandlerPtr);
-void polipoExit(void);
+void polipo_exit(void);
diff -u polipo-20091115.orig/io.c polipo-20091115/io.c
--- polipo-20091115.orig/io.c 2009-12-12 20:43:56.000000000 +0100
+++ polipo-20091115/io.c 2010-09-25 23:03:33.000000000 +0200
@@ -788,7 +788,7 @@
return NULL;
}
- do_log(L_INFO, "Established listening socket on port %d.\n", port);
+ // do_log(L_INFO, "Established listening socket on port %d.\n", port);
return schedule_accept(fd, handler, data);
}
diff -u polipo-20091115.orig/local.c polipo-20091115/local.c
--- polipo-20091115.orig/local.c 2009-12-12 20:43:56.000000000 +0100
+++ polipo-20091115/local.c 2010-09-25 23:03:33.000000000 +0200
@@ -541,7 +541,7 @@
} while (rc < 0 && errno == EINTR);
if(rc < 0) {
do_log_error(L_ERROR, errno, "Couldn't restore signal mask");
- polipoExit();
+ polipo_exit();
}
return;
}
@@ -554,7 +554,7 @@
} while (rc < 0 && errno == EINTR);
if(rc < 0) {
do_log_error(L_ERROR, errno, "Couldn't restore signal mask");
- polipoExit();
+ polipo_exit();
return;
}
diff -u polipo-20091115.orig/main.c polipo-20091115/main.c
--- polipo-20091115.orig/main.c 2009-12-12 20:43:56.000000000 +0100
+++ polipo-20091115/main.c 2010-09-25 23:03:33.000000000 +0200
@@ -38,14 +38,20 @@
fprintf(stderr, " -c: specify the configuration file to use.\n");
}
+extern ConfigVariablePtr configVariables;
+
int
-main(int argc, char **argv)
+polipo_main(int argc, char **argv)
{
FdEventHandlerPtr listener;
int i;
int rc;
int expire = 0, printConfig = 0;
+ configFile = NULL;
+ pidFile = NULL;
+ configVariables = NULL;
+
initAtoms();
CONFIG_VARIABLE(daemonise, CONFIG_BOOLEAN, "Run as a daemon");
CONFIG_VARIABLE(pidFile, CONFIG_ATOM, "File with pid of running daemon.");
@@ -163,7 +169,9 @@
}
eventLoop();
+
+ close(listener->fd);
if(pidFile) unlink(pidFile->string);
return 0;
-}
+}
\ No newline at end of file
diff -u polipo-20091115.orig/md5.h polipo-20091115/md5.h
--- polipo-20091115.orig/md5.h 2009-12-12 20:43:56.000000000 +0100
+++ polipo-20091115/md5.h 2010-09-25 23:03:33.000000000 +0200
@@ -40,6 +40,7 @@
/* typedef a 32-bit type */
typedef uint32_t UINT4;
+//typedef unsigned int UINT4;
/* Data structure for MD5 (Message-Digest) computation */
typedef struct {
diff -u polipo-20091115.orig/server.c polipo-20091115/server.c
--- polipo-20091115.orig/server.c 2009-12-12 20:43:56.000000000 +0100
+++ polipo-20091115/server.c 2010-09-25 23:03:33.000000000 +0200
@@ -159,7 +159,7 @@
expireServersHandler, 0, NULL);
if(!e) {
do_log(L_ERROR, "Couldn't schedule server expiry.\n");
- polipoExit();
+ polipo_exit();
}
return 1;
}
@@ -1359,7 +1359,7 @@
if(!handler) {
do_log(L_ERROR,
"Couldn't schedule delayed finish -- aborting.\n");
- polipoExit();
+ polipo_exit();
}
}
}