linux 读写锁死锁,读写锁unlock时发作死锁

当前位置:我的异常网» Linux/Unix » 读写锁unlock时发作死锁

读写锁unlock时发作死锁

www.myexceptions.net  网友分享于:2014-02-20  浏览:1次

读写锁unlock时产生死锁

最近使用读写锁的时候遇到了一个奇怪的死锁现象:调用pthread_rwlock_unlock竟然阻塞了。

堆栈:

(gdb) t 10

[Switching to thread 10 (Thread 0x7ffd621fc700 (LWP 17864))]#0  0x000000363b80e054 in __lll_lock_wait () from /lib64/libpthread.so.0

(gdb) bt

#0  0x000000363b80e054 in __lll_lock_wait () from /lib64/libpthread.so.0

#1  0x000000363b80ae90 in pthread_rwlock_unlock () from /lib64/libpthread.so.0

#2  0x000000000040e2b9 in OutboundServer::OutbdExcute (this=0x80, outbd_uuid=..., app_name=..., app_arg=..., app_exe_uuid=..., event_lock=253) at ../os/mutex.h:64

#3  0x0000000000413234 in IxApi::execute_lua (this=0x17b7350, lua_name=..., lua_arg=..., cuid=..., event_lock=false) at ixapi.cpp:1089

#4  0x00007ffd8f55b42c in TelMgr::play_agent_num (this=0x17bb920, cuid=..., language=..., agent_num=...) at TelMgr.cpp:2790

#5  0x00007ffd8f574bb8 in QueueMgr::OnEvent_Answer (this=0x17ce780, msg=0x17ce788) at ../queue_and_acd/QueueMgr.cpp:876

#6  0x00007ffd8f57528c in QueueMgr::processMsg (this=0x17ce780, event=0x80) at ../queue_and_acd/QueueMgr.cpp:473

#7  0x00007ffd8f5755a7 in QueueMgrThread::run (this=0x17d1f40) at ../queue_and_acd/QueueMgr.cpp:421

#8  0x000000000042a717 in util::Thread::threadFun (this=0x17d1f40) at thread.cpp:92

#9  0x000000000042a4aa in util::Thread::begin (pArg=0x7ffd8802ae78) at thread.cpp:35

#10 0x000000363b807851 in start_thread () from /lib64/libpthread.so.0

#11 0x000000363b0e890d in clone () from /lib64/libc.so.6

代码:

std::string OutboundServer::OutbdExcute(const  string outbd_uuid,const std :: string app_name,const std :: string app_arg,const std :: string app_exe_uuid,bool event_lock)

{

Oubound_handle_t *handle = ListenThread->otbdConnections.find(outbd_uuid);

if(!handle)

{

TelError<

return "-1";

}

TelTrace<handle->sock<

util::MutexLock lock(handle->handle_Guard);

if(event_lock)

handle->handle->event_lock = 1;

else

handle->handle->event_lock = 0;

if(ESL_SUCCESS!=esl_execute(handle->handle,app_name.c_str(),app_arg.c_str(),app_exe_uuid.c_str()))

return "-1";

if(!handle->handle->last_sr_reply)

return "-1";

return handle->handle->last_sr_reply;

}

这个锁是类内部的锁,且只有一个函数使用(会存在多线程的情况,所以加了锁),且使用的地方是自动锁,所以好奇问一下大家有没有遇到这样的问题?大概会是什么原因?谢谢!

------解决方案--------------------

失败的情况下,也是需要解锁的!

加锁后,不管什么情况都是需要解锁的!

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值