贴: Warning: msg_get_queue(): failed for key 0x610005bd: File exists in

原创
2016-06-23 13:55:10 1196浏览

我在我的环境里, 写了如下一个php文件:
$msg_key = ftok(__FILE__, 'a');
$seg = msg_get_queue($msg_key, 0666);
?>
然后用命令行执行不能输出错误.

但在网页执行的时候, 就会发生以下错误:
Warning: msg_get_queue(): failed for key 0x610005bd: File exists in /var/www/html/test/sysvmsg.php on line 4

困扰了我一个下午, 求高手赐教.
我的环境:linux + apache + php 5.3.3


回复讨论(解决方案)

看看php的文档说http://php.net/msg_get_queue

echo 100 > /proc/sys/fs/mqueue/msg_max

ftok 返回一个整数
msg_get_queue 发送一个消息

十六进制的 0x610005bd 是十进制的 1627391421

你得到并发送的不就是这个数吗?

If you are getting this message on your *NIX box:

Warning: msg_get_queue() [function.msg-get-queue]: failed for key 0x12345678: No space left on device in /path/to/script.php on line 1

you may use the command "ipcrm" as root to clear the message queue. Use "man ipcrm" to get more info on it.
The default setting for maximum messages in the queue is stored in /proc/sys/fs/mqueue/msg_max. To increase it to a maximum of 100 messages, just run:
echo 100 > /proc/sys/fs/mqueue/msg_max

Please ensure to follow a good programming style and close/free all your message queues before your script exits to avoid those warning messages.
这是手册里的,跟你的情况是一致的吧!

你可以用命令ipcrm做为root清楚消息队列,再用 man ipcrm得到更多的信息。
在队列默认最大的消息存储在/proc/sys/fs/mqueue/msg_max里,想增加最多100条消息的话,可执行
echo 100 > /proc/sys/fs/mqueue/msg_max

http://www.baidu.com/baidu?wd=Warning%3A+msg_get_queue%28%29%3A+failed+for+key+0x610005bd%3A+File+exists+in+%2Fvar%2Fwww%2Fhtml%2Ftest%2Fsysvmsg.php+on+line+4&tn=monline_dg

最终查明原因是: SELinux未关闭

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。