sbsm 1.4.5 → 1.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +6 -0
- data/lib/sbsm/admin_server.rb +2 -2
- data/lib/sbsm/app.rb +3 -1
- data/lib/sbsm/logger.rb +0 -0
- data/lib/sbsm/session.rb +4 -3
- data/lib/sbsm/session_store.rb +19 -16
- data/lib/sbsm/state.rb +0 -0
- data/lib/sbsm/user.rb +0 -0
- data/lib/sbsm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60f4a61bb07708b12676dc908a0de85f373c5b17
|
4
|
+
data.tar.gz: 496054938b87a49afb78c8269edc3ec77c1e6a19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e048c7a06458e3327852f4a9a9a582fd44a476f8385a491c77352f54da1471de42d59968be3381b583587b097f5b964db12cfc063f50c64aa889a1212c51926
|
7
|
+
data.tar.gz: a4eb100131a6255fbe1c8fd0448d27ad061d70f3e33f9b5fbaa957f6b235bdfc984dfe74bd81397d55de8df8b320446c8e174f7aad735dae2cfc83cd778a560c
|
data/History.txt
CHANGED
data/lib/sbsm/admin_server.rb
CHANGED
@@ -37,8 +37,8 @@ require 'sbsm/session_store'
|
|
37
37
|
module SBSM
|
38
38
|
# AdminClass must be tied to an Rack app
|
39
39
|
class AdminServer
|
40
|
-
def initialize(app:)
|
41
|
-
@session = SBSM::SessionStore.new(app: app)
|
40
|
+
def initialize(app:, multi_threaded: false)
|
41
|
+
@session = SBSM::SessionStore.new(app: app, multi_threaded: multi_threaded)
|
42
42
|
@admin_threads = ThreadGroup.new
|
43
43
|
end
|
44
44
|
def _admin(src, result, priority=0)
|
data/lib/sbsm/app.rb
CHANGED
@@ -35,6 +35,7 @@ module SBSM
|
|
35
35
|
###
|
36
36
|
# App as a member of session
|
37
37
|
class App
|
38
|
+
attr_reader :unknown_user
|
38
39
|
|
39
40
|
def initialize()
|
40
41
|
SBSM.info "initialize"
|
@@ -43,6 +44,7 @@ module SBSM
|
|
43
44
|
|
44
45
|
class RackInterface
|
45
46
|
attr_accessor :session # thread variable!
|
47
|
+
attr_reader :session_store, :unknown_user
|
46
48
|
SESSION_ID = '_session_id'
|
47
49
|
|
48
50
|
# Base class for a SBSM based WebRick HTTP server
|
@@ -84,6 +86,7 @@ module SBSM
|
|
84
86
|
unknown_user: unknown_user,
|
85
87
|
validator: validator,
|
86
88
|
multi_threaded: multi_threaded)
|
89
|
+
@unknown_user = unknown_user
|
87
90
|
end
|
88
91
|
|
89
92
|
def last_session
|
@@ -143,7 +146,6 @@ module SBSM
|
|
143
146
|
response.set_cookie(key, { :value => value, :path => '/' })
|
144
147
|
end
|
145
148
|
response.set_cookie(SESSION_ID, { :value => session_id, :path => '/' }) unless request.cookies[SESSION_ID]
|
146
|
-
|
147
149
|
# response.set_cookie(SBSM::Session.get_cookie_name, session_id)
|
148
150
|
@@last_session = session
|
149
151
|
if response.headers['Set-Cookie'].to_s.index(session_id)
|
data/lib/sbsm/logger.rb
CHANGED
File without changes
|
data/lib/sbsm/session.rb
CHANGED
@@ -31,6 +31,7 @@ require 'sbsm/cgi'
|
|
31
31
|
require 'sbsm/state'
|
32
32
|
require 'sbsm/user'
|
33
33
|
require 'sbsm/lookandfeelfactory'
|
34
|
+
require 'sbsm/trans_handler'
|
34
35
|
require 'delegate'
|
35
36
|
|
36
37
|
module SBSM
|
@@ -571,16 +572,16 @@ module SBSM
|
|
571
572
|
# nothing
|
572
573
|
end
|
573
574
|
def delete
|
574
|
-
@app.delete_session
|
575
|
+
@app.delete_session(@key)
|
575
576
|
end
|
576
577
|
def zone
|
577
|
-
@valid_input[:zone] || @state.zone || self::class::DEFAULT_ZONE
|
578
|
+
@valid_input[:zone] || (@state && @state.zone) || self::class::DEFAULT_ZONE
|
578
579
|
end
|
579
580
|
def zones
|
580
581
|
@active_state.zones
|
581
582
|
end
|
582
583
|
def zone_navigation
|
583
|
-
@state.zone_navigation
|
584
|
+
@state.zone_navigation if @state
|
584
585
|
end
|
585
586
|
def ==(other)
|
586
587
|
super
|
data/lib/sbsm/session_store.rb
CHANGED
@@ -33,6 +33,7 @@ require 'thread'
|
|
33
33
|
require 'digest/md5'
|
34
34
|
require 'sbsm/logger'
|
35
35
|
require 'sbsm/validator'
|
36
|
+
require 'sbsm/session_store'
|
36
37
|
|
37
38
|
module SBSM
|
38
39
|
#
|
@@ -49,6 +50,8 @@ module SBSM
|
|
49
50
|
UNKNOWN_USER = UnknownUser
|
50
51
|
VALIDATOR = nil
|
51
52
|
attr_reader :cleaner, :updater, :persistence_layer
|
53
|
+
@@mutex = Mutex.new
|
54
|
+
@@sessions = {}
|
52
55
|
def initialize(app:,
|
53
56
|
persistence_layer: nil,
|
54
57
|
trans_handler: nil,
|
@@ -58,8 +61,6 @@ module SBSM
|
|
58
61
|
unknown_user: UNKNOWN_USER.new,
|
59
62
|
multi_threaded: nil)
|
60
63
|
fail "You must specify an app!" unless app
|
61
|
-
@sessions = {}
|
62
|
-
@mutex = Mutex.new
|
63
64
|
@cleaner = run_cleaner if(self.class.const_get(:RUN_CLEANER))
|
64
65
|
@app = app
|
65
66
|
@system = persistence_layer
|
@@ -74,13 +75,13 @@ module SBSM
|
|
74
75
|
@validator = validator
|
75
76
|
end
|
76
77
|
def cap_max_sessions(now = Time.now)
|
77
|
-
if(
|
78
|
+
if(@@sessions.size > self::class::CAP_MAX_THRESHOLD)
|
78
79
|
SBSM.info "too many sessions! Keeping only #{self::class::MAX_SESSIONS}"
|
79
80
|
sess = nil
|
80
|
-
sorted =
|
81
|
+
sorted = @@sessions.values.sort
|
81
82
|
sorted[0...(-self::class::MAX_SESSIONS)].each { |sess|
|
82
83
|
sess.__checkout
|
83
|
-
|
84
|
+
@@sessions.delete(sess.key)
|
84
85
|
}
|
85
86
|
if(sess)
|
86
87
|
age = sess.age(now)
|
@@ -90,7 +91,7 @@ module SBSM
|
|
90
91
|
end
|
91
92
|
def clean
|
92
93
|
now = Time.now
|
93
|
-
|
94
|
+
@@sessions.delete_if { |key, s|
|
94
95
|
begin
|
95
96
|
if s.respond_to?(:expired?)
|
96
97
|
if s.expired?(now)
|
@@ -109,18 +110,20 @@ module SBSM
|
|
109
110
|
}
|
110
111
|
#cap_max_sessions(now)
|
111
112
|
end
|
112
|
-
def clear
|
113
|
-
|
114
|
-
|
113
|
+
def SessionStore.clear
|
114
|
+
@@mutex.synchronize do
|
115
|
+
@@sessions.each_value { |sess| sess.__checkout }
|
116
|
+
@@sessions.clear
|
117
|
+
end
|
115
118
|
end
|
116
119
|
def delete_session(key)
|
117
|
-
if(sess =
|
120
|
+
if(sess = @@sessions.delete(key))
|
118
121
|
sess.__checkout
|
119
122
|
end
|
120
123
|
end
|
121
124
|
def reset
|
122
|
-
|
123
|
-
|
125
|
+
@@mutex.synchronize {
|
126
|
+
@@sessions.clear
|
124
127
|
}
|
125
128
|
end
|
126
129
|
def run_cleaner
|
@@ -130,16 +133,16 @@ module SBSM
|
|
130
133
|
#Thread.current.priority = 1
|
131
134
|
loop do
|
132
135
|
sleep self::class::CLEANING_INTERVAL
|
133
|
-
|
136
|
+
@@mutex.synchronize do
|
134
137
|
clean()
|
135
138
|
end
|
136
139
|
end
|
137
140
|
end
|
138
141
|
end
|
139
142
|
def [](key)
|
140
|
-
|
141
|
-
unless((s =
|
142
|
-
s =
|
143
|
+
@@mutex.synchronize do
|
144
|
+
unless((s = @@sessions[key]) && !s.expired?)
|
145
|
+
s = @@sessions[key] = @session_class.new(app: @app, cookie_name: @cookie_name, trans_handler: @trans_handler, validator: @validator, unknown_user: @unknown_user)
|
143
146
|
end
|
144
147
|
s.reset()
|
145
148
|
s.touch()
|
data/lib/sbsm/state.rb
CHANGED
File without changes
|
data/lib/sbsm/user.rb
CHANGED
File without changes
|
data/lib/sbsm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|