Skip to content

Commit c070067

Browse files
committed
Fix SessionManager database leak
All database access should be wrapped in with_connection blocks. Much of this commit is whitespace. It may help to view it with --ignore-all-space or the w=0 parameter on GitHub. [Story #55586616]
1 parent a815d92 commit c070067

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/msf/core/session_manager.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,17 @@ def initialize(framework)
107107
# processing time for large session lists from skewing our update interval.
108108

109109
last_seen_timer = Time.now.utc
110-
values.each do |s|
111-
# Update the database entry on a regular basis, marking alive threads
112-
# as recently seen. This notifies other framework instances that this
113-
# session is being maintained.
114-
if framework.db.active and s.db_record
115-
s.db_record.last_seen = Time.now.utc
116-
s.db_record.save
110+
if framework.db.active
111+
::ActiveRecord::Base.connection_pool.with_connection do
112+
values.each do |s|
113+
# Update the database entry on a regular basis, marking alive threads
114+
# as recently seen. This notifies other framework instances that this
115+
# session is being maintained.
116+
if s.db_record
117+
s.db_record.last_seen = Time.now.utc
118+
s.db_record.save
119+
end
120+
end
117121
end
118122
end
119123
end

0 commit comments

Comments
 (0)