Commit Graph

675 Commits

Author SHA1 Message Date
jackpoz
1b3575ba77 Core/Logs: Fix race condition in Log
Fix race condition in Log by using atomic operators.

Helgrind log:
 Possible data race during read of size 8 at 0x7379D98 by thread #1
 Locks held: none
  at 0x15AE9C7: AppenderFile::_write(LogMessage const&) (AppenderFile.cpp:59)
  by 0x15ADFF8: Appender::write(LogMessage&) (Appender.cpp:106)
  by 0x159F14E: Logger::write(LogMessage&) (Logger.cpp:83)
  by 0x15A215B: Log::write(LogMessage*) (Log.cpp:290)
  by 0x15A200F: Log::vlog(LogFilterType, LogLevel, char const*, __va_list_tag*) (Log.cpp:272)
  by 0x15A2682: Log::outInfo(LogFilterType, char const*, ...) (Log.cpp:364)
  by 0xF7DA28: Master::Run() (Master.cpp:296)
  by 0xF835E8: main (Main.cpp:142)

 This conflicts with a previous write of size 8 by thread #10
 Locks held: none
  at 0x15AE9D7: AppenderFile::_write(LogMessage const&) (AppenderFile.cpp:59)
  by 0x15ADFF8: Appender::write(LogMessage&) (Appender.cpp:106)
  by 0x159F14E: Logger::write(LogMessage&) (Logger.cpp:83)
  by 0x15A215B: Log::write(LogMessage*) (Log.cpp:290)
  by 0x15A200F: Log::vlog(LogFilterType, LogLevel, char const*, __va_list_tag*) (Log.cpp:272)
  by 0x15A2682: Log::outInfo(LogFilterType, char const*, ...) (Log.cpp:364)
  by 0xF7EC1F: FreezeDetectorRunnable::run() (Master.cpp:98)
  by 0x15A5B3E: ACE_Based::Thread::ThreadTask(void*) (Threading.cpp:186)

 Address 0x7379D98 is 88 bytes inside a block of size 96 alloc'd
  at 0x4C2C857: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
  by 0x15A0FE3: Log::CreateAppenderFromConfig(char const*) (Log.cpp:150)
  by 0x15A1AED: Log::ReadAppendersFromConfig() (Log.cpp:244)
  by 0x15A31B4: Log::LoadFromConfig() (Log.cpp:469)
  by 0x15A053B: Log::Log() (Log.cpp:35)
  by 0xF75CD1: ACE_Singleton<Log, ACE_Thread_Mutex>::ACE_Singleton() (Singleton.inl:13)
  by 0xF754A4: ACE_Singleton<Log, ACE_Thread_Mutex>::instance() (Singleton.cpp:91)
  by 0xF8351A: main (Main.cpp:135)
2013-09-13 19:59:50 +02:00
Nay
38391cd774 Merge pull request #10737 from jackpoz/clock_fix
Core/Timer: Better handle system clock changes
2013-09-11 11:50:50 -07:00
jackpoz
67f7c1fde1 Core/Timer: Better handle system clock changes
Change IntervalTimer::Reset() behavior to handle system clock changes forward and backward.
This fixes IntervalTimer:.Passed() returning true till it catches up to the new time, triggering the event up to "std::numeric_limits<time_t>::max() / _interval" times.
Fixes https://github.com/TrinityCore/TrinityCore/issues/5816
2013-09-07 17:30:23 +02:00
jackpoz
9578b5f87a Core/Thread: Fix race condition converting time values to local time
Replace thread-unsafe localtime() http://www.cplusplus.com/reference/ctime/localtime/ with thread-safe portable ACE_OS::localtime_r() .

