Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28197 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70308 invoked by uid 1010); 1 Mar 2007 15:17:40 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 70293 invoked from network); 1 Mar 2007 15:17:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Mar 2007 15:17:40 -0000 Authentication-Results: pb1.pair.com header.from=bs@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=bs@php.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain php.net from 217.13.204.132 cause and error) X-PHP-List-Original-Sender: bs@php.net X-Host-Fingerprint: 217.13.204.132 mx.zenyo.de Linux 2.5 (sometimes 2.4) (4) Received: from [217.13.204.132] ([217.13.204.132:60633] helo=mx.zenyo.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 21/86-16569-29EE6E54 for ; Thu, 01 Mar 2007 10:17:39 -0500 Received: (qmail 15437 invoked from network); 1 Mar 2007 15:16:51 -0000 Received: from unknown (HELO mail.rz.ih.zenyo.de) (217.13.204.157) by mx.zenyo.de with SMTP; 1 Mar 2007 15:16:51 -0000 Received: (qmail 28479 invoked from network); 1 Mar 2007 15:17:48 -0000 Received: from unknown (HELO ?10.0.129.10?) (bs@10.0.129.10) by mail.rz.ih.zenyo.de with ESMTPA; 1 Mar 2007 15:17:48 -0000 Mime-Version: 1.0 (Apple Message framework v752.3) To: wez@php.net, internals Mailing List Message-ID: <64626A16-DE42-43AD-A6BB-37153EBB4D2E@php.net> Content-Type: multipart/mixed; boundary=Apple-Mail-3--965963535 Date: Thu, 1 Mar 2007 16:17:28 +0100 X-Mailer: Apple Mail (2.752.3) Subject: [PATCH] ext/sysvmsg: msg_queue_exists() From: bs@php.net (Benjamin Schulz) --Apple-Mail-3--965963535 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hi Wez, this patch that adds a msg_queue_exists() to ext/sysvmsg. Currently there is no way to tell wether msg_get_queue() will create or just a attach to a queue. It would be great to see this function in the next PHP release. Benjamin --Apple-Mail-3--965963535 Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name=msg_queue_exists.diff.txt Content-Disposition: attachment; filename=msg_queue_exists.diff.txt diff -u php-5.2.1/ext/sysvmsg/php_sysvmsg.h php-5.2.1-patched/ext/sysvmsg/php_sysvmsg.h --- php-5.2.1/ext/sysvmsg/php_sysvmsg.h 2007-01-08 23:34:07.000000000 +0100 +++ php-5.2.1-patched/ext/sysvmsg/php_sysvmsg.h 2007-03-01 15:51:28.000000000 +0100 @@ -48,6 +48,7 @@ PHP_FUNCTION(msg_set_queue); PHP_FUNCTION(msg_send); PHP_FUNCTION(msg_receive); +PHP_FUNCTION(msg_queue_exists); typedef struct { key_t key; diff -u php-5.2.1/ext/sysvmsg/sysvmsg.c php-5.2.1-patched/ext/sysvmsg/sysvmsg.c --- php-5.2.1/ext/sysvmsg/sysvmsg.c 2007-01-17 09:25:32.000000000 +0100 +++ php-5.2.1-patched/ext/sysvmsg/sysvmsg.c 2007-03-01 15:51:28.000000000 +0100 @@ -72,6 +72,7 @@ PHP_FE(msg_remove_queue, NULL) PHP_FE(msg_stat_queue, NULL) PHP_FE(msg_set_queue, NULL) + PHP_FE(msg_queue_exists, NULL) {NULL, NULL, NULL} /* Must be the last line in sysvmsg_functions[] */ }; /* }}} */ @@ -206,6 +207,26 @@ } /* }}} */ + +/* {{{ proto bool msg_queue_exists(int key) + Check wether a message queue exists */ +PHP_FUNCTION(msg_queue_exists) +{ + long key; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &key) == FAILURE) { + return; + } + + if (msgget(key, 0) < 0) { + RETURN_FALSE; + } + + RETURN_TRUE; +} +/* }}} */ + + /* {{{ proto resource msg_get_queue(int key [, int perms]) Attach to a message queue */ PHP_FUNCTION(msg_get_queue) --Apple-Mail-3--965963535--