Skip to content

Commit

Permalink
fix bug in MacOs
Browse files Browse the repository at this point in the history
  • Loading branch information
yunnian committed Oct 15, 2019
1 parent 212f895 commit 805bc41
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ set(SOURCE_FILES
sub.h
pub.c
pub.h
message.h
message.c

)

Expand Down
2 changes: 1 addition & 1 deletion command.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

#ifndef STRUGGLE_NSQ_MESSAGE_CLIENT_C_H
#define STRUGGLE_NSQ_MESSAGE_CLIENT_C_H char * request(char * url);
#define STRUGGLE_NSQ_MESSAGE_CLIENT_C_H

void nsq_subscribe(struct bufferevent *bev, const char *topic, const char *channel);

Expand Down
2 changes: 1 addition & 1 deletion examples/pub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//the nsqd tcp addr that you want to publish
$nsqdAddr = array(
"127.0.0.1:4150", //tcp addr
"127.0.0.1:4154",
//"127.0.0.1:4154", if you have another nsqd addr
);
$nsq = new Nsq();
$isTrue = $nsq->connectNsqd($nsqdAddr);
Expand Down
1 change: 1 addition & 0 deletions examples/sub.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"retry_delay_time" => 5000, // after 5000 msec, message will be retried
"auto_finish" => true,
);
//new NsqMessage();

$nsq->subscribe($nsq_lookupd, $config, function($msg,$bev){

Expand Down
5 changes: 3 additions & 2 deletions message.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
*/

#include <php.h>
#include <event2/bufferevent.h>
#include "ext/standard/php_var.h"
#include <message.h>
#include <event2/bufferevent.h>
#include "command.h"

zend_class_entry *nsq_message_ce;
Expand Down Expand Up @@ -88,7 +89,7 @@ static const zend_function_entry nsq_message_functions[] = {

};

void message_init(){
void nsq_message_init() {
zend_class_entry nsq_message;
INIT_CLASS_ENTRY(nsq_message,"NsqMessage",nsq_message_functions);
nsq_message_ce = zend_register_internal_class(&nsq_message TSRMLS_CC);
Expand Down
25 changes: 25 additions & 0 deletions message.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
+----------------------------------------------------------------------+
| Copyright (c) 1997-2017 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Zhenyu Wu <[email protected]> |
+----------------------------------------------------------------------+
*/



#ifndef STRUGGLE_NSQ_MESSAGE_H_CLIENT
#define STRUGGLE_NSQ_MESSAGE_H_CLIENT

void nsq_message_init();
//extern int le_bufferevent;

#endif
6 changes: 3 additions & 3 deletions nsq.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
#include <event2/buffer.h>
#include <event2/listener.h>
#include <signal.h>
#include<sys/wait.h>
#include <sys/wait.h>

#include "ext/standard/php_string.h"
#include "sub.h"
#include "pub.h"
#include "message.h"
#include "nsq_lookupd.h"
#include "zend_exceptions.h"
//#include <sys/prctl.h>
Expand Down Expand Up @@ -599,9 +600,8 @@ PHP_MINIT_FUNCTION (nsq)
zend_declare_property_null(nsq_ce, ZEND_STRL("nsqd_connection_fds"), ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_null(nsq_ce, ZEND_STRL("conn_timeout"), ZEND_ACC_PUBLIC TSRMLS_CC);
le_bufferevent = zend_register_list_destructors_ex(_php_bufferevent_dtor, NULL, "buffer event", module_number);

lookupd_init();
message_init();
nsq_message_init();

return SUCCESS;
}
Expand Down
3 changes: 1 addition & 2 deletions nsq_lookupd.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#include <php.h>
#include "nsq_lookupd.h"
#include <stdio.h>
#include <string.h>
#include <assert.h>
Expand Down Expand Up @@ -45,7 +44,7 @@ ZEND_END_ARG_INFO()

static PHP_METHOD(NsqLookupd, __construct);

static zend_class_entry *nsq_lookupd_ce;
zend_class_entry *nsq_lookupd_ce;

static const zend_function_entry nsq_lookupd_functions[] = {
PHP_ME(NsqLookupd, __construct, ctor, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
Expand Down
4 changes: 3 additions & 1 deletion nsq_lookupd.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/

#ifndef STRUGGLE_NSQ_LOOKUP_CLIENT_C_H
#define STRUGGLE_NSQ_LOOKUP_CLIENT_C_H char * request(char * url);
#define STRUGGLE_NSQ_LOOKUP_CLIENT_C_H

char * request(char * url);

void lookupd_init();

Expand Down
8 changes: 4 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<email>[email protected]</email>
<active>yes</active>
</lead>
<date>2019-09-17</date>
<date>2019-10-15</date>
<version>
<release>3.4.3</release>
<release>3.5.0</release>
<api>2.0.0</api>
</version>
<stability>
Expand All @@ -26,8 +26,7 @@
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>
* Fix the problem of sub-processes not restarting automatically in CentOS environment
* this version is Stable
* Fix the bug in MacOs
</notes>
<contents>
<dir name="/">
Expand All @@ -48,6 +47,7 @@
<file role='src' name='common.c'/>
<file role='src' name='command.c'/>
<file role='src' name='command.h'/>
<file role='src' name='message.h'/>
<file role='src' name='message.c'/>
<dir name="examples">
<file role='doc' name='identify_pub.php'/>
Expand Down
3 changes: 1 addition & 2 deletions php_nsq.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
extern zend_module_entry nsq_module_entry;
#define phpext_nsq_ptr &nsq_module_entry

#define PHP_NSQ_VERSION "3.4.3" /* Replace with version number for your extension */
#define PHP_NSQ_VERSION "3.5.0" /* Replace with version number for your extension */

#ifdef PHP_WIN32
# define PHP_NSQ_API __declspec(dllexport)
Expand All @@ -37,7 +37,6 @@ extern zend_module_entry nsq_module_entry;
#define get_object_handle(object) Z_OBJ_HANDLE_P(object)


void message_init();

void error_handlings(char *message);

Expand Down

0 comments on commit 805bc41

Please sign in to comment.