Helgrind log:
 Possible data race during read of size 4 at 0x6F183C0 by thread #1
 Locks held: none
  at 0x14E72E3: World::InitDailyQuestResetTime() (World.cpp:2772)
  by 0x14E3A01: World::SetInitialWorldSettings() (World.cpp:1790)
  by 0x101122A: Master::Run() (Master.cpp:164)
  by 0x101740C: main (Main.cpp:142)

 This conflicts with a previous write of size 4 by thread #2
 Locks held: none
  at 0x6C2D3BA: __tzfile_compute (tzfile.c:797)
  by 0x6C2D036: __tz_convert (tzset.c:627)
  by 0x164146C: LogMessage::getTimeStr(long) (Appender.cpp:23)
  by 0x1641550: LogMessage::getTimeStr() (Appender.cpp:31)
  by 0x1641722: Appender::write(LogMessage&) (Appender.cpp:80)
  by 0x1633FCE: Logger::write(LogMessage&) (Logger.cpp:83)
  by 0x16433D8: LogOperation::call() (LogOperation.cpp:29)
  by 0x16428A4: LogWorker::svc() (LogWorker.cpp:45)
2013-09-07 14:37:54 +02:00
Shauren
0ca481c0a2 Core/Achievements: Converted save queries to prepared statements 2013-09-06 14:00:21 +02:00
Subv
3ec941bacf Merge pull request #10697 from Chaplain/authserver
Auth/Misc: Code cleanup.
2013-09-03 14:59:56 -07:00
Chaplain
aa8bfeec4f Auth/Misc: Code cleanup.
*Random performance optimizations
2013-09-02 19:40:31 +03:00
Ascathor
722a6c143a Core/Account: Make account password change security variable and various changes
Settings within worldserver.conf:

Three settings for secruity level:
0 - None - No change to current system
1 - Email - Always requires the email entered on registration for confirming.
2 - RBAC - Groups applied with the RBAC role always require the email entered on registration for confirming.

RBAC default to every group. Changed some logs to make it more clear what is going on at all.

Emails may now no longer exceed 64 chars. Current email is used as regmail.

On account creation, two emails are saved. Registration email and normal email. Normal email is relevant afterwards. Registration email can be changed by console ONLY.

Includes new commands and changes to existing ones:
.account fulfills several new functions:
* Still prints GM Level.
* If account has permission, it displays the current email. This is not defaulted to any group.
* Security level is displayed. Also displays if user has RBAC perm if RBAC security mode is selected
.account email allows user to change email with sufficient confirmation
.account set sec email allows higher sec with higher sec than account to change the normal email. Registrationemail remains untouched here.
.account set sec regmail allows console to change registration email.
.pinfo now displays the registration and normal mail.

Also fixes .learn all crafts.
Closes #10558
2013-09-01 21:21:16 +02:00
Nay
1903d4ca7d Core/Server: Fix a spammy warning in WorldSession and move code to .cpp 2013-08-30 15:44:17 +01:00
Spp
3232b69ff3 Core/RBAC: Move commands security to RBAC (using generic RBAC Permissions)
- Warning: This will break commands for any custom security level
2013-08-30 13:57:09 +02:00
Nay
8eaf763235 Core&Tools: Fix multiple issues found by a static code coverage tool 2013-08-26 02:00:18 +01:00
raczman
ba22baebbd Core/Auth: Implement time-based token for user login as described in RFC 6238.
New column in account table is a base32 of token key bytes,
coincidentally it is the same format Google's Authenticator Android app uses.
If you want that to work, set system time on server correctly and use ntpd.

Closes #10527

Signed-off-by: Nay <dnpd.dd@gmail.com>
2013-08-25 14:02:40 +01:00
jackpoz
e96aa444b0 Core/Threading: Fix race condition in Thread
Increment the reference count of m_task in Thread::start() before spawning the actual Thread that will execute the task, otherwise the thread might finish, decRef the task and delete it.

