| 495 | } |
| 496 | |
| 497 | int KqueuerObj::KqueueCtlAdd(void* args) |
| 498 | { |
| 499 | MtFrame* frame = MtFrame::Instance(); |
| 500 | KqFdRef* fd_ref = (KqFdRef*)args; |
| 501 | kqueue_assert(fd_ref != NULL); |
| 502 | |
| 503 | int osfd = this->GetOsfd(); |
| 504 | int new_events = this->GetEvents(); |
| 505 | |
| 506 | // Notify object needs updating |
| 507 | KqueuerObj* old_obj = fd_ref->GetNotifyObj(); |
| 508 | if ((old_obj != NULL) && (old_obj != this)) |
| 509 | { |
| 510 | MTLOG_ERROR("kqfd ref conflict, fd: %d, old: %p, now: %p", osfd, old_obj, this); |
| 511 | return -1; |
| 512 | } |
| 513 | fd_ref->SetNotifyObj(this); |
| 514 | |
| 515 | if (!frame->KqueueCtrlAdd(osfd, new_events)) |
| 516 | { |
| 517 | MTLOG_ERROR("kqfd ref add failed, log"); |
| 518 | fd_ref->SetNotifyObj(old_obj); |
| 519 | return -2; |
| 520 | } |
| 521 | |
| 522 | return 0; |
| 523 | } |
| 524 | |
| 525 | int KqueuerObj::KqueueCtlDel(void* args) |
| 526 | { |
no test coverage detected