| 910 | } |
| 911 | |
| 912 | bool MtFrame::KqueueSchedule(KqObjList* fdlist, KqueuerObj* fd, int timeout) |
| 913 | { |
| 914 | MicroThread* thread = GetActiveThread(); |
| 915 | if (NULL == thread) |
| 916 | { |
| 917 | MTLOG_ERROR("active thread null, epoll schedule failed"); |
| 918 | return false; |
| 919 | } |
| 920 | |
| 921 | thread->ClearAllFd(); |
| 922 | if (fdlist) |
| 923 | { |
| 924 | thread->AddFdList(fdlist); |
| 925 | } |
| 926 | if (fd) |
| 927 | { |
| 928 | thread->AddFd(fd); |
| 929 | } |
| 930 | |
| 931 | thread->SetWakeupTime(timeout + this->GetLastClock()); |
| 932 | if (!this->KqueueAdd(thread->GetFdSet())) |
| 933 | { |
| 934 | MTLOG_ERROR("epoll add failed, errno: %d", errno); |
| 935 | return false; |
| 936 | } |
| 937 | this->InsertIoWait(thread); |
| 938 | thread->SwitchContext(); |
| 939 | |
| 940 | int rcvnum = 0; |
| 941 | KqObjList& rcvfds = thread->GetFdSet(); |
| 942 | KqueuerObj* fdata = NULL; |
| 943 | TAILQ_FOREACH(fdata, &rcvfds, _entry) |
| 944 | { |
| 945 | if (fdata->GetRcvEvents() != 0) |
| 946 | { |
| 947 | rcvnum++; |
| 948 | } |
| 949 | } |
| 950 | this->KqueueDel(rcvfds); |
| 951 | |
| 952 | if (rcvnum == 0) |
| 953 | { |
| 954 | errno = ETIME; |
| 955 | return false; |
| 956 | } |
| 957 | |
| 958 | return true; |
| 959 | } |
| 960 | |
| 961 | int MtFrame::recvfrom(int fd, void *buf, int len, int flags, struct sockaddr *from, socklen_t *fromlen, int timeout) |
| 962 | { |
no test coverage detected