zoukankan      html  css  js  c++  java
  • boost的named_mutex的一些坑

    最近遇到一个问题,程序在a用户下运行后,然后注销windows,登陆b用户,发现程序奔溃,抓了下堆栈,发现了boost的named_mutex一些细节,记录下

    #include <boost/interprocess/sync/named_mutex.hpp>
    #include <boost/interprocess/creation_tags.hpp>
    boost::interprocess::named_mutex mutex(boost::interprocess::open_or_create, "haha");
    1.这段代码在a用户运行后,注销,在运行b用户,直接崩溃
    解决方案
    boost::interprocess::permissions per;
    per.set_unrestricted();
    boost::interprocess::named_mutex mutex(boost::interprocess::open_or_create, "haha",per);
    
    文件中的几个值的意义
    UninitializedSegment, //0
    InitializingSegment, //1
    InitializedSegment, //2
    CorruptedSegment //3
    定义在boostinterprocessdetailmanaged_open_or_create_impl.hpp
    开始初始化为1,进程退出的时候改为2
     
    2.文件创建在priv_open_or_create函数里面,其中文件夹在create_device里面创建,该函数最终调用
    get_last_bootup_time(boostinterprocessdetailwin32_api.hpp) 函数会根据系统的事件来获取启动时间,
    如果进程启动之前,系统的日志被一些清理工具清理掉了,那么就会触发异常
     
  • 相关阅读:
    跨域请求携带cookie
    vue keep-alive
    关于js replace 第二个参数时函数时,函数参数解析
    前端开发规范之CSS
    git命令集合(正在完善中...)
    怎么写jQuery的插件
    git命令集合
    GitHub创建静态网站预览方法
    正则表达式
    各种浏览器全屏模式的方法、属性和事件介绍
  • 原文地址:https://www.cnblogs.com/ultracpp/p/6832201.html
Copyright © 2011-2022 走看看