summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburlex <burlex@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-15 20:41:30 +0000
committerburlex <burlex@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-15 20:41:30 +0000
commit8cebdce0933438c32fc5821dd16d090ea06fd8cc (patch)
tree505df2bb898fad59ebd2dfef0a61698c4765c973
parentbb35a0fa9cbebe51fa636f707c12ca4a7033dd9a (diff)
* include/caller.h will now compile correctly on Windows platforms.
+ Implemented gettimeofday in win32 wrapper, link rtt's will now display in milliseconds. * SocketEngine::BoundsCheckFd will now handle Windows event handler cases correctly. (fixing writing to sockets not working) * Fixed VC71 project. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7723 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/caller.h16
-rw-r--r--src/modules/m_spanningtree/main.cpp7
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp4
-rw-r--r--src/socketengine.cpp14
-rw-r--r--win/inspircdVC71.vcproj6
-rw-r--r--win/inspircd_win32wrapper.cpp14
-rw-r--r--win/inspircd_win32wrapper.h2
7 files changed, 44 insertions, 19 deletions
diff --git a/include/caller.h b/include/caller.h
index 5850ae2a6..b5dd38ef0 100644
--- a/include/caller.h
+++ b/include/caller.h
@@ -146,7 +146,7 @@ template <typename ReturnType, typename Param1> class CoreExport caller1 : publi
{
public:
caller1(HandlerBase1<ReturnType, Param1>* initial)
- : caller< HandlerBase1<ReturnType, Param1> >::caller(initial)
+ : caller< HandlerBase1<ReturnType, Param1> >(initial)
{ }
virtual ReturnType operator() (Param1 param1)
@@ -159,7 +159,7 @@ template <typename ReturnType, typename Param1, typename Param2> class CoreExpor
{
public:
caller2(HandlerBase2<ReturnType, Param1, Param2>* initial)
- : caller< HandlerBase2<ReturnType, Param1, Param2> >::caller(initial)
+ : caller< HandlerBase2<ReturnType, Param1, Param2> >(initial)
{ }
virtual ReturnType operator() (Param1 param1, Param2 param2)
@@ -172,7 +172,7 @@ template <typename ReturnType, typename Param1, typename Param2, typename Param3
{
public:
caller3(HandlerBase3<ReturnType, Param1, Param2, Param3>* initial)
- : caller< HandlerBase3<ReturnType, Param1, Param2, Param3> >::caller(initial)
+ : caller< HandlerBase3<ReturnType, Param1, Param2, Param3> >(initial)
{ }
virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3)
@@ -185,7 +185,7 @@ template <typename ReturnType, typename Param1, typename Param2, typename Param3
{
public:
caller4(HandlerBase4<ReturnType, Param1, Param2, Param3, Param4>* initial)
- : caller< HandlerBase4<ReturnType, Param1, Param2, Param3, Param4> >::caller(initial)
+ : caller< HandlerBase4<ReturnType, Param1, Param2, Param3, Param4> >(initial)
{ }
virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4)
@@ -198,7 +198,7 @@ template <typename ReturnType, typename Param1, typename Param2, typename Param3
{
public:
caller5(HandlerBase5<ReturnType, Param1, Param2, Param3, Param4, Param5>* initial)
- : caller< HandlerBase5<ReturnType, Param1, Param2, Param3, Param4, Param5> >::caller(initial)
+ : caller< HandlerBase5<ReturnType, Param1, Param2, Param3, Param4, Param5> >(initial)
{ }
virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5)
@@ -211,7 +211,7 @@ template <typename ReturnType, typename Param1, typename Param2, typename Param3
{
public:
caller6(HandlerBase6<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6>* initial)
- : caller< HandlerBase6<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6> >::caller(initial)
+ : caller< HandlerBase6<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6> >(initial)
{ }
virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5, Param6 param6)
@@ -224,7 +224,7 @@ template <typename ReturnType, typename Param1, typename Param2, typename Param3
{
public:
caller7(HandlerBase7<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7>* initial)
- : caller< HandlerBase7<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7> >::caller(initial)
+ : caller< HandlerBase7<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7> >(initial)
{ }
virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5, Param6 param6, Param7 param7)
@@ -237,7 +237,7 @@ template <typename ReturnType, typename Param1, typename Param2, typename Param3
{
public:
caller8(HandlerBase8<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8>* initial)
- : caller< HandlerBase8<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8> >::caller(initial)
+ : caller< HandlerBase8<ReturnType, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8> >(initial)
{ }
virtual ReturnType operator() (Param1 param1, Param2 param2, Param3 param3, Param4 param4, Param5 param5, Param6 param6, Param7 param7, Param8 param8)
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index ed54be0fb..3d472bf7a 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -174,12 +174,7 @@ std::string ModuleSpanningTree::TimeToStr(time_t secs)
const std::string ModuleSpanningTree::MapOperInfo(TreeServer* Current)
{
time_t secs_up = ServerInstance->Time() - Current->age;
-
-#ifndef WIN32
return (" [Up: " + TimeToStr(secs_up) + " Lag: "+ConvToStr(Current->rtt)+"ms]");
-#else
- return (" [Up: " + TimeToStr(secs_up) + " Lag: "+ConvToStr(Current->rtt)+"s]");
-#endif
}
// WARNING: NOT THREAD SAFE - DONT GET ANY SMART IDEAS.
@@ -492,12 +487,10 @@ void ModuleSpanningTree::DoPingChecks(time_t curtime)
sock->WriteLine(std::string(":")+ServerInstance->Config->ServerName+" PING "+serv->GetName());
serv->SetNextPingTime(curtime + Utils->PingFreq);
serv->LastPing = curtime;
-#ifndef WIN32
timeval t;
gettimeofday(&t, NULL);
long ts = (t.tv_sec * 1000) + (t.tv_usec / 1000);
serv->LastPingMsec = ts;
-#endif
serv->Warned = false;
}
else
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 527c0122b..88c7666bf 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -365,14 +365,10 @@ bool TreeSocket::LocalPong(const std::string &prefix, std::deque<std::string> &p
if (ServerSource)
{
ServerSource->SetPingFlag();
-#ifndef WIN32
timeval t;
gettimeofday(&t, NULL);
long ts = (t.tv_sec * 1000) + (t.tv_usec / 1000);
ServerSource->rtt = ts - ServerSource->LastPingMsec;
-#else
- ServerSource->rtt = Instance->Time() - ServerSource->LastPing;
-#endif
}
}
else
diff --git a/src/socketengine.cpp b/src/socketengine.cpp
index 28ba8c252..3aef464e6 100644
--- a/src/socketengine.cpp
+++ b/src/socketengine.cpp
@@ -93,10 +93,24 @@ std::string SocketEngine::GetName()
bool SocketEngine::BoundsCheckFd(EventHandler* eh)
{
+#ifdef WINDOWS
+ int * internal_fd;
+ if(!eh || eh->GetFd() < 0)
+ return false;
+
+ if(!eh->GetExt("internal_fd", internal_fd))
+ return false;
+
+ if(*internal_fd > MAX_DESCRIPTORS)
+ return false;
+
+ return true;
+#else
if (!eh)
return false;
if ((eh->GetFd() < 0) || (eh->GetFd() > MAX_DESCRIPTORS))
return false;
return true;
+#endif
}
diff --git a/win/inspircdVC71.vcproj b/win/inspircdVC71.vcproj
index 107cb5036..1bcac8fcd 100644
--- a/win/inspircdVC71.vcproj
+++ b/win/inspircdVC71.vcproj
@@ -146,6 +146,9 @@
RelativePath="..\src\dynamic.cpp">
</File>
<File
+ RelativePath="..\src\filelogger.cpp">
+ </File>
+ <File
RelativePath="..\src\hashcomp.cpp">
</File>
<File
@@ -167,6 +170,9 @@
RelativePath="..\src\modules.cpp">
</File>
<File
+ RelativePath="..\src\server.cpp">
+ </File>
+ <File
RelativePath="..\src\snomasks.cpp">
</File>
<File
diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp
index 1646e39af..e6f25df18 100644
--- a/win/inspircd_win32wrapper.cpp
+++ b/win/inspircd_win32wrapper.cpp
@@ -17,12 +17,15 @@
#include <string>
#include <errno.h>
#include <assert.h>
+#pragma comment(lib, "winmm.lib")
using namespace std;
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
+#include <mmsystem.h>
+
/* This MUST remain static and delcared outside the class, so that WriteProcessMemory can reference it properly */
static DWORD owner_processid = 0;
@@ -640,3 +643,14 @@ bool ValidateWindowsDnsServer(ServerConfig* conf, const char* tag, const char* v
}
return true;
}
+
+int gettimeofday(struct timeval * tv, void * tz)
+{
+ if(tv == NULL)
+ return -1;
+
+ DWORD mstime = timeGetTime();
+ tv->tv_sec = time(NULL);
+ tv->tv_usec = (mstime - (tv->tv_sec * 1000)) * 1000;
+ return 0;
+}
diff --git a/win/inspircd_win32wrapper.h b/win/inspircd_win32wrapper.h
index ffda9ff40..17c3f5525 100644
--- a/win/inspircd_win32wrapper.h
+++ b/win/inspircd_win32wrapper.h
@@ -152,6 +152,8 @@ CoreExport DIR * opendir(const char * path);
CoreExport dirent * readdir(DIR * handle);
CoreExport void closedir(DIR * handle);
+CoreExport int gettimeofday(struct timeval * tv, void * tz);
+
/* Disable these stupid warnings.. */
#pragma warning(disable:4800)
#pragma warning(disable:4251)