Skip to content

Commit

Permalink
[10694] Use portable ACE way msecs time value calculation
Browse files Browse the repository at this point in the history
Avoid use unsafe code for non-Windows platforms
Thanks to Marik for research the problem and Ambal for helping me with this patch
  • Loading branch information
SilverIce committed Nov 7, 2010
1 parent 5be43d0 commit 3a82098
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
25 changes: 4 additions & 21 deletions src/shared/Timer.h
Expand Up @@ -19,31 +19,14 @@
#ifndef MANGOS_TIMER_H
#define MANGOS_TIMER_H

#include "Platform/CompilerDefs.h"

#if PLATFORM == PLATFORM_WINDOWS
# include <ace/config-all.h>
# include <mmsystem.h>
# include <time.h>
#else
# if defined(__APPLE_CC__)
# include <time.h>
# endif
# include <sys/time.h>
# include <sys/timeb.h>
#endif
#include "Common.h"
#include <ace/OS_NS_sys_time.h>

#if PLATFORM == PLATFORM_WINDOWS
inline uint32 getMSTime() { return GetTickCount(); }
#else
inline uint32 getMSTime()
{
struct timeval tv;
struct timezone tz;
gettimeofday( &tv, &tz );
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
static const ACE_Time_Value ApplicationStartTime = ACE_OS::gettimeofday();
return (ACE_OS::gettimeofday() - ApplicationStartTime).msec();
}
#endif

inline uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
{
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10693"
#define REVISION_NR "10694"
#endif // __REVISION_NR_H__

3 comments on commit 3a82098

@Limur
Copy link

@Limur Limur commented on 3a82098 Nov 7, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!!!! Hope this will solve the problem with ACE-depend crashes

@SilverIce
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should to describe this before: probably it resolves problems that came with send real diff from last update commits
can't be sure until someone will test it on *nix platform

thanks!!!! Hope this will solve the problem with ACE-depend crashes

you talking about socket-related crashes? no, it won't

@Limur
Copy link

@Limur Limur commented on 3a82098 Nov 7, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.