Skip to content

Commit d0b9d54

Browse files
committed
Remove the socket_dontwait option from the async module, as it is an obsolete feature.
1 parent d64826a commit d0b9d54

File tree

5 files changed

+12
-21
lines changed

5 files changed

+12
-21
lines changed

ext-src/swoole_async_coro.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ PHP_FUNCTION(swoole_async_set) {
116116
v = SW_MAX(1, SW_MIN(v, UINT32_MAX));
117117
SwooleG.aio_worker_num = v;
118118
}
119-
if (php_swoole_array_get_value(vht, "socket_dontwait", ztmp)) {
120-
SwooleG.socket_dontwait = zval_is_true(ztmp);
121-
}
122119
if (php_swoole_array_get_value(vht, "dns_lookup_random", ztmp)) {
123120
SwooleG.dns_lookup_random = zval_is_true(ztmp);
124121
}

include/swoole.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -670,11 +670,11 @@ struct EventData {
670670
char data[SW_IPC_BUFFER_SIZE];
671671

672672
uint32_t size() {
673-
return sizeof(info) + len();
673+
return sizeof(info) + len();
674674
}
675675

676676
uint32_t len() {
677-
return info.len;
677+
return info.len;
678678
}
679679
};
680680

@@ -746,12 +746,11 @@ struct Global {
746746
uchar running : 1;
747747
uchar wait_signal : 1;
748748
uchar enable_signalfd : 1;
749-
uchar socket_dontwait : 1;
750749
uchar dns_lookup_random : 1;
751750
uchar use_async_resolver : 1;
752751
uchar use_name_resolver : 1;
753752
uchar enable_coroutine : 1;
754-
uchar print_backtrace_on_error: 1;
753+
uchar print_backtrace_on_error : 1;
755754

756755
uint8_t process_type;
757756
uint32_t process_id;
@@ -812,7 +811,7 @@ void hook_call(void **hooks, int type, void *arg);
812811
double microtime(void);
813812
} // namespace swoole
814813

815-
extern swoole::Global SwooleG; // Local Global Variable
814+
extern swoole::Global SwooleG; // Local Global Variable
816815
extern thread_local swoole::ThreadGlobal SwooleTG; // Thread Global Variable
817816

818817
#define SW_CPU_NUM (SwooleG.cpu_num)

include/swoole_socket.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ struct Socket {
190190
uchar dtls : 1;
191191
#endif
192192
#endif
193-
uchar dontwait : 1;
194193
uchar close_wait : 1;
195194
uchar send_wait : 1;
196195
uchar tcp_nopush : 1;

src/network/client.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ Client::Client(SocketType _type, bool _async) : async(_async) {
8686
connect = Client_tcp_connect_async;
8787
send = Client_tcp_send_async;
8888
sendfile = Client_tcp_sendfile_async;
89-
socket->dontwait = SwooleG.socket_dontwait;
9089
} else {
9190
connect = Client_tcp_connect_sync;
9291
send = Client_tcp_send_sync;

src/reactor/base.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ ssize_t Reactor::write_func(Reactor *reactor,
218218
const std::function<void(Buffer *buffer)> &append_fn) {
219219
ssize_t retval;
220220
Buffer *buffer = socket->out_buffer;
221-
int fd = socket->fd;
222221

223222
if (socket->buffer_size == 0) {
224223
socket->set_memory_buffer_size(Socket::default_buffer_size);
@@ -263,6 +262,11 @@ ssize_t Reactor::write_func(Reactor *reactor,
263262
if (!socket->isset_writable_event()) {
264263
reactor->add_write_event(socket);
265264
}
265+
/**
266+
* Part of the data has been successfully written to the kernel's socket buffer,
267+
* and at this point, writing to the memory queue is permitted under any circumstances.
268+
* Ensure that the async write operation either succeeds completely or fails entirely.
269+
*/
266270
goto _append_buffer;
267271
} else if (errno == EINTR) {
268272
goto _do_send;
@@ -271,18 +275,11 @@ ssize_t Reactor::write_func(Reactor *reactor,
271275
return SW_ERR;
272276
}
273277
} else {
274-
_append_buffer:
275278
if (buffer->length() > socket->buffer_size) {
276-
if (socket->dontwait) {
277-
swoole_set_last_error(SW_ERROR_OUTPUT_BUFFER_OVERFLOW);
278-
return SW_ERR;
279-
} else {
280-
swoole_error_log(
281-
SW_LOG_WARNING, SW_ERROR_OUTPUT_BUFFER_OVERFLOW, "socket#%d output buffer overflow", fd);
282-
sw_yield();
283-
socket->wait_event(SW_SOCKET_OVERFLOW_WAIT, SW_EVENT_WRITE);
284-
}
279+
swoole_set_last_error(SW_ERROR_OUTPUT_BUFFER_OVERFLOW);
280+
return SW_ERR;
285281
}
282+
_append_buffer:
286283
append_fn(buffer);
287284
}
288285
return __len;

0 commit comments

Comments
 (0)