unix: turn field stream->blocking into a flag
Saves 4 bytes.
This commit is contained in:
parent
5fd2c406f1
commit
e71495c84a
@ -159,7 +159,6 @@ struct uv__io_s {
|
||||
int delayed_error; \
|
||||
uv_connection_cb connection_cb; \
|
||||
int accepted_fd; \
|
||||
int blocking;
|
||||
|
||||
|
||||
/* UV_TCP */
|
||||
|
||||
@ -84,17 +84,18 @@
|
||||
|
||||
/* flags */
|
||||
enum {
|
||||
UV_CLOSING = 0x01, /* uv_close() called but not finished. */
|
||||
UV_CLOSED = 0x02, /* close(2) finished. */
|
||||
UV_CLOSING = 0x01, /* uv_close() called but not finished. */
|
||||
UV_CLOSED = 0x02, /* close(2) finished. */
|
||||
UV_STREAM_READING = 0x04, /* uv_read_start() called. */
|
||||
UV_STREAM_SHUTTING = 0x08, /* uv_shutdown() called but not complete. */
|
||||
UV_STREAM_SHUT = 0x10, /* Write side closed. */
|
||||
UV_STREAM_READABLE = 0x20, /* The stream is readable */
|
||||
UV_STREAM_WRITABLE = 0x40, /* The stream is writable */
|
||||
UV_TCP_NODELAY = 0x080, /* Disable Nagle. */
|
||||
UV_TCP_KEEPALIVE = 0x100, /* Turn on keep-alive. */
|
||||
UV_TIMER_REPEAT = 0x100,
|
||||
UV__PENDING = 0x800
|
||||
UV_STREAM_BLOCKING = 0x80, /* Synchronous writes. */
|
||||
UV_TCP_NODELAY = 0x100, /* Disable Nagle. */
|
||||
UV_TCP_KEEPALIVE = 0x200, /* Turn on keep-alive. */
|
||||
UV_TIMER_REPEAT = 0x100,
|
||||
UV__PENDING = 0x800
|
||||
};
|
||||
|
||||
inline static int uv__has_pending_handles(const uv_loop_t* loop) {
|
||||
|
||||
@ -67,7 +67,6 @@ void uv__stream_init(uv_loop_t* loop,
|
||||
stream->accepted_fd = -1;
|
||||
stream->fd = -1;
|
||||
stream->delayed_error = 0;
|
||||
stream->blocking = 0;
|
||||
ngx_queue_init(&stream->write_queue);
|
||||
ngx_queue_init(&stream->write_completed_queue);
|
||||
stream->write_queue_size = 0;
|
||||
@ -444,7 +443,7 @@ start:
|
||||
stream->write_queue_size -= uv__write_req_size(req);
|
||||
uv__write_req_finish(req);
|
||||
return;
|
||||
} else if (stream->blocking) {
|
||||
} else if (stream->flags & UV_STREAM_BLOCKING) {
|
||||
/* If this is a blocking stream, try again. */
|
||||
goto start;
|
||||
}
|
||||
@ -465,7 +464,7 @@ start:
|
||||
n = 0;
|
||||
|
||||
/* There is more to write. */
|
||||
if (stream->blocking) {
|
||||
if (stream->flags & UV_STREAM_BLOCKING) {
|
||||
/*
|
||||
* If we're blocking then we should not be enabling the write
|
||||
* watcher - instead we need to try again.
|
||||
@ -501,7 +500,7 @@ start:
|
||||
assert(n == 0 || n == -1);
|
||||
|
||||
/* Only non-blocking streams should use the write_watcher. */
|
||||
assert(!stream->blocking);
|
||||
assert(!(stream->flags & UV_STREAM_BLOCKING));
|
||||
|
||||
/* We're not done. */
|
||||
uv__io_start(stream->loop, &stream->write_watcher);
|
||||
@ -931,7 +930,7 @@ int uv_write2(uv_write_t* req, uv_stream_t* stream, uv_buf_t bufs[], int bufcnt,
|
||||
* if this assert fires then somehow the blocking stream isn't being
|
||||
* sufficently flushed in uv__write.
|
||||
*/
|
||||
assert(!stream->blocking);
|
||||
assert(!(stream->flags & UV_STREAM_BLOCKING));
|
||||
|
||||
uv__io_start(stream->loop, &stream->write_watcher);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) {
|
||||
} else {
|
||||
/* Note: writable tty we set to blocking mode. */
|
||||
uv__stream_open((uv_stream_t*)tty, fd, UV_STREAM_WRITABLE);
|
||||
tty->blocking = 1;
|
||||
tty->flags |= UV_STREAM_BLOCKING;
|
||||
}
|
||||
|
||||
loop->counters.tty_init++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user