Skip to content

Commit

Permalink
fix: Server crash caused by using Logger.DropSink() (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
F1F88 committed Nov 9, 2024
1 parent 10b0318 commit 8d09191
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sourcemod/scripting/include/log4sp/logger.inc
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,26 @@ methodmap Logger < Handle
/**
* Add a new sink to sinks.
*
* @note This native has thread safety issues (will not cause crashes)
* See: https://github.com/F1F88/sm-ext-log4sp/issues/4
*
* @param sink Handle of sink.
* @error Invalid logger handle, invalid sink handle.
*/
#pragma deprecated Use new Logger(). (May be removed in the future version)
public native void AddSink(Sink sink);

/**
* Drop the reference to the given sink
*
* @note This native has a fatal thread safety issue (may cause crash)
* See: https://github.com/F1F88/sm-ext-log4sp/issues/4
*
* @param sink Handle of Sink.
* @return True on success, false if the sink was not found.
* @error Invalid logger handle, invalid sink handle.
*/
#pragma deprecated This native may cause server crashes. (Expected to be removed in the next version)
public native bool DropSink(Sink sink);

/**
Expand Down
2 changes: 2 additions & 0 deletions sourcemod/scripting/include/log4sp_empty/logger.inc
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ methodmap Logger < Handle
public void DisableBacktrace() {}
public void DumpBacktrace() {}

#pragma deprecated Use new Logger(). (May be removed in the future)
public void AddSink(Sink sink) {}
#pragma deprecated This native may cause server crashes. (Expected to be removed in the next version)
public bool DropSink(Sink sink) { return false; }

public void SetErrorHandler(Log4spErrorCallback callback) {}
Expand Down

0 comments on commit 8d09191

Please sign in to comment.