我有一个应用程序正在创建2个侦听器套接字,并从一个接收数据并隧道到另一个。然后将数据隧道传回原始套接字等。然而,应用程序在执行隧道传输大约5秒后崩溃。调用堆栈始终是相同的。
select h_date, h_name from (
select (DATENAME(dw, hdate) + ', ' +
DATENAME(mm, hdate) + ' ' +
DATENAME(dd, hdate)) AS h_date, name AS h_name
, id1
from @results
where id1 in (1,2)
UNION
SELECT (STUFF((
SELECT ', ' + (DATENAME(dw, hdate) + ', ' +
DATENAME(mm, hdate) + ' ' +
DATENAME(dd, hdate))
FROM @results
WHERE id1 = 3
FOR XML PATH('')
), 1, 2, '')
) AS h_date, 'Giving Day' AS h_name, 3 as id1) q
order by id1
_data - >缓冲区在类中定义为常规char缓冲区。
void ListenerOne::readPerformed(const asio::error_code& error, size_t bytes_transferred)
{
//Error checking is present there
//Write data to Tunnel (tunnelBackSession is pointer to class)
this->tunnelBackSession->writeDataWithBufferCopy(data_, bytes_transferred);
}
在使用memcpy之前,我试图直接使用第一个侦听器的缓冲区,但它也触发了崩溃。这是调用堆栈:
void ListenerTwo::writeDataWithBufferCopy(char* szData, size_t len)
{
memcpy(data_, szData, len);
socket_.async_write_some(asio::buffer(data_, len), boost::bind(&ListenerTwo::afterWrite, this, asio::placeholders::error));
}
我在某处读到它与引用计数有关并且与缓冲区有关。 我该如何解决这个问题?