Skip to content

Commit

Permalink
Merge branch 'master' of gitee.com:swoole/swoole
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Nov 19, 2018
2 parents 8ae094b + c73e708 commit cb71f50
Show file tree
Hide file tree
Showing 51 changed files with 1,255 additions and 1,354 deletions.
2 changes: 1 addition & 1 deletion README-CN.md
Expand Up @@ -487,7 +487,7 @@ make && sudo make install
## 💎 框架 & 组件

- [**Swoft**](https://github.com/swoft-cloud) 是一个现代化的面向切面的高性能协程全栈组件化框架
- [**Easyswoole**](https://github.com/swoft-cloud) 是一个极简的高性能的框架, 让代码开发就好像写`echo "hello world"`一样简单
- [**Easyswoole**](https://www.easyswoole.com) 是一个极简的高性能的框架, 让代码开发就好像写`echo "hello world"`一样简单
- [**Saber**](https://github.com/swlib/saber) 是一个人性化的高性能HTTP客户端组件,几乎拥有一切你可以想象的强大功能

## 🛠 开发 & 讨论
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -482,7 +482,7 @@ After compiling and installing to the system successfully, you need to add a new
## 💎 Frameworks & Components

- [**Swoft**](https://github.com/swoft-cloud) is a modern, high-performance AOP and coroutine PHP framework.
- [**Easyswoole**](https://github.com/swoft-cloud) is a simple, high-performance PHP framework, based on Swoole, which makes using Swoole as easy as `echo "hello world"`.
- [**Easyswoole**](https://www.easyswoole.com) is a simple, high-performance PHP framework, based on Swoole, which makes using Swoole as easy as `echo "hello world"`.
- [**Saber**](https://github.com/swlib/saber) Is a human-friendly, high-performance HTTP client component that has almost everything you can imagine.

## 🛠 Develop & Discussion
Expand Down
265 changes: 265 additions & 0 deletions examples/coroutine/stack/1.php
@@ -0,0 +1,265 @@
<?php
go(function () {
$a_255 = 255;
$a_254 = 254;
$a_253 = 253;
$a_252 = 252;
$a_251 = 251;
$a_250 = 250;
$a_249 = 249;
$a_248 = 248;
$a_247 = 247;
$a_246 = 246;
$a_245 = 245;
$a_244 = 244;
$a_243 = 243;
$a_242 = 242;
$a_241 = 241;
$a_240 = 240;
$a_239 = 239;
$a_238 = 238;
$a_237 = 237;
$a_236 = 236;
$a_235 = 235;
$a_234 = 234;
$a_233 = 233;
$a_232 = 232;
$a_231 = 231;
$a_230 = 230;
$a_229 = 229;
$a_228 = 228;
$a_227 = 227;
$a_226 = 226;
$a_225 = 225;
$a_224 = 224;
$a_223 = 223;
$a_222 = 222;
$a_221 = 221;
$a_220 = 220;
$a_219 = 219;
$a_218 = 218;
$a_217 = 217;
$a_216 = 216;
$a_215 = 215;
$a_214 = 214;
$a_213 = 213;
$a_212 = 212;
$a_211 = 211;
$a_210 = 210;
$a_209 = 209;
$a_208 = 208;
$a_207 = 207;
$a_206 = 206;
$a_205 = 205;
$a_204 = 204;
$a_203 = 203;
$a_202 = 202;
$a_201 = 201;
$a_200 = 200;
$a_199 = 199;
$a_198 = 198;
$a_197 = 197;
$a_196 = 196;
$a_195 = 195;
$a_194 = 194;
$a_193 = 193;
$a_192 = 192;
$a_191 = 191;
$a_190 = 190;
$a_189 = 189;
$a_188 = 188;
$a_187 = 187;
$a_186 = 186;
$a_185 = 185;
$a_184 = 184;
$a_183 = 183;
$a_182 = 182;
$a_181 = 181;
$a_180 = 180;
$a_179 = 179;
$a_178 = 178;
$a_177 = 177;
$a_176 = 176;
$a_175 = 175;
$a_174 = 174;
$a_173 = 173;
$a_172 = 172;
$a_171 = 171;
$a_170 = 170;
$a_169 = 169;
$a_168 = 168;
$a_167 = 167;
$a_166 = 166;
$a_165 = 165;
$a_164 = 164;
$a_163 = 163;
$a_162 = 162;
$a_161 = 161;
$a_160 = 160;
$a_159 = 159;
$a_158 = 158;
$a_157 = 157;
$a_156 = 156;
$a_155 = 155;
$a_154 = 154;
$a_153 = 153;
$a_152 = 152;
$a_151 = 151;
$a_150 = 150;
$a_149 = 149;
$a_148 = 148;
$a_147 = 147;
$a_146 = 146;
$a_145 = 145;
$a_144 = 144;
$a_143 = 143;
$a_142 = 142;
$a_141 = 141;
$a_140 = 140;
$a_139 = 139;
$a_138 = 138;
$a_137 = 137;
$a_136 = 136;
$a_135 = 135;
$a_134 = 134;
$a_133 = 133;
$a_132 = 132;
$a_131 = 131;
$a_130 = 130;
$a_129 = 129;
$a_128 = 128;
$a_127 = 127;
$a_126 = 126;
$a_125 = 125;
$a_124 = 124;
$a_123 = 123;
$a_122 = 122;
$a_121 = 121;
$a_120 = 120;
$a_119 = 119;
$a_118 = 118;
$a_117 = 117;
$a_116 = 116;
$a_115 = 115;
$a_114 = 114;
$a_113 = 113;
$a_112 = 112;
$a_111 = 111;
$a_110 = 110;
$a_109 = 109;
$a_108 = 108;
$a_107 = 107;
$a_106 = 106;
$a_105 = 105;
$a_104 = 104;
$a_103 = 103;
$a_102 = 102;
$a_101 = 101;
$a_100 = 100;
$a_99 = 99;
$a_98 = 98;
$a_97 = 97;
$a_96 = 96;
$a_95 = 95;
$a_94 = 94;
$a_93 = 93;
$a_92 = 92;
$a_91 = 91;
$a_90 = 90;
$a_89 = 89;
$a_88 = 88;
$a_87 = 87;
$a_86 = 86;
$a_85 = 85;
$a_84 = 84;
$a_83 = 83;
$a_82 = 82;
$a_81 = 81;
$a_80 = 80;
$a_79 = 79;
$a_78 = 78;
$a_77 = 77;
$a_76 = 76;
$a_75 = 75;
$a_74 = 74;
$a_73 = 73;
$a_72 = 72;
$a_71 = 71;
$a_70 = 70;
$a_69 = 69;
$a_68 = 68;
$a_67 = 67;
$a_66 = 66;
$a_65 = 65;
$a_64 = 64;
$a_63 = 63;
$a_62 = 62;
$a_61 = 61;
$a_60 = 60;
$a_59 = 59;
$a_58 = 58;
$a_57 = 57;
$a_56 = 56;
$a_55 = 55;
$a_54 = 54;
$a_53 = 53;
$a_52 = 52;
$a_51 = 51;
$a_50 = 50;
$a_49 = 49;
$a_48 = 48;
$a_47 = 47;
$a_46 = 46;
$a_45 = 45;
$a_44 = 44;
$a_43 = 43;
$a_42 = 42;
$a_41 = 41;
$a_40 = 40;
$a_39 = 39;
$a_38 = 38;
$a_37 = 37;
$a_36 = 36;
$a_35 = 35;
$a_34 = 34;
$a_33 = 33;
$a_32 = 32;
$a_31 = 31;
$a_30 = 30;
$a_29 = 29;
$a_28 = 28;
$a_27 = 27;
$a_26 = 26;
$a_25 = 25;
$a_24 = 24;
$a_23 = 23;
$a_22 = 22;
$a_21 = 21;
$a_20 = 20;
$a_19 = 19;
$a_18 = 18;
$a_17 = 17;
$a_16 = 16;
$a_15 = 15;
$a_14 = 14;
$a_13 = 13;
$a_12 = 12;
$a_11 = 11;
$a_10 = 10;
$a_9 = 9;
$a_8 = 8;
$a_7 = 7;
$a_6 = 6;
$a_5 = 5;
$a_4 = 4;
$a_3 = 3;
$a_2 = 2;
$a_1 = 1;
$a_0 = 0;

echo "before\n";
co::sleep(0.5);
echo "after\n";
});
echo "end\n";

8 changes: 8 additions & 0 deletions examples/coroutine/stack/2.php
@@ -0,0 +1,8 @@
<?php
go(function () {
echo "before\n";
co::sleep(0.5);
echo "after\n";
});
echo "end\n";

2 changes: 1 addition & 1 deletion include/swoole.h
Expand Up @@ -87,7 +87,7 @@ int daemon(int nochdir, int noclose);

/*----------------------------------------------------------------------------*/

#define SWOOLE_VERSION "4.2.7"
#define SWOOLE_VERSION "4.2.8-alpha"
#define SWOOLE_BUG_REPORT \
"A bug occurred in Swoole-v" SWOOLE_VERSION ", please report it.\n"\
"The Swoole developers probably don't know about it,\n"\
Expand Down
2 changes: 1 addition & 1 deletion php_swoole.h
Expand Up @@ -530,7 +530,7 @@ static sw_inline int php_swoole_is_callable(zval *callback)
char *func_name = NULL;
if (!sw_zend_is_callable(callback, 0, &func_name))
{
swoole_php_fatal_error(E_WARNING, "Function '%s' is not callable", func_name);
swoole_php_fatal_error(E_WARNING, "function '%s' is not callable", func_name);
efree(func_name);
return SW_FALSE;
}
Expand Down
13 changes: 3 additions & 10 deletions src/coroutine/base.cc
Expand Up @@ -143,7 +143,7 @@ int coroutine_create(coroutine_func_t fn, void* args)
int cid = alloc_cidmap();
if (unlikely(cid == -1))
{
swWarn("alloc_cidmap failed");
swWarn("alloc_cidmap failed, may reaches the limit of allocation %d", MAX_CORO_NUM_LIMIT);
return CORO_LIMIT;
}
coroutine_t *co = new coroutine_s(cid, swCoroG.stack_size, fn, args);
Expand Down Expand Up @@ -260,19 +260,12 @@ void* coroutine_get_current_task()
int coroutine_get_current_cid()
{
coroutine_t* co = coroutine_get_current();
if (likely(co))
{
return co->cid;
}
else
{
return -1;
}
return likely(co) ? co->cid : -1;
}

int coroutine_get_cid(coroutine_t *co)
{
return co->cid;
return likely(co) ? co->cid : -1;
}

int coroutine_test_alloc_cid()
Expand Down
5 changes: 0 additions & 5 deletions src/network/server.c
Expand Up @@ -247,11 +247,6 @@ static int swServer_start_check(swServer *serv)
swWarn("onTask is null");
return SW_ERR;
}
if (serv->onFinish == NULL)
{
swWarn("onFinish is null");
return SW_ERR;
}
if (serv->task_worker_num > SW_CPU_NUM * SW_MAX_WORKER_NCPU)
{
swWarn("serv->task_worker_num > %d, Too many processes, the system will be slow", SW_CPU_NUM * SW_MAX_WORKER_NCPU);
Expand Down
7 changes: 3 additions & 4 deletions swoole.c
Expand Up @@ -1412,11 +1412,10 @@ static PHP_FUNCTION(swoole_last_error)

PHP_FUNCTION(swoole_cpu_num)
{
long cpu_num = 1;
cpu_num = sysconf(_SC_NPROCESSORS_CONF);
if (cpu_num < 1)
static long cpu_num = 0;
if (cpu_num == 0)
{
cpu_num = 1;
cpu_num = MAX(1, sysconf(_SC_NPROCESSORS_CONF));
}
RETURN_LONG(cpu_num);
}
Expand Down
2 changes: 1 addition & 1 deletion swoole_async.cc
Expand Up @@ -905,7 +905,7 @@ PHP_FUNCTION(swoole_async_set)
if (php_swoole_array_get_value(vht, "display_errors", v))
{
convert_to_boolean(v);
SWOOLE_G(display_errors) = 0;
SWOOLE_G(display_errors) = Z_BVAL_P(v);
}
if (php_swoole_array_get_value(vht, "socket_dontwait", v))
{
Expand Down

0 comments on commit cb71f50

Please sign in to comment.