X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsocketengine.cpp;h=df6ff5a0206d0471b41d962ffe115a9add91ab1f;hb=a032cd90ad5582914759e226085efee5aae1a1ef;hp=bac97a6dc3eb6e81f14fb2375cdd38a18e0ee140;hpb=b1098712771ab823042fcf8614a706c76c2ff401;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/socketengine.cpp b/src/socketengine.cpp index bac97a6dc..df6ff5a02 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -21,8 +21,11 @@ */ +#include "exitcodes.h" #include "inspircd.h" +#include + /** Reference table, contains all current handlers **/ std::vector SocketEngine::ref; @@ -60,8 +63,17 @@ void EventHandler::OnEventHandlerError(int errornum) { } +void SocketEngine::InitError() +{ + std::cerr << con_red << "FATAL ERROR!" << con_reset << " Socket engine initialization failed. " << strerror(errno) << '.' << std::endl; + exit(EXIT_STATUS_SOCKETENGINE); +} + void SocketEngine::LookupMaxFds() { +#if defined _WIN32 + MaxSetSize = FD_SETSIZE; +#else struct rlimit limits; if (!getrlimit(RLIMIT_NOFILE, &limits)) MaxSetSize = limits.rlim_cur; @@ -73,6 +85,7 @@ void SocketEngine::LookupMaxFds() #endif if (!setrlimit(RLIMIT_NOFILE, &limits)) MaxSetSize = limits.rlim_cur; +#endif } void SocketEngine::ChangeEventMask(EventHandler* eh, int change) @@ -235,9 +248,9 @@ int SocketEngine::Recv(EventHandler* fd, void *buf, size_t len, int flags) return nbRecvd; } -int SocketEngine::SendTo(EventHandler* fd, const void *buf, size_t len, int flags, const sockaddr *to, socklen_t tolen) +int SocketEngine::SendTo(EventHandler* fd, const void* buf, size_t len, int flags, const irc::sockets::sockaddrs& address) { - int nbSent = sendto(fd->GetFd(), (const char*)buf, len, flags, to, tolen); + int nbSent = sendto(fd->GetFd(), (const char*)buf, len, flags, &address.sa, address.sa_size()); stats.UpdateWriteCounters(nbSent); return nbSent; } @@ -268,9 +281,9 @@ int SocketEngine::WriteV(EventHandler* fd, const iovec* iovec, int count) } #endif -int SocketEngine::Connect(EventHandler* fd, const sockaddr *serv_addr, socklen_t addrlen) +int SocketEngine::Connect(EventHandler* fd, const irc::sockets::sockaddrs& address) { - int ret = connect(fd->GetFd(), serv_addr, addrlen); + int ret = connect(fd->GetFd(), &address.sa, address.sa_size()); #ifdef _WIN32 if ((ret == SOCKET_ERROR) && (WSAGetLastError() == WSAEWOULDBLOCK)) errno = EINPROGRESS;