Valgrind log of the issue:
 Invalid read of size 8
   at 0x1314CAD: ACE_Atomic_Op_GCC<long>::operator++() (Atomic_Op_GCC_T.inl:34)
   by 0x15933FB: ACE_Based::Runnable::incReference() (Threading.h:36)
   by 0x1592D2D: ACE_Based::Thread::start() (Threading.cpp:136)
   by 0x1592C37: ACE_Based::Thread::Thread(ACE_Based::Runnable*) (Threading.cpp:111)
   by 0xF6C463: Master::Run() (Master.cpp:195)
   by 0xF725D0: main (Main.cpp:142)
 Address 0x26137278 is 8 bytes inside a block of size 24 free'd
   at 0x4C2B59C: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0xF67FDB: RARunnable::~RARunnable() (RARunnable.cpp:55)
   by 0x1593441: ACE_Based::Runnable::decReference() (Threading.h:40)
   by 0x1592E92: ACE_Based::Thread::ThreadTask(void*) (Threading.cpp:186)
   by 0x515EA35: ACE_OS_Thread_Adapter::invoke() (in /usr/lib/libACE-6.0.3.so)
   by 0x5F19F8D: start_thread (pthread_create.c:311)
   by 0x6A46E1C: clone (clone.S:113)

Closes #10619
2013-08-25 13:48:55 +01:00
Nay
12973de799 Core&Tools: Fix multiple issues found by a static code coverage tool 2013-08-24 22:57:22 +01:00
Vincent-Michael
7679145da5 Core: Fix warning 2013-08-19 15:04:45 +02:00
QAston
dedeb5f9eb Fix build with gcc. Thanks to McBitter for testing. 2013-08-19 14:52:17 +02:00
QAston
0513d9c8d0 Core: Fix warnings. Make callback symbols local. 2013-08-18 20:30:38 +02:00
QAston
19343ddd55 Fix crashed caused by using openssl from multiple threads simultanously.
Note that this doesn't make BigNumber class threadsafe - it never was that way.
2013-08-18 17:44:04 +02:00
QAston
2a3370929d Fix BigNumber::AsByteArray function by returning Auto_Ptr.
Remove mutex from BigNumber class - it didn't do what it was advertised to do - consider using the "locked" array outside of the function in which it was "locked".
2013-08-18 17:44:03 +02:00
QAston
8160633e12 Core: Fix a bug in BigNumber::SetBinary 2013-08-18 17:44:02 +02:00
QAston
10fb50ad66 Core: Fix a bug in BigNumber::SetQword 2013-08-18 17:44:02 +02:00
Vincent-Michael
75e6c40630 Core/Misc: Rename some no name enums 2013-08-06 21:16:05 +02:00
Ascathor
5a9810ec08 Core/Commands: Added the rank id to .pinfo for guild data 2013-07-24 19:25:36 +02:00
Shauren
779a59e7e2 Core/Config: Refactored ConfigMgr
* Loading initial configuration files is now separate from loading any additional custom configs
2013-07-15 17:31:44 +02:00
Warpten
55338ff53b Revert "Shared/Utils: Fixed ApplyPercentModFloatVar."
This reverts commit 2005be0474.

