stretto icon indicating copy to clipboard operation
stretto copied to clipboard

Stacks on close() while code compiled as cdylib

Open Numenorean opened this issue 2 years ago • 1 comments

It's great that with your lib i can do such things

lazy_static! {
    static ref CACHE: Cache<String, TcpStream> = {
        let cache = Cache::new(12000, 1e6 as i64).unwrap();
        cache
    };
}

But there is 2 issues while compiling code as cdylib:

  1. Without cache.close() in DLL_PROCESS_DETACH (yeah, my lib is for windows), it just throws some kind of error, which rust detects while I loading this dll - STATUS_ACCESS_VIOLATION. In another programs this issues cause whole program crash
  2. I find out to prevent that issue i need to call cache.close() in order to clear some memory, stop additional threads, but now it just stacks on closing and do nothing until I kill process I really need your help, because i literally can't find another in-memory cache which can be defined as global value with lazy_static

Numenorean avatar Dec 25 '21 13:12 Numenorean

Hi, there is a method wait which can help you wait for all of the items in the write buffer to be written in the cache (If you have not tried this method). Have you tried to compile the related code on linux? I need to fix out whether it is a bug of Stretto. Or, could you give a piece of example code to help me reproduce the crash situation?

al8n avatar Dec 27 '21 09:12 al8n