bugfix: pause will disable write event

This commit is contained in:
Cloud Wu
2020-10-12 18:28:24 +08:00
parent 471c7d1101
commit f3acbe46df
4 changed files with 41 additions and 38 deletions

View File

@@ -56,9 +56,13 @@ sp_add(int kfd, int sock, void *ud) {
}
static void
sp_write(int kfd, int sock, void *ud, bool enable) {
sp_write(int kfd, int sock, void *ud, bool read_enable, bool write_enable) {
struct kevent ke;
EV_SET(&ke, sock, EVFILT_WRITE, enable ? EV_ENABLE : EV_DISABLE, 0, 0, ud);
EV_SET(&ke, sock, EVFILT_READ, read_enable ? EV_ENABLE : EV_DISABLE, 0, 0, ud);
if (kevent(kfd, &ke, 1, NULL, 0, NULL) == -1 || ke.flags & EV_ERROR) {
// todo: check error
}
EV_SET(&ke, sock, EVFILT_WRITE, write_enable ? EV_ENABLE : EV_DISABLE, 0, 0, ud);
if (kevent(kfd, &ke, 1, NULL, 0, NULL) == -1 || ke.flags & EV_ERROR) {
// todo: check error
}