1248
|
1 |
diff -urN rtorrent-0.8.2.orig/src/core/curl_event.cc rtorrent-0.8.2/src/core/curl_event.cc
|
|
2 |
--- rtorrent-0.8.2.orig/src/core/curl_event.cc 1969-12-31 19:00:00.000000000 -0500
|
|
3 |
+++ rtorrent-0.8.2/src/core/curl_event.cc 2008-06-10 14:40:41.403064000 -0400
|
|
4 |
@@ -0,0 +1,63 @@
|
|
5 |
+// libTorrent - BitTorrent library
|
|
6 |
+// Copyright (C) 2008 Albert Lee
|
|
7 |
+//
|
|
8 |
+// This program is free software; you can redistribute it and/or modify
|
|
9 |
+// it under the terms of the GNU General Public License as published by
|
|
10 |
+// the Free Software Foundation; either version 2 of the License, or
|
|
11 |
+// (at your option) any later version.
|
|
12 |
+//
|
|
13 |
+// This program is distributed in the hope that it will be useful,
|
|
14 |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 |
+// GNU General Public License for more details.
|
|
17 |
+//
|
|
18 |
+// You should have received a copy of the GNU General Public License
|
|
19 |
+// along with this program; if not, write to the Free Software
|
|
20 |
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 |
+//
|
|
22 |
+// In addition, as a special exception, the copyright holders give
|
|
23 |
+// permission to link the code of portions of this program with the
|
|
24 |
+// OpenSSL library under certain conditions as described in each
|
|
25 |
+// individual source file, and distribute linked combinations
|
|
26 |
+// including the two.
|
|
27 |
+//
|
|
28 |
+// You must obey the GNU General Public License in all respects for
|
|
29 |
+// all of the code used other than OpenSSL. If you modify file(s)
|
|
30 |
+// with this exception, you may extend this exception to your version
|
|
31 |
+// of the file(s), but you are not obligated to do so. If you do not
|
|
32 |
+// wish to do so, delete this exception statement from your version.
|
|
33 |
+// If you delete this exception statement from all source files in the
|
|
34 |
+// program, then also delete it here.
|
|
35 |
+//
|
|
36 |
+// Contact: Jari Sundell <[email protected]>
|
|
37 |
+//
|
|
38 |
+// Skomakerveien 33
|
|
39 |
+// 3185 Skoppum, NORWAY
|
|
40 |
+
|
|
41 |
+#include "config.h"
|
|
42 |
+
|
|
43 |
+#include <torrent/exceptions.h>
|
|
44 |
+
|
|
45 |
+#include "rak/functional.h"
|
|
46 |
+
|
|
47 |
+#include "curl_event.h"
|
|
48 |
+#include "curl_stack.h"
|
|
49 |
+
|
|
50 |
+namespace core {
|
|
51 |
+
|
|
52 |
+void
|
|
53 |
+CurlEvent::event_read() {
|
|
54 |
+ m_stack->perform(m_fileDesc);
|
|
55 |
+}
|
|
56 |
+
|
|
57 |
+void
|
|
58 |
+CurlEvent::event_write() {
|
|
59 |
+ m_stack->perform(m_fileDesc);
|
|
60 |
+}
|
|
61 |
+
|
|
62 |
+void
|
|
63 |
+CurlEvent::event_error() {
|
|
64 |
+ m_stack->perform(m_fileDesc);
|
|
65 |
+}
|
|
66 |
+
|
|
67 |
+}
|
|
68 |
diff -urN rtorrent-0.8.2.orig/src/core/curl_event.h rtorrent-0.8.2/src/core/curl_event.h
|
|
69 |
--- rtorrent-0.8.2.orig/src/core/curl_event.h 1969-12-31 19:00:00.000000000 -0500
|
|
70 |
+++ rtorrent-0.8.2/src/core/curl_event.h 2008-06-10 14:37:59.758119000 -0400
|
|
71 |
@@ -0,0 +1,61 @@
|
|
72 |
+// libTorrent - BitTorrent library
|
|
73 |
+// Copyright (C) 2008 Albert Lee
|
|
74 |
+//
|
|
75 |
+// This program is free software; you can redistribute it and/or modify
|
|
76 |
+// it under the terms of the GNU General Public License as published by
|
|
77 |
+// the Free Software Foundation; either version 2 of the License, or
|
|
78 |
+// (at your option) any later version.
|
|
79 |
+//
|
|
80 |
+// This program is distributed in the hope that it will be useful,
|
|
81 |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
82 |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
83 |
+// GNU General Public License for more details.
|
|
84 |
+//
|
|
85 |
+// You should have received a copy of the GNU General Public License
|
|
86 |
+// along with this program; if not, write to the Free Software
|
|
87 |
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
88 |
+//
|
|
89 |
+// In addition, as a special exception, the copyright holders give
|
|
90 |
+// permission to link the code of portions of this program with the
|
|
91 |
+// OpenSSL library under certain conditions as described in each
|
|
92 |
+// individual source file, and distribute linked combinations
|
|
93 |
+// including the two.
|
|
94 |
+//
|
|
95 |
+// You must obey the GNU General Public License in all respects for
|
|
96 |
+// all of the code used other than OpenSSL. If you modify file(s)
|
|
97 |
+// with this exception, you may extend this exception to your version
|
|
98 |
+// of the file(s), but you are not obligated to do so. If you do not
|
|
99 |
+// wish to do so, delete this exception statement from your version.
|
|
100 |
+// If you delete this exception statement from all source files in the
|
|
101 |
+// program, then also delete it here.
|
|
102 |
+//
|
|
103 |
+// Contact: Jari Sundell <[email protected]>
|
|
104 |
+//
|
|
105 |
+// Skomakerveien 33
|
|
106 |
+// 3185 Skoppum, NORWAY
|
|
107 |
+
|
|
108 |
+#ifndef RTORRENT_CORE_CURL_EVENT_H
|
|
109 |
+#define RTORRENT_CORE_CURL_EVENT_H
|
|
110 |
+
|
|
111 |
+#include <torrent/event.h>
|
|
112 |
+
|
|
113 |
+namespace core {
|
|
114 |
+
|
|
115 |
+class CurlStack;
|
|
116 |
+
|
|
117 |
+class CurlEvent : public torrent::Event {
|
|
118 |
+public:
|
|
119 |
+ CurlEvent(CurlStack* s, int fd) : m_stack(s) { m_fileDesc = fd; }
|
|
120 |
+ virtual ~CurlEvent() {}
|
|
121 |
+
|
|
122 |
+ virtual void event_read();
|
|
123 |
+ virtual void event_write();
|
|
124 |
+ virtual void event_error();
|
|
125 |
+
|
|
126 |
+protected:
|
|
127 |
+ CurlStack* m_stack;
|
|
128 |
+};
|
|
129 |
+
|
|
130 |
+}
|
|
131 |
+
|
|
132 |
+#endif
|
|
133 |
diff -urN rtorrent-0.8.2.orig/src/core/curl_stack.cc rtorrent-0.8.2/src/core/curl_stack.cc
|
|
134 |
--- rtorrent-0.8.2.orig/src/core/curl_stack.cc 2008-05-07 08:19:11.000000000 -0400
|
|
135 |
+++ rtorrent-0.8.2/src/core/curl_stack.cc 2008-06-10 14:32:12.992249000 -0400
|
|
136 |
@@ -44,13 +44,77 @@
|
|
137 |
#include "rak/functional.h"
|
|
138 |
#include "curl_get.h"
|
|
139 |
#include "curl_stack.h"
|
|
140 |
+#include "curl_event.h"
|
|
141 |
+
|
|
142 |
+#include "poll_manager.h"
|
|
143 |
|
|
144 |
namespace core {
|
|
145 |
|
|
146 |
-CurlStack::CurlStack() :
|
|
147 |
+#if LIBCURL_VERSION_NUM >= 0x071000
|
|
148 |
+static void timer_callback(curl_socket_t socket, int action, void* event_data)
|
|
149 |
+{
|
|
150 |
+ CurlStack* s = static_cast<CurlStack*>(event_data);
|
|
151 |
+ CURLM* handle = (CURLM*)(s->handle());
|
|
152 |
+ CURLMcode rc;
|
|
153 |
+ int count;
|
|
154 |
+
|
|
155 |
+ while (CURLM_CALL_MULTI_PERFORM == (rc = curl_multi_socket(handle, CURL_SOCKET_TIMEOUT, &count)));
|
|
156 |
+}
|
|
157 |
+#endif
|
|
158 |
+
|
|
159 |
+static int socket_callback(CURL *easy, curl_socket_t socket, int action, void* socket_data, void* assign_data)
|
|
160 |
+{
|
|
161 |
+ CurlStack* stack = static_cast<CurlStack*>(socket_data);
|
|
162 |
+ torrent::Event* event = static_cast<torrent::Event*>(assign_data);
|
|
163 |
+ torrent::Poll* poll = stack->poll();
|
|
164 |
+
|
|
165 |
+ if (!event) {
|
|
166 |
+ event = new CurlEvent(stack, socket);
|
|
167 |
+ curl_multi_assign((CURLM*)(stack->handle()), socket, event);
|
|
168 |
+ if (socket > poll->open_max())
|
|
169 |
+ throw torrent::internal_error("Socket too large for " + poll->open_max());
|
|
170 |
+ poll->open(event);
|
|
171 |
+ } else {
|
|
172 |
+ poll->remove_read(event);
|
|
173 |
+ poll->remove_write(event);
|
|
174 |
+ poll->remove_error(event);
|
|
175 |
+ }
|
|
176 |
+
|
|
177 |
+ switch (action) {
|
|
178 |
+ case CURL_POLL_NONE:
|
|
179 |
+ break;
|
|
180 |
+ case CURL_POLL_IN:
|
|
181 |
+ poll->insert_read(event);
|
|
182 |
+ break;
|
|
183 |
+ case CURL_POLL_OUT:
|
|
184 |
+ poll->insert_write(event);
|
|
185 |
+ break;
|
|
186 |
+ case CURL_POLL_INOUT:
|
|
187 |
+ poll->insert_read(event);
|
|
188 |
+ poll->insert_write(event);
|
|
189 |
+ break;
|
|
190 |
+ case CURL_POLL_REMOVE:
|
|
191 |
+ poll->close(event);
|
|
192 |
+ delete event;
|
|
193 |
+ break;
|
|
194 |
+ default:
|
|
195 |
+ throw torrent::internal_error("socket_callback(...) called with unsupported action");
|
|
196 |
+ }
|
|
197 |
+
|
|
198 |
+ return 0;
|
|
199 |
+}
|
|
200 |
+
|
|
201 |
+CurlStack::CurlStack(torrent::Poll* poll) :
|
|
202 |
m_handle((void*)curl_multi_init()),
|
|
203 |
+ m_poll(poll),
|
|
204 |
m_active(0),
|
|
205 |
m_maxActive(32) {
|
|
206 |
+ curl_multi_setopt(m_handle, CURLMOPT_SOCKETDATA, this);
|
|
207 |
+ curl_multi_setopt(m_handle, CURLMOPT_SOCKETFUNCTION, socket_callback);
|
|
208 |
+#if LIBCURL_VERSION_NUM >= 0x071000
|
|
209 |
+ curl_multi_setopt(m_handle, CURLMOPT_TIMERDATA, this);
|
|
210 |
+ curl_multi_setopt(m_handle, CURLMOPT_TIMERFUNCTION, timer_callback);
|
|
211 |
+#endif
|
|
212 |
}
|
|
213 |
|
|
214 |
CurlStack::~CurlStack() {
|
|
215 |
@@ -66,35 +130,59 @@
|
|
216 |
}
|
|
217 |
|
|
218 |
void
|
|
219 |
-CurlStack::perform() {
|
|
220 |
+CurlStack::process() {
|
|
221 |
+ int t;
|
|
222 |
+ CURLMsg* msg;
|
|
223 |
+
|
|
224 |
+ while ((msg = curl_multi_info_read((CURLM*)m_handle, &t)) != NULL) {
|
|
225 |
+ if (msg->msg != CURLMSG_DONE)
|
|
226 |
+ throw torrent::internal_error("CurlStack::process() msg->msg != CURLMSG_DONE.");
|
|
227 |
+
|
|
228 |
+ iterator itr = std::find_if(begin(), end(), rak::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
|
|
229 |
+
|
|
230 |
+ if (itr == end())
|
|
231 |
+ throw torrent::internal_error("Could not find CurlGet with the right easy_handle.");
|
|
232 |
+
|
|
233 |
+ if (msg->data.result == CURLE_OK)
|
|
234 |
+ (*itr)->signal_done().emit();
|
|
235 |
+ else
|
|
236 |
+ (*itr)->signal_failed().emit(curl_easy_strerror(msg->data.result));
|
|
237 |
+ }
|
|
238 |
+}
|
|
239 |
+
|
|
240 |
+void
|
|
241 |
+CurlStack::perform(curl_socket_t sockfd) {
|
|
242 |
CURLMcode code;
|
|
243 |
|
|
244 |
do {
|
|
245 |
int count;
|
|
246 |
- code = curl_multi_perform((CURLM*)m_handle, &count);
|
|
247 |
+ code = curl_multi_socket((CURLM*)m_handle, sockfd, &count);
|
|
248 |
|
|
249 |
if (code > 0)
|
|
250 |
- throw torrent::internal_error("Error calling curl_multi_perform.");
|
|
251 |
+ throw torrent::internal_error("Error calling curl_multi_socket.");
|
|
252 |
|
|
253 |
if ((unsigned int)count != size()) {
|
|
254 |
// Done with some handles.
|
|
255 |
- int t;
|
|
256 |
- CURLMsg* msg;
|
1263
|
257 |
+ process();
|
1248
|
258 |
+ }
|
|
259 |
|
|
260 |
- while ((msg = curl_multi_info_read((CURLM*)m_handle, &t)) != NULL) {
|
|
261 |
- if (msg->msg != CURLMSG_DONE)
|
|
262 |
- throw torrent::internal_error("CurlStack::perform() msg->msg != CURLMSG_DONE.");
|
|
263 |
+ } while (code == CURLM_CALL_MULTI_PERFORM);
|
|
264 |
+}
|
|
265 |
|
|
266 |
- iterator itr = std::find_if(begin(), end(), rak::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
|
|
267 |
+void
|
|
268 |
+CurlStack::perform() {
|
|
269 |
+ CURLMcode code;
|
|
270 |
|
|
271 |
- if (itr == end())
|
|
272 |
- throw torrent::internal_error("Could not find CurlGet with the right easy_handle.");
|
|
273 |
-
|
|
274 |
- if (msg->data.result == CURLE_OK)
|
|
275 |
- (*itr)->signal_done().emit();
|
|
276 |
- else
|
|
277 |
- (*itr)->signal_failed().emit(curl_easy_strerror(msg->data.result));
|
|
278 |
- }
|
|
279 |
+ do {
|
|
280 |
+ int count;
|
|
281 |
+ code = curl_multi_perform((CURLM*)m_handle, &count);
|
|
282 |
+
|
|
283 |
+ if (code > 0)
|
|
284 |
+ throw torrent::internal_error("Error calling curl_multi_perform.");
|
|
285 |
+
|
|
286 |
+ if ((unsigned int)count != size()) {
|
|
287 |
+ // Done with some handles.
|
1263
|
288 |
+ process();
|
1248
|
289 |
}
|
|
290 |
|
|
291 |
} while (code == CURLM_CALL_MULTI_PERFORM);
|
|
292 |
diff -urN rtorrent-0.8.2.orig/src/core/curl_stack.h rtorrent-0.8.2/src/core/curl_stack.h
|
|
293 |
--- rtorrent-0.8.2.orig/src/core/curl_stack.h 2008-05-07 08:19:11.000000000 -0400
|
|
294 |
+++ rtorrent-0.8.2/src/core/curl_stack.h 2008-06-10 13:54:21.695024000 -0400
|
|
295 |
@@ -40,11 +40,19 @@
|
|
296 |
#include <deque>
|
|
297 |
#include <string>
|
|
298 |
#include <sigc++/functors/slot.h>
|
|
299 |
+#include <curl/curl.h>
|
|
300 |
+
|
|
301 |
+class torrent::Poll;
|
|
302 |
|
|
303 |
namespace core {
|
|
304 |
|
|
305 |
class CurlGet;
|
|
306 |
|
|
307 |
+#if LIBCURL_VERSION_NUM >= 0x071000
|
|
308 |
+static void timer_callback(curl_socket_t socket, int action, void* event_data);
|
|
309 |
+#endif
|
|
310 |
+static int socket_callback(CURL *easy, curl_socket_t socket, int action, void* socket_data, void* assign_data);
|
|
311 |
+
|
|
312 |
// By using a deque instead of vector we allow for cheaper removal of
|
|
313 |
// the oldest elements, those that will be first in the in the
|
|
314 |
// deque.
|
|
315 |
@@ -76,16 +84,19 @@
|
|
316 |
using base_type::size;
|
|
317 |
using base_type::empty;
|
|
318 |
|
|
319 |
- CurlStack();
|
|
320 |
+ CurlStack(torrent::Poll* poll);
|
|
321 |
~CurlStack();
|
|
322 |
|
|
323 |
CurlGet* new_object();
|
|
324 |
|
|
325 |
+ void perform(curl_socket_t sockfd);
|
|
326 |
void perform();
|
|
327 |
|
|
328 |
// TODO: Set fd_set's only once?
|
|
329 |
unsigned int fdset(fd_set* readfds, fd_set* writefds, fd_set* exceptfds);
|
|
330 |
|
|
331 |
+ void* handle() { return m_handle; }
|
|
332 |
+ torrent::Poll* poll() { return m_poll; }
|
|
333 |
unsigned int active() const { return m_active; }
|
|
334 |
unsigned int max_active() const { return m_maxActive; }
|
|
335 |
void set_max_active(unsigned int a) { m_maxActive = a; }
|
|
336 |
@@ -111,12 +122,14 @@
|
|
337 |
protected:
|
|
338 |
void add_get(CurlGet* get);
|
|
339 |
void remove_get(CurlGet* get);
|
|
340 |
+ void process();
|
|
341 |
|
|
342 |
private:
|
|
343 |
CurlStack(const CurlStack&);
|
|
344 |
void operator = (const CurlStack&);
|
|
345 |
|
|
346 |
void* m_handle;
|
|
347 |
+ torrent::Poll* m_poll;
|
|
348 |
|
|
349 |
unsigned int m_active;
|
|
350 |
unsigned int m_maxActive;
|
|
351 |
diff -urN rtorrent-0.8.2.orig/src/core/Makefile.am rtorrent-0.8.2/src/core/Makefile.am
|
|
352 |
--- rtorrent-0.8.2.orig/src/core/Makefile.am 2008-06-10 15:13:49.786345331 -0400
|
|
353 |
+++ rtorrent-0.8.2/src/core/Makefile.am 2008-06-10 02:25:32.809721000 -0400
|
|
354 |
@@ -1,6 +1,8 @@
|
|
355 |
noinst_LIBRARIES = libsub_core.a
|
|
356 |
|
|
357 |
libsub_core_a_SOURCES = \
|
|
358 |
+ curl_event.cc \
|
|
359 |
+ curl_event.h \
|
|
360 |
curl_get.cc \
|
|
361 |
curl_get.h \
|
|
362 |
curl_stack.cc \
|
|
363 |
diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_epoll.cc rtorrent-0.8.2/src/core/poll_manager_epoll.cc
|
|
364 |
--- rtorrent-0.8.2.orig/src/core/poll_manager_epoll.cc 2008-05-07 08:19:11.000000000 -0400
|
|
365 |
+++ rtorrent-0.8.2/src/core/poll_manager_epoll.cc 2008-06-10 14:17:27.568558000 -0400
|
|
366 |
@@ -67,6 +67,7 @@
|
|
367 |
torrent::perform();
|
|
368 |
timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
|
|
369 |
|
|
370 |
+#if 0
|
|
371 |
if (!m_httpStack.empty()) {
|
|
372 |
// When we're using libcurl we need to use select, but as this is
|
|
373 |
// inefficient we try avoiding it whenever possible.
|
|
374 |
@@ -101,6 +102,7 @@
|
|
375 |
// Clear the timeout since we've already used it in the select call.
|
|
376 |
timeout = rak::timer();
|
|
377 |
}
|
|
378 |
+#endif
|
|
379 |
|
|
380 |
// Yes, below is how much code really *should* have been in this
|
|
381 |
// function. ;)
|
|
382 |
diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_kqueue.cc rtorrent-0.8.2/src/core/poll_manager_kqueue.cc
|
|
383 |
--- rtorrent-0.8.2.orig/src/core/poll_manager_kqueue.cc 2008-05-07 08:19:11.000000000 -0400
|
|
384 |
+++ rtorrent-0.8.2/src/core/poll_manager_kqueue.cc 2008-06-10 14:17:31.672907000 -0400
|
|
385 |
@@ -68,6 +68,7 @@
|
|
386 |
torrent::perform();
|
|
387 |
timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
|
|
388 |
|
|
389 |
+#if 0
|
|
390 |
if (!m_httpStack.empty()) {
|
|
391 |
// When we're using libcurl we need to use select, but as this is
|
|
392 |
// inefficient we try avoiding it whenever possible.
|
|
393 |
@@ -102,6 +103,7 @@
|
|
394 |
// Clear the timeout since we've already used it in the select call.
|
|
395 |
timeout = rak::timer();
|
|
396 |
}
|
|
397 |
+#endif
|
|
398 |
|
|
399 |
// Yes, below is how much code really *should* have been in this
|
|
400 |
// function. ;)
|
|
401 |
diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_ports.cc rtorrent-0.8.2/src/core/poll_manager_ports.cc
|
|
402 |
--- rtorrent-0.8.2.orig/src/core/poll_manager_ports.cc 2008-06-10 15:13:49.790288665 -0400
|
|
403 |
+++ rtorrent-0.8.2/src/core/poll_manager_ports.cc 2008-06-10 14:31:09.552278000 -0400
|
|
404 |
@@ -68,6 +68,7 @@
|
|
405 |
torrent::perform();
|
|
406 |
timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
|
|
407 |
|
|
408 |
+#if 0
|
|
409 |
if (!m_httpStack.empty()) {
|
|
410 |
// When we're using libcurl we need to use select, but as this is
|
|
411 |
// inefficient we try avoiding it whenever possible.
|
|
412 |
@@ -103,6 +104,7 @@
|
|
413 |
// Clear the timeout since we've already used it in the select call.
|
|
414 |
timeout = rak::timer();
|
|
415 |
}
|
|
416 |
+#endif
|
|
417 |
|
|
418 |
// Yes, below is how much code really *should* have been in this
|
|
419 |
// function. ;)
|
|
420 |
diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_select.cc rtorrent-0.8.2/src/core/poll_manager_select.cc
|
|
421 |
--- rtorrent-0.8.2.orig/src/core/poll_manager_select.cc 2008-05-07 08:19:11.000000000 -0400
|
|
422 |
+++ rtorrent-0.8.2/src/core/poll_manager_select.cc 2008-06-10 02:37:17.419878000 -0400
|
|
423 |
@@ -77,16 +77,16 @@
|
|
424 |
|
|
425 |
unsigned int maxFd = static_cast<torrent::PollSelect*>(m_poll)->fdset(m_readSet, m_writeSet, m_errorSet);
|
|
426 |
|
|
427 |
- if (!m_httpStack.empty())
|
|
428 |
- maxFd = std::max(maxFd, m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet));
|
|
429 |
+ if (!m_httpStack->empty())
|
|
430 |
+ maxFd = std::max(maxFd, m_httpStack->fdset(m_readSet, m_writeSet, m_errorSet));
|
|
431 |
|
|
432 |
timeval t = timeout.tval();
|
|
433 |
|
|
434 |
if (select(maxFd + 1, m_readSet, m_writeSet, m_errorSet, &t) == -1)
|
|
435 |
return check_error();
|
|
436 |
|
|
437 |
- if (!m_httpStack.empty())
|
|
438 |
- m_httpStack.perform();
|
|
439 |
+ if (!m_httpStack->empty())
|
|
440 |
+ m_httpStack->perform();
|
|
441 |
|
|
442 |
torrent::perform();
|
|
443 |
static_cast<torrent::PollSelect*>(m_poll)->perform(m_readSet, m_writeSet, m_errorSet);
|
|
444 |
diff -urN rtorrent-0.8.2.orig/src/core/poll_manager.cc rtorrent-0.8.2/src/core/poll_manager.cc
|
|
445 |
--- rtorrent-0.8.2.orig/src/core/poll_manager.cc 2008-05-07 08:19:11.000000000 -0400
|
|
446 |
+++ rtorrent-0.8.2/src/core/poll_manager.cc 2008-06-10 02:35:35.523377000 -0400
|
|
447 |
@@ -44,7 +44,8 @@
|
|
448 |
namespace core {
|
|
449 |
|
|
450 |
PollManager::PollManager(torrent::Poll* poll) :
|
|
451 |
- m_poll(poll) {
|
|
452 |
+ m_poll(poll),
|
|
453 |
+ m_httpStack(new CurlStack(poll)) {
|
|
454 |
|
|
455 |
if (m_poll == NULL)
|
|
456 |
throw std::logic_error("PollManager::PollManager(...) received poll == NULL");
|
|
457 |
@@ -74,10 +75,11 @@
|
|
458 |
|
|
459 |
// Call this so curl has valid fd_set pointers if curl_multi_perform
|
|
460 |
// is called before it gets set when polling.
|
|
461 |
- m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet);
|
|
462 |
+ m_httpStack->fdset(m_readSet, m_writeSet, m_errorSet);
|
|
463 |
}
|
|
464 |
|
|
465 |
PollManager::~PollManager() {
|
|
466 |
+ delete m_httpStack;
|
|
467 |
delete m_poll;
|
|
468 |
|
|
469 |
#if defined USE_VARIABLE_FDSET
|
|
470 |
diff -urN rtorrent-0.8.2.orig/src/core/poll_manager.h rtorrent-0.8.2/src/core/poll_manager.h
|
|
471 |
--- rtorrent-0.8.2.orig/src/core/poll_manager.h 2008-05-07 08:19:11.000000000 -0400
|
|
472 |
+++ rtorrent-0.8.2/src/core/poll_manager.h 2008-06-10 02:34:57.898088000 -0400
|
|
473 |
@@ -58,7 +58,7 @@
|
|
474 |
|
|
475 |
unsigned int get_open_max() const { return m_poll->open_max(); }
|
|
476 |
|
|
477 |
- CurlStack* get_http_stack() { return &m_httpStack; }
|
|
478 |
+ CurlStack* get_http_stack() { return m_httpStack; }
|
|
479 |
torrent::Poll* get_torrent_poll() { return m_poll; }
|
|
480 |
|
|
481 |
virtual void poll(rak::timer timeout) = 0;
|
|
482 |
@@ -70,7 +70,7 @@
|
|
483 |
void check_error();
|
|
484 |
|
|
485 |
torrent::Poll* m_poll;
|
|
486 |
- CurlStack m_httpStack;
|
|
487 |
+ CurlStack* m_httpStack;
|
|
488 |
|
|
489 |
unsigned int m_setSize;
|
|
490 |
fd_set* m_readSet;
|