@@ -883,7 +883,7 @@ static PHP_METHOD(swoole_mysql_coro, recv)
883
883
RETURN_FALSE ;
884
884
}
885
885
886
- client -> defer_yield = 1 ;
886
+ client -> suspending = 1 ;
887
887
client -> cid = get_current_cid ();
888
888
php_context * context = swoole_get_property (getThis (), 0 );
889
889
coro_save (context );
@@ -937,19 +937,24 @@ static PHP_METHOD(swoole_mysql_coro, prepare)
937
937
}
938
938
RETURN_FALSE ;
939
939
}
940
- else
940
+
941
+ if (client -> defer )
941
942
{
942
- client -> state = SW_MYSQL_STATE_READ_START ;
943
- php_context * context = swoole_get_property ( getThis (), 0 ) ;
944
- double timeout = client -> connector . timeout ;
945
- if ( timeout > 0 )
946
- {
947
- client -> timer = SwooleG . timer . add ( & SwooleG . timer , ( int ) ( timeout * 1000 ) , 0 , context , swoole_mysql_coro_onTimeout );
948
- }
949
- client -> cid = get_current_cid ();
950
- coro_save ( context );
951
- coro_yield ( );
943
+ client -> iowait = SW_MYSQL_CORO_STATUS_WAIT ;
944
+ RETURN_TRUE ;
945
+ }
946
+
947
+ client -> state = SW_MYSQL_STATE_READ_START ;
948
+ php_context * context = swoole_get_property ( getThis () , 0 );
949
+ double timeout = client -> connector . timeout ;
950
+ if ( timeout > 0 )
951
+ {
952
+ client -> timer = SwooleG . timer . add ( & SwooleG . timer , ( int ) ( timeout * 1000 ), 0 , context , swoole_mysql_coro_onTimeout );
952
953
}
954
+ client -> suspending = 1 ;
955
+ client -> cid = get_current_cid ();
956
+ coro_save (context );
957
+ coro_yield ();
953
958
}
954
959
955
960
static PHP_METHOD (swoole_mysql_coro_statement , execute )
@@ -994,7 +999,7 @@ static PHP_METHOD(swoole_mysql_coro_statement, execute)
994
999
client -> iowait = SW_MYSQL_CORO_STATUS_WAIT ;
995
1000
RETURN_TRUE ;
996
1001
}
997
- client -> defer_yield = 1 ;
1002
+ client -> suspending = 1 ;
998
1003
client -> cid = get_current_cid ();
999
1004
coro_save (context );
1000
1005
coro_yield ();
@@ -1128,12 +1133,12 @@ static int swoole_mysql_coro_onError(swReactor *reactor, swEvent *event)
1128
1133
zend_update_property_string (swoole_mysql_coro_class_entry_ptr , zobject , ZEND_STRL ("connect_error" ), "EPOLLERR/EPOLLHUP/EPOLLRDHUP happen!" TSRMLS_CC );
1129
1134
zend_update_property_long (swoole_mysql_coro_class_entry_ptr , zobject , ZEND_STRL ("connect_errno" ), 104 TSRMLS_CC );
1130
1135
ZVAL_BOOL (result , 0 );
1131
- if (client -> defer && !client -> defer_yield )
1136
+ if (client -> defer && !client -> suspending )
1132
1137
{
1133
1138
client -> result = result ;
1134
1139
return SW_OK ;
1135
1140
}
1136
- client -> defer_yield = 0 ;
1141
+ client -> suspending = 0 ;
1137
1142
client -> cid = 0 ;
1138
1143
php_context * sw_current_context = swoole_get_property (zobject , 0 );
1139
1144
int ret = coro_resume (sw_current_context , result , & retval );
@@ -1229,12 +1234,12 @@ static void swoole_mysql_coro_onTimeout(swTimer *timer, swTimer_node *tnode)
1229
1234
client -> state = SW_MYSQL_STATE_QUERY ;
1230
1235
swoole_mysql_coro_close (zobject );
1231
1236
1232
- if (client -> defer && !client -> defer_yield )
1237
+ if (client -> defer && !client -> suspending )
1233
1238
{
1234
1239
client -> result = result ;
1235
1240
return ;
1236
1241
}
1237
- client -> defer_yield = 0 ;
1242
+ client -> suspending = 0 ;
1238
1243
client -> cid = 0 ;
1239
1244
1240
1245
int ret = coro_resume (ctx , result , & retval );
@@ -1423,13 +1428,13 @@ static int swoole_mysql_coro_onRead(swReactor *reactor, swEvent *event)
1423
1428
1424
1429
SW_ALLOC_INIT_ZVAL (result );
1425
1430
ZVAL_BOOL (result , 0 );
1426
- if (client -> defer && !client -> defer_yield )
1431
+ if (client -> defer && !client -> suspending )
1427
1432
{
1428
1433
client -> iowait = SW_MYSQL_CORO_STATUS_DONE ;
1429
1434
client -> result = result ;
1430
1435
return SW_OK ;
1431
1436
}
1432
- client -> defer_yield = 0 ;
1437
+ client -> suspending = 0 ;
1433
1438
if (!client -> cid )
1434
1439
{
1435
1440
return SW_OK ;
@@ -1529,13 +1534,13 @@ static int swoole_mysql_coro_onRead(swReactor *reactor, swEvent *event)
1529
1534
1530
1535
swString_clear (client -> buffer );
1531
1536
bzero (& client -> response , sizeof (client -> response ));
1532
- if (client -> defer && !client -> defer_yield )
1537
+ if (client -> defer && !client -> suspending )
1533
1538
{
1534
1539
client -> iowait = SW_MYSQL_CORO_STATUS_DONE ;
1535
1540
client -> result = result ;
1536
1541
return SW_OK ;
1537
1542
}
1538
- client -> defer_yield = 0 ;
1543
+ client -> suspending = 0 ;
1539
1544
client -> iowait = SW_MYSQL_CORO_STATUS_READY ;
1540
1545
client -> cid = 0 ;
1541
1546
0 commit comments