change PIIODevice read* and write* methods size to "ssize_t"

This commit is contained in:
2022-08-01 18:52:30 +03:00
parent 1b499530c5
commit b1e220e454
39 changed files with 135 additions and 128 deletions

View File

@@ -247,7 +247,7 @@ void PIPeer::initEths(PIStringList al) {
eths_traffic << ce;
cint = prev_ifaces.getByAddress(a);
self_info.addresses << PeerInfo::PeerAddress(ce->path(), cint == 0 ? "255.255.255.0" : cint->netmask);
CONNECT2(void, const uchar *, int, ce, threadedReadEvent, this, dataRead);
CONNECT2(void, const uchar *, ssize_t, ce, threadedReadEvent, this, dataRead);
ce->startThreadedRead();
// piCoutObj << "dc binded to" << ce->path();
// piCoutObj << "add eth" << a;
@@ -282,7 +282,7 @@ void PIPeer::initMBcasts(PIStringList al) {
ce->joinMulticastGroup(_PIPEER_MULTICAST_IP);
if (ce->open()) {
eths_mcast << ce;
CONNECT2(void, const uchar *, int, ce, threadedReadEvent, this, mbcastRead);
CONNECT2(void, const uchar *, ssize_t, ce, threadedReadEvent, this, mbcastRead);
ce->startThreadedRead();
// piCout << "mcast bind to" << a << ce->sendIP();
} else {
@@ -302,7 +302,7 @@ void PIPeer::initMBcasts(PIStringList al) {
ce->setReadAddress(a, _PIPEER_BROADCAST_PORT);
if (ce->open()) {
eths_bcast << ce;
CONNECT2(void, const uchar *, int, ce, threadedReadEvent, this, mbcastRead);
CONNECT2(void, const uchar *, ssize_t, ce, threadedReadEvent, this, mbcastRead);
ce->startThreadedRead();
// piCout << "mc BC try" << a << nm << ce->sendIP();
// piCout << "bcast bind to" << a << nm;
@@ -319,7 +319,7 @@ void PIPeer::initMBcasts(PIStringList al) {
eth_lo.setReadAddress("127.0.0.1", p);
if (eth_lo.open()) {
eth_lo.setSendIP("127.0.0.1");
CONNECT2(void, const uchar *, int, &eth_lo, threadedReadEvent, this, mbcastRead);
CONNECT2(void, const uchar *, ssize_t, &eth_lo, threadedReadEvent, this, mbcastRead);
eth_lo.startThreadedRead();
// piCout << "lo binded to" << eth_lo.readAddress() << eth_lo.sendAddress();
//piCout << "add eth" << ta;
@@ -336,7 +336,7 @@ void PIPeer::initMBcasts(PIStringList al) {
eth_tcp_cli.init();
eth_tcp_cli.setDebug(false);
tcpClientReconnect();
CONNECT2(void, const uchar *, int, &eth_tcp_cli, threadedReadEvent, this, mbcastRead);
CONNECT2(void, const uchar *, ssize_t, &eth_tcp_cli, threadedReadEvent, this, mbcastRead);
CONNECTU(&eth_tcp_cli, disconnected, this, tcpClientReconnect);
eth_tcp_cli.startThreadedRead();
if (eths_mcast.isEmpty() && eths_bcast.isEmpty() && !eth_lo.isOpened()) piCoutObj << "Warning! Can`t find suitable network interface for multicast receive, check for exists at least one interface with multicasting enabled!";
@@ -444,7 +444,7 @@ void PIPeer::dtReceived(const PIString & from, const PIByteArray & data) {
}
bool PIPeer::dataRead(const uchar * readed, int size) {
bool PIPeer::dataRead(const uchar * readed, ssize_t size) {
if (destroyed) {
//piCout << "[PIPeer] SegFault";
return true;
@@ -561,7 +561,7 @@ bool PIPeer::dataRead(const uchar * readed, int size) {
}
bool PIPeer::mbcastRead(const uchar * data, int size) {
bool PIPeer::mbcastRead(const uchar * data, ssize_t size) {
if (destroyed) {
//piCout << "[PIPeer] SegFault";
return true;
@@ -933,7 +933,7 @@ ssize_t PIPeer::bytesAvailable() const {
}
int PIPeer::readDevice(void *read_to, int max_size) {
ssize_t PIPeer::readDevice(void *read_to, ssize_t max_size) {
read_buffer_mutex.lock();
bool empty = read_buffer.isEmpty();
read_buffer_mutex.unlock();
@@ -947,7 +947,7 @@ int PIPeer::readDevice(void *read_to, int max_size) {
if (!read_buffer.isEmpty()) {
PIByteArray ba = read_buffer.dequeue();
read_buffer_mutex.unlock();
int sz = piMini(ba.size_s(), max_size);
ssize_t sz = piMini(ba.size_s(), max_size);
memcpy(read_to, ba.data(), sz);
return sz;
}
@@ -956,7 +956,7 @@ int PIPeer::readDevice(void *read_to, int max_size) {
}
int PIPeer::writeDevice(const void *data, int size) {
ssize_t PIPeer::writeDevice(const void *data, ssize_t size) {
if (trust_peer.isEmpty()) {
sendToAll(data, size);
return size;
@@ -970,7 +970,7 @@ int PIPeer::writeDevice(const void *data, int size) {
void PIPeer::newTcpClient(PIEthernet *client) {
client->setName("__S__PIPeer_eth_TCP_ServerClient" + client->path());
piCoutObj << "client" << client->path();
CONNECT2(void, const uchar *, int, client, threadedReadEvent, this, mbcastRead);
CONNECT2(void, const uchar *, ssize_t, client, threadedReadEvent, this, mbcastRead);
client->startThreadedRead();
}