go-macaron / session

Package session is a middleware that provides the session management of Macaron.
Apache License 2.0
26 stars 27 forks source link

don't release session after websocket closed #25

Closed xmh19936688 closed 5 years ago

xmh19936688 commented 5 years ago

session maybe out-of-date after websocket closed

unknwon commented 5 years ago

Hi, can you explain more? Why needs this fix, fixed what problem?

xmh19936688 commented 5 years ago

Hi, can you explain more? Why needs this fix, fixed what problem?

1st: at 10:00AM, websocket request will block at ctx.Next() and sess fetched at the same time. 2nd: at 10:05AM, post request come in and updated session in ctx.Next() then invoke sess.Release() push data to redis. 3rd: at 10:07AM, websocket disconnect and ctx.Next() return, then session(fetched at 10:00AM) will invoke sess.Releash() and push old data to redis.

unknwon commented 5 years ago

Thank for the use case!

But I think it is better to make this a config option of session, instead of changing the current default behavior.

i.e.

IgnoreReleaseForWebSocket: false
xmh19936688 commented 5 years ago

Like this?

unknwon commented 5 years ago

Thanks for the update. One last mirror problem and we are good to go!

unknwon commented 5 years ago

Thank you!

xmh19936688 commented 5 years ago

🤝