Merge pull request #259 from f1rmb/f1rmb_fix_UDPSocket_close
Fix nasty bug in UDPSocket::close().
This commit is contained in:
commit
014cddadd5
4 changed files with 20 additions and 12 deletions
|
@ -187,6 +187,8 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(index);
|
||||||
|
|
||||||
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
|
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
@ -343,13 +345,13 @@ bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const s
|
||||||
|
|
||||||
void CUDPSocket::close()
|
void CUDPSocket::close()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < UDP_SOCKET_MAX; i++)
|
for (unsigned int i = 0; i < UDP_SOCKET_MAX; i++)
|
||||||
close(m_fd[i]);
|
close(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUDPSocket::close(const unsigned int index)
|
void CUDPSocket::close(const unsigned int index)
|
||||||
{
|
{
|
||||||
if (m_fd[index] >= 0) {
|
if ((index < UDP_SOCKET_MAX) && (m_fd[index] >= 0)) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
::closesocket(m_fd[index]);
|
::closesocket(m_fd[index]);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -187,6 +187,8 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(index);
|
||||||
|
|
||||||
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
|
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
@ -343,13 +345,13 @@ bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const s
|
||||||
|
|
||||||
void CUDPSocket::close()
|
void CUDPSocket::close()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < UDP_SOCKET_MAX; i++)
|
for (unsigned int i = 0; i < UDP_SOCKET_MAX; i++)
|
||||||
close(m_fd[i]);
|
close(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUDPSocket::close(const unsigned int index)
|
void CUDPSocket::close(const unsigned int index)
|
||||||
{
|
{
|
||||||
if (m_fd[index] >= 0) {
|
if ((index < UDP_SOCKET_MAX) && (m_fd[index] >= 0)) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
::closesocket(m_fd[index]);
|
::closesocket(m_fd[index]);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -188,6 +188,8 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(index);
|
||||||
|
|
||||||
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
|
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
@ -344,13 +346,13 @@ bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const s
|
||||||
|
|
||||||
void CUDPSocket::close()
|
void CUDPSocket::close()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < UDP_SOCKET_MAX; i++)
|
for (unsigned int i = 0; i < UDP_SOCKET_MAX; i++)
|
||||||
close(m_fd[i]);
|
close(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUDPSocket::close(const unsigned int index)
|
void CUDPSocket::close(const unsigned int index)
|
||||||
{
|
{
|
||||||
if (m_fd[index] >= 0) {
|
if ((index < UDP_SOCKET_MAX) && (m_fd[index] >= 0)) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
::closesocket(m_fd[index]);
|
::closesocket(m_fd[index]);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -215,6 +215,8 @@ bool CUDPSocket::open(const unsigned int index, const unsigned int af, const std
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(index);
|
||||||
|
|
||||||
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
|
int fd = ::socket(addr.ss_family, SOCK_DGRAM, 0);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
@ -371,13 +373,13 @@ bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const s
|
||||||
|
|
||||||
void CUDPSocket::close()
|
void CUDPSocket::close()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < UDP_SOCKET_MAX; i++)
|
for (unsigned int i = 0; i < UDP_SOCKET_MAX; i++)
|
||||||
close(m_fd[i]);
|
close(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUDPSocket::close(const unsigned int index)
|
void CUDPSocket::close(const unsigned int index)
|
||||||
{
|
{
|
||||||
if (m_fd[index] >= 0) {
|
if ((index < UDP_SOCKET_MAX) && (m_fd[index] >= 0)) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
::closesocket(m_fd[index]);
|
::closesocket(m_fd[index]);
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Reference in a new issue