PIPeer important fix!
git-svn-id: svn://db.shs.com.ru/pip@113 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -272,7 +272,7 @@ bool PIEthernet::closeDevice() {
|
|||||||
|
|
||||||
void PIEthernet::closeSocket(int & sd) {
|
void PIEthernet::closeSocket(int & sd) {
|
||||||
if (sd != -1)
|
if (sd != -1)
|
||||||
ethClosesocket(sd);
|
ethClosesocket(sd, type() != PIEthernet::UDP);
|
||||||
sd = -1;
|
sd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1035,13 +1035,14 @@ int PIEthernet::ethSendto(int sock, const void * buf, int size, int flags, socka
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PIEthernet::ethClosesocket(int sock) {
|
void PIEthernet::ethClosesocket(int sock, bool shutdown) {
|
||||||
if (sock < 0) return;
|
if (sock < 0) return;
|
||||||
|
if (shutdown) ::shutdown(sock,
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
shutdown(sock, SD_BOTH);
|
SD_BOTH);
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
#else
|
#else
|
||||||
shutdown(sock, SHUT_RDWR);
|
SHUT_RDWR);
|
||||||
::close(sock);
|
::close(sock);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ private:
|
|||||||
inline static int ethRecv(int sock, void * buf, int size, int flags = 0);
|
inline static int ethRecv(int sock, void * buf, int size, int flags = 0);
|
||||||
inline static int ethRecvfrom(int sock, void * buf, int size, int flags, sockaddr * addr);
|
inline static int ethRecvfrom(int sock, void * buf, int size, int flags, sockaddr * addr);
|
||||||
inline static int ethSendto(int sock, const void * buf, int size, int flags, sockaddr * addr, int addr_len);
|
inline static int ethSendto(int sock, const void * buf, int size, int flags, sockaddr * addr, int addr_len);
|
||||||
inline static void ethClosesocket(int sock);
|
inline static void ethClosesocket(int sock, bool shutdown);
|
||||||
inline static int ethSetsockopt(int sock, int level, int optname, const void * optval, int optlen);
|
inline static int ethSetsockopt(int sock, int level, int optname, const void * optval, int optlen);
|
||||||
inline static int ethSetsockoptInt(int sock, int level, int optname, int value = 1);
|
inline static int ethSetsockoptInt(int sock, int level, int optname, int value = 1);
|
||||||
inline static int ethSetsockoptBool(int sock, int level, int optname, bool value = true);
|
inline static int ethSetsockoptBool(int sock, int level, int optname, bool value = true);
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ void PIPeer::initMBcasts(PIStringList al) {
|
|||||||
eth_lo.setDebug(false);
|
eth_lo.setDebug(false);
|
||||||
eth_lo.setName("__S__PIPeer_eth_loopback");
|
eth_lo.setName("__S__PIPeer_eth_loopback");
|
||||||
eth_lo.setParameters(0);
|
eth_lo.setParameters(0);
|
||||||
|
eth_lo.init();
|
||||||
cint = prev_ifaces.getByAddress("127.0.0.1");
|
cint = prev_ifaces.getByAddress("127.0.0.1");
|
||||||
for (int p = _PIPEER_LOOPBACK_PORT_S; p <= _PIPEER_LOOPBACK_PORT_E; ++p) {
|
for (int p = _PIPEER_LOOPBACK_PORT_S; p <= _PIPEER_LOOPBACK_PORT_E; ++p) {
|
||||||
eth_lo.setReadAddress("127.0.0.1", p);
|
eth_lo.setReadAddress("127.0.0.1", p);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ private:
|
|||||||
pthread_mutex_t
|
pthread_mutex_t
|
||||||
#endif
|
#endif
|
||||||
mutex;
|
mutex;
|
||||||
bool locked;
|
volatile bool locked;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ public:
|
|||||||
~PIMutexLocker() {if (cond) mutex->unlock();}
|
~PIMutexLocker() {if (cond) mutex->unlock();}
|
||||||
private:
|
private:
|
||||||
PIMutex * mutex;
|
PIMutex * mutex;
|
||||||
bool cond;
|
volatile bool cond;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PIMUTEX_H
|
#endif // PIMUTEX_H
|
||||||
|
|||||||
Reference in New Issue
Block a user