Skip to content

Commit b9d67f1

Browse files
committed
Use new ev_io_modify method from libev.
1 parent ec4da27 commit b9d67f1

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

apib/apib_io_basic.cc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void ConnectionState::completeShutdown(struct ev_loop* loop, ev_io* w,
9292
io_Verbose(c, "Close needs read\n");
9393
if (c->backwardsIo_) {
9494
ev_io_stop(loop, &(c->io_));
95-
ev_io_set(&(c->io_), c->socket_->fd(), EV_READ);
95+
ev_io_modify(&(c->io_), EV_READ);
9696
c->backwardsIo_ = false;
9797
ev_io_start(loop, &(c->io_));
9898
}
@@ -101,7 +101,7 @@ void ConnectionState::completeShutdown(struct ev_loop* loop, ev_io* w,
101101
io_Verbose(c, "Close needs write\n");
102102
if (!c->backwardsIo_) {
103103
ev_io_stop(loop, &(c->io_));
104-
ev_io_set(&(c->io_), c->socket_->fd(), EV_WRITE);
104+
ev_io_modify(&(c->io_), EV_WRITE);
105105
c->backwardsIo_ = true;
106106
ev_io_start(loop, &(c->io_));
107107
}
@@ -128,16 +128,14 @@ void ConnectionState::Close() {
128128
break;
129129
case NEED_READ:
130130
io_Verbose(this, "Close needs read\n");
131-
ev_init(&io_, completeShutdown);
132-
ev_io_set(&io_, socket_->fd(), EV_READ);
131+
ev_io_init(&io_, completeShutdown, socket_->fd(), EV_READ);
133132
backwardsIo_ = false;
134133
io_.data = this;
135134
ev_io_start(t_->loop(), &io_);
136135
break;
137136
case NEED_WRITE:
138137
io_Verbose(this, "Close needs write\n");
139-
ev_init(&io_, completeShutdown);
140-
ev_io_set(&io_, socket_->fd(), EV_WRITE);
138+
ev_io_init(&io_, completeShutdown, socket_->fd(), EV_WRITE);
141139
backwardsIo_ = true;
142140
io_.data = this;
143141
ev_io_start(t_->loop(), &io_);
@@ -215,8 +213,7 @@ void ConnectionState::writeReady(struct ev_loop* loop, ev_io* w, int revents) {
215213

216214
// Set up libev to asychronously write from writeBuf
217215
void ConnectionState::SendWrite() {
218-
ev_init(&io_, writeReady);
219-
ev_io_set(&io_, socket_->fd(), EV_WRITE);
216+
ev_io_init(&io_, writeReady, socket_->fd(), EV_WRITE);
220217
backwardsIo_ = false;
221218
io_.data = this;
222219
ev_io_start(t_->loop(), &io_);
@@ -296,7 +293,7 @@ int ConnectionState::singleRead(struct ev_loop* loop, ev_io* w, int revents) {
296293
io_Verbose(this, "Restoring I/O direction\n");
297294
backwardsIo_ = 0;
298295
ev_io_stop(loop, &io_);
299-
ev_io_set(&io_, socket_->fd(), EV_READ);
296+
ev_io_modify(&io_, EV_READ);
300297
ev_io_start(loop, &io_);
301298
}
302299
return 0;
@@ -308,7 +305,7 @@ int ConnectionState::singleRead(struct ev_loop* loop, ev_io* w, int revents) {
308305
io_Verbose(this, "Switching I/O direction\n");
309306
backwardsIo_ = 1;
310307
ev_io_stop(loop, &io_);
311-
ev_io_set(&io_, socket_->fd(), EV_WRITE);
308+
ev_io_modify(&io_, EV_WRITE);
312309
ev_io_start(loop, &io_);
313310
}
314311
return 0;
@@ -327,8 +324,7 @@ void ConnectionState::readReady(struct ev_loop* loop, ev_io* w, int revents) {
327324

328325
// Set up libev to asynchronously read to readBuf
329326
void ConnectionState::SendRead() {
330-
ev_init(&io_, readReady);
331-
ev_io_set(&io_, socket_->fd(), EV_READ);
327+
ev_io_init(&io_, readReady, socket_->fd(), EV_READ);
332328
io_.data = this;
333329
backwardsIo_ = 0;
334330
ev_io_start(t_->loop(), &io_);

0 commit comments

Comments
 (0)