Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update to latest Csocket

We are using a vanilla version of Csocket again. Previously, our copy of
Csocket.h had a new '#include "zncconfig.h"'.

The other changes are mostly cleanup for various compiler warnings. The switch
from inet_ntoa() to inet_ntop() is for thread-safety reasons.

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information...
commit cc552fb3f50b1ca7cd38cf5a58ac6a7f57f43959 1 parent 32e89ef
@psychon psychon authored
Showing with 12 additions and 12 deletions.
  1. +6 −2 Csocket.cpp
  2. +4 −10 Csocket.h
  3. +2 −0  defines.h
View
8 Csocket.cpp
@@ -1594,10 +1594,14 @@ CS_STRING Csock::GetLocalIP()
if( !GetIPv6() )
{
+ char straddr[INET_ADDRSTRLEN];
struct sockaddr_in mLocalAddr;
socklen_t mLocalLen = sizeof( mLocalAddr );
- if ( getsockname( iSock, (struct sockaddr *) &mLocalAddr, &mLocalLen ) == 0 )
- m_sLocalIP = inet_ntoa( mLocalAddr.sin_addr );
+ if ( ( getsockname( iSock, (struct sockaddr *) &mLocalAddr, &mLocalLen ) == 0 )
+ && ( inet_ntop( AF_INET, &mLocalAddr.sin_addr, straddr, sizeof(straddr) ) ) )
+ {
+ m_sLocalIP = straddr;
+ }
}
#ifdef HAVE_IPV6
else
View
14 Csocket.h
@@ -34,8 +34,7 @@
#ifndef _HAS_CSOCKET_
#define _HAS_CSOCKET_
-
-#include "zncconfig.h"
+#include "defines.h" // require this as a general rule, most projects have a defines.h or the like
#include <stdio.h>
#include <unistd.h>
@@ -93,8 +92,6 @@
#include <set>
#include <map>
-#include "defines.h" // require this as a general rule, most projects have a defines.h or the like
-
#ifndef CS_STRING
# ifdef _HAS_CSTRING_
# define CS_STRING Cstring
@@ -1437,7 +1434,7 @@ class TSocketManager : public std::vector<T *>
{
if ( !pcSock->SetupVHost() )
{
- pcSock->SockError( errno );
+ pcSock->SockError( GetSockError() );
DelSock( a-- );
continue;
}
@@ -1569,6 +1566,7 @@ class TSocketManager : public std::vector<T *>
}
case SELECT_TIMEOUT:
+ case SELECT_TRYAGAIN:
case SELECT_ERROR:
default :
break;
@@ -1630,7 +1628,7 @@ class TSocketManager : public std::vector<T *>
virtual void AddSock( T *pcSock, const CS_STRING & sSockName )
{
pcSock->SetSockName( sSockName );
- push_back( pcSock );
+ this->push_back( pcSock );
}
//! returns a pointer to the FIRST sock found by port or NULL on no match
@@ -1988,7 +1986,6 @@ class TSocketManager : public std::vector<T *>
if ( m_iSelectWait == 0 )
iQuickReset = 0;
- bool bHasWriteable = false;
bool bHasAvailSocks = false;
unsigned long long iNOW = 0;
for( unsigned int i = 0; i < this->size(); i++ )
@@ -2029,7 +2026,6 @@ class TSocketManager : public std::vector<T *>
FDSetCheck( aiAresSocks[0], miiReadyFds, eCheckWrite );
// let ares drop the timeout if it has something timing out sooner then whats in tv currently
ares_timeout( pChannel, &tv, &tv );
- bHasWriteable = true;
}
#endif /* HAVE_C_ARES */
@@ -2070,7 +2066,6 @@ class TSocketManager : public std::vector<T *>
if( !pcSock->GetWriteBuffer().empty() )
{ // this means we need to write again, not everything got knocked out
FDSetCheck( iWSock, miiReadyFds, eCheckWrite );
- bHasWriteable = true;
}
} else
@@ -2081,7 +2076,6 @@ class TSocketManager : public std::vector<T *>
if( pcSock->AllowWrite( iNOW ) )
{
FDSetCheck( iWSock, miiReadyFds, eCheckWrite );
- bHasWriteable = true;
}
}
View
2  defines.h
@@ -9,6 +9,8 @@
#ifndef _DEFINES_H
#define _DEFINES_H
+#include "zncconfig.h"
+
// This header file is just for Csocket
#include "main.h"
Please sign in to comment.
Something went wrong with that request. Please try again.