Note to self: do not touch maths past 10 any more.
2013-07-11 11:10:05 +02:00
Warpten
2005be0474 Shared/Utils: Fixed ApplyPercentModFloatVar.
This has been around since 2010-12-11 :)
2013-07-10 21:44:08 +02:00
Nay
3561ab98ba Misc: Use override and final C++11 keywords in a few places (mostly scripts)
OVERRIDE and FINAL are TC macros (expand to nothing if compiler does not  support C++11)
2013-07-06 20:21:45 +01:00
Spp
d58a037512 Build: Set _BUILD_DIRECTIVE even if the compiler is not properly detected 2013-06-27 10:47:30 +02:00
Shauren
3c91c04758 Buildsystem/MSVC
* Fixed ACE PCH
* Removed WheatyExceptionReport sources from shared project
2013-06-15 14:07:12 +02:00
Malcrom
ec474a62e5 Core: More Function Renaming. 2013-06-11 21:25:12 -02:30
Shauren
ef15fe8ed2 Core/Instances: Fixed a bug that caused switching group leader inside active instance to cause players not being saved when a boss was killed.
Closes #5109
2013-06-11 15:50:08 +02:00
Subv
1d1bb84cf9 Merge pull request #9854 from Ascathor/master
Core/Command: Optimized .pinfo more
2013-06-02 17:52:27 -07:00
Vincent-Michael
15b055fe87 Core/Database: Fix bad sql query in 55b3819d12 (thx Shauren) 2013-06-01 23:47:46 +02:00
Subv
55b3819d12 Core/Database: Deleted characters will no longer be loaded when sending the SMSG_CHAR_ENUM packet. 2013-06-01 12:57:37 -05:00
Ascathor
fb52e9ea03 Core/Command: Optimized .pinfo more
* Moved some checks around
* Added RBAC Permission for Email, last login and last ip (group 3 and 4) -- If missing RBAC permission, then it displays "Unauthorized (RBAC)"
* Changed totalmail output from uint64 to uint32
* Level either puts Max level, or a list of information necessary
* Only queries guild if the current xp query also detects guild membership
* Incorporated recent changes into code
* Commander requires higher than target to get sensitive data beside RBAC permission.
2013-05-26 14:21:39 +02:00
Shauren
590133c2b0 Missed change for previous commit 2013-05-24 18:33:33 +02:00
Bezo
178cb300d1 Implement .arena commands - add new commands to the core to handle with arena teams.
*.arena create [player] "arena name" [type]
	*.arena create "arena name" [type]
	*.arena disband [TeamID]
	*.arena rename "oldName" "newName"
	*.arena captain [TeamID] [Player]
	*.arena info [TeamID]
	*.arena lookup [name]
2013-05-22 00:50:51 +03:00
Aokromes
78840516f1 Merge pull request #9827 from Ascathor/master
Core/Command: Rework .PInfo and give more output and add Gender to trinity_string
2013-05-21 09:41:18 -07:00
Spp
00c1168897 Core/Misc: Remove trailing whitespace, compile warnings and minor cosmetic changes 2013-05-21 08:37:28 +02:00
Ascathor
051d6ef925 Core/Command: Rework PInfo and give more output and add Gender to trinity_string
* Prints out in several strings instead of few
* Leaves unnecessary ones out (e.g. phase for GMs)
* Some code documentation included (including doxygen)
* Cleaner code (partly)
* Prints more content, e.g.:
** Localized Class- and Race names
** Localizable Gender names
** Current experience, required experience
** And more

Shoutouts to @Nay, @Subv, @Shauren and several others from the irc

Core/Command: Rework PInfo and give more output and add Gender to trinity_string
2013-05-20 03:09:34 +02:00
Shauren
d6709ed610 Reverted part of 8be181c7e6 that was not supposed to be pushed 2013-05-18 11:49:46 +02:00
Shauren
8be181c7e6 Core/Misc: Fixed a bunch of issues found by static analysis 2013-05-17 20:39:53 +02:00
Nay
60dae46462 Core: Fix compiler warnings 2013-05-16 01:10:53 +01:00
Shauren
8e1601e202 Core/Debugging: Marked assert functions as non returning 2013-05-13 18:12:01 +02:00
Shauren
86d846e627 Core: Fixed windows compile 2013-05-13 18:10:20 +02:00
Spp
d1677b2db0 Core/Logging: Performance-related tweaks to logging system
All sLog->out* functions (except outCommand atm) are replaced with TC_LOG_* macros.
    Memleak fix
2013-05-13 15:07:36 +02:00
xjose93
f2b6b2f95e Core/Commands: Improve .character rename [name], now can force rename .character rename [name] [newName] 2013-04-29 11:26:54 +02:00
Aokromes
1087e5f5c9 Merge pull request #9710 from xjose93/Autobroadcast
Core/World: Improvements in Autobroadcast system (dropped from world database and moved to auth database, added realmid and weight columns)
2013-04-27 05:02:48 -07:00
Aokromes
e486cd7623 Merge pull request #9662 from xjose93/GuildRename
Guild rename
2013-04-27 05:02:07 -07:00
xjose93
d7e9d1bafb Core/World: Improvements in Autobroadcast system (dropped from world database and moved to auth database, added realmid and weight columns) 2013-04-25 22:54:20 +02:00