1. Ruslan Osmanov
  2. pecl-event

Commits

Ruslan Osmanov  committed 8b2265d

Change: ret type of EventBufferEvent enable/disable

  • Participants
  • Parent commits 0f78f9d
  • Branches master

Comments (0)

Files changed (3)

File classes/buffer_event.c

View file
  • Ignore whitespace
 }
 /* }}} */
 
-/* {{{ proto void EventBufferEvent::enable(int events);
+/* {{{ proto bool EventBufferEvent::enable(int events);
  * Enable events EVENT_READ, EVENT_WRITE, or EVENT_READ | EVENT_WRITE on a buffer event. */
 PHP_METHOD(EventBufferEvent, enable)
 {
 
 	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
 
-	bufferevent_enable(bev->bevent, events);
+	if (bufferevent_enable(bev->bevent, events)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
 }
 /* }}} */
 
-/* {{{ proto void EventBufferEvent::disable(int events);
+/* {{{ proto bool EventBufferEvent::disable(int events);
  * Disable events EVENT_READ, EVENT_WRITE, or EVENT_READ | EVENT_WRITE on a buffer event. */
 PHP_METHOD(EventBufferEvent,disable)
 {
 
 	PHP_EVENT_FETCH_BEVENT(bev, zbevent);
 
-	bufferevent_disable(bev->bevent, events);
+	if (bufferevent_disable(bev->bevent, events)) {
+		RETURN_FALSE;
+	}
+
+	RETVAL_TRUE;
 }
 /* }}} */
 

File examples/listener.php

View file
  • Ignore whitespace
 		}
 
 		// Variant #1
+		/*
 		$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
 		if (!socket_bind($this->socket, '0.0.0.0', $port)) {
 			echo "Unable to bind socket\n";
 			array($this, "accept_conn_cb"), $this->base,
 			EventListener::OPT_CLOSE_ON_FREE | EventListener::OPT_REUSEABLE,
 			-1, $this->socket);
+		 */
 
-/*		Variant #2
- *		$this->listener = new EventListener($this->base,
- *			array($this, "accept_conn_cb"), $this->base,
- *			EventListener::OPT_CLOSE_ON_FREE | EventListener::OPT_REUSEABLE, -1,
- *			"0.0.0.0:$port");
- */
+//		Variant #2
+ 		$this->listener = new EventListener($this->base,
+ 			array($this, "accept_conn_cb"), $this->base,
+ 			EventListener::OPT_CLOSE_ON_FREE | EventListener::OPT_REUSEABLE, -1,
+ 			"0.0.0.0:$port");
 
 		if (!$this->listener) {
 			echo "Couldn't create listener";
 
 		$this->bev->setCallbacks(array($this, "echo_read_cb"), NULL, array($this, "echo_event_cb"), NULL);
 
-		$this->bev->enable(Event::READ | Event::WRITE);
+		if (!$this->bev->enable(Event::READ | Event::WRITE)) {
+			echo "Failed to enable READ | WRITE\n";
+			exit();
+		}
 	}
 
 	public function accept_error_cb($listener, $ctx) {

File package.xml

View file
  • Ignore whitespace
   <license uri="http://www.php.net/license">PHP</license>
   <notes><![CDATA[
   Fix: redundant Z_ADDREF_P() calls in EventListener, EventBufferEvent constructors and factory methods
+  Change: EventBufferEvent enable/disable methods return bool now
   ]]></notes>
   <!--}}}-->
   <!--{{{ Contents -->
   <license uri="http://www.php.net/license">PHP</license>
   <notes><![CDATA[
   Fix: redundant Z_ADDREF_P() calls in EventListener, EventBufferEvent constructors and factory methods
+  Change: EventBufferEvent enable/disable methods return bool now
   ]]></notes>
   <!--}}}-->
   <!--{{{ 1.2.4-alpha -->