summaryrefslogtreecommitdiff
path: root/net-p2p/amule/files/amule-2.3.3-boost-1.87.patch
blob: 10256c6238eb17534c68c7b4b437ca5173a59536 (plain)
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
From 212b1891da96750ca602df05b575b4d679ca6f1e Mon Sep 17 00:00:00 2001
From: Luigi 'Comio' Mantellini <luigi.mantellini@gmail.com>
Date: Mon, 16 Dec 2024 07:53:11 +0100
Subject: [PATCH] Fix build with Boost 1.87 that removes deprecated asio
 methods

---
 src/LibSocketAsio.cpp | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/LibSocketAsio.cpp b/src/LibSocketAsio.cpp
index 5f8b02652..8e15c8635 100644
--- a/src/LibSocketAsio.cpp
+++ b/src/LibSocketAsio.cpp
@@ -70,7 +70,7 @@
 
 using namespace boost::asio;
 using namespace boost::system;	// for error_code
-static io_service s_io_service;
+static io_context s_io_service;
 
 // Number of threads in the Asio thread pool
 const int CAsioService::m_numberOfThreads = 4;
@@ -265,7 +265,7 @@ public:
 		AddDebugLogLineF(logAsio, CFormat(wxT("Write %d %s")) % nbytes % m_IP);
 		m_sendBuffer = new char[nbytes];
 		memcpy(m_sendBuffer, buf, nbytes);
-		m_strand.dispatch(boost::bind(& CAsioSocketImpl::DispatchWrite, this, nbytes));
+		dispatch(m_strand, boost::bind(& CAsioSocketImpl::DispatchWrite, this, nbytes));
 		m_ErrorCode = 0;
 		return nbytes;
 	}
@@ -279,7 +279,7 @@ public:
 			if (m_sync || s_io_service.stopped()) {
 				DispatchClose();
 			} else {
-				m_strand.dispatch(boost::bind(& CAsioSocketImpl::DispatchClose, this));
+				dispatch(m_strand, boost::bind(& CAsioSocketImpl::DispatchClose, this));
 			}
 		}
 	}
@@ -538,7 +538,7 @@ private:
 	{
 		m_readPending = true;
 		m_readBufferContent = 0;
-		m_strand.dispatch(boost::bind(& CAsioSocketImpl::DispatchBackgroundRead, this));
+		dispatch(m_strand, boost::bind(& CAsioSocketImpl::DispatchBackgroundRead, this));
 	}
 
 	void PostReadEvent(int DEBUG_ONLY(from) )
@@ -618,7 +618,7 @@ private:
 	uint32			m_readBufferContent;
 	bool			m_eventPending;
 	char *			m_sendBuffer;
-	io_service::strand	m_strand;		// handle synchronisation in io_service thread pool
+	io_context::strand	m_strand;		// handle synchronisation in io_service thread pool
 	deadline_timer	m_timer;
 	bool			m_connected;
 	bool			m_closed;
@@ -875,7 +875,7 @@ private:
 		}
 		// We were not successful. Try again.
 		// Post the request to the event queue to make sure it doesn't get called immediately.
-		m_strand.post(boost::bind(& CAsioSocketServerImpl::StartAccept, this));
+		post(m_strand, boost::bind(& CAsioSocketServerImpl::StartAccept, this));
 	}
 
 	// The wrapper object
@@ -886,7 +886,7 @@ private:
 	CScopedPtr<CAsioSocketImpl> m_currentSocket;
 	// Is there a socket available?
 	bool m_socketAvailable;
-	io_service::strand	m_strand;		// handle synchronisation in io_service thread pool
+	io_context::strand	m_strand;		// handle synchronisation in io_service thread pool
 };
 
 
@@ -1021,7 +1021,7 @@ public:
 		// Collect data, make a copy of the buffer's content
 		CUDPData * recdata = new CUDPData(buf, nBytes, addr);
 		AddDebugLogLineF(logAsio, CFormat(wxT("UDP SendTo %d to %s")) % nBytes % addr.IPAddress());
-		m_strand.dispatch(boost::bind(& CAsioUDPSocketImpl::DispatchSendTo, this, recdata));
+		dispatch(m_strand, boost::bind(& CAsioUDPSocketImpl::DispatchSendTo, this, recdata));
 		return nBytes;
 	}
 
@@ -1035,7 +1035,7 @@ public:
 		if (s_io_service.stopped()) {
 			DispatchClose();
 		} else {
-			m_strand.dispatch(boost::bind(& CAsioUDPSocketImpl::DispatchClose, this));
+			dispatch(m_strand, boost::bind(& CAsioUDPSocketImpl::DispatchClose, this));
 		}
 	}
 
@@ -1162,7 +1162,7 @@ private:
 	ip::udp::socket *	m_socket;
 	CMuleUDPSocket *	m_muleSocket;
 	bool				m_OK;
-	io_service::strand	m_strand;		// handle synchronisation in io_service thread pool
+	io_context::strand	m_strand;		// handle synchronisation in io_service thread pool
 	deadline_timer		m_timer;
 	amuleIPV4Address	m_address;
 
@@ -1254,7 +1254,7 @@ public:
 	void * Entry()
 	{
 		AddLogLineNS(CFormat(_("Asio thread %d started")) % m_threadNumber);
-		io_service::work worker(s_io_service);		// keep io_service running
+		auto worker = make_work_guard(s_io_service);		// keep io_service running
 		s_io_service.run();
 		AddDebugLogLineN(logAsio, CFormat(wxT("Asio thread %d stopped")) % m_threadNumber);
 
@@ -1342,7 +1342,7 @@ bool amuleIPV4Address::Hostname(const wxString& name)
 	// This is usually just an IP.
 	std::string sname(unicode2char(name));
 	error_code ec;
-	ip::address_v4 adr = ip::address_v4::from_string(sname, ec);
+	ip::address_v4 adr = ip::make_address_v4(sname, ec);
 	if (!ec) {
 		m_endpoint->address(adr);
 		return true;
@@ -1353,17 +1353,16 @@ bool amuleIPV4Address::Hostname(const wxString& name)
 	error_code ec2;
 	ip::tcp::resolver res(s_io_service);
 	// We only want to get IPV4 addresses.
-	ip::tcp::resolver::query query(ip::tcp::v4(), sname, "");
-	ip::tcp::resolver::iterator endpoint_iterator = res.resolve(query, ec2);
+	ip::tcp::resolver::results_type endpoint_iterator = res.resolve(sname, "", ec2);
 	if (ec2) {
 		AddDebugLogLineN(logAsio, CFormat(wxT("Hostname(\"%s\") resolve failed: %s")) % name % ec2.message());
 		return false;
 	}
-	if (endpoint_iterator == ip::tcp::resolver::iterator()) {
+	if (endpoint_iterator == ip::tcp::resolver::results_type()) {
 		AddDebugLogLineN(logAsio, CFormat(wxT("Hostname(\"%s\") resolve failed: no address found")) % name);
 		return false;
 	}
-	m_endpoint->address(endpoint_iterator->endpoint().address());
+	m_endpoint->address(endpoint_iterator.begin()->endpoint().address());
 	AddDebugLogLineN(logAsio, CFormat(wxT("Hostname(\"%s\") resolved to %s")) % name % IPAddress());
 	return true;
 }
-- 
2.45.2