Changeset 367
- Timestamp:
- 06/06/07 23:45:10 (2 years ago)
- Files:
-
- version_0/ext/ed.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
version_0/ext/ed.cpp
r337 r367 76 76 throw std::runtime_error ("bad eventable descriptor"); 77 77 CreatedAt = gCurrentLoopTime; 78 79 #ifdef HAVE_EPOLL 80 EpollEvent.data.ptr = this; 81 #endif 78 82 } 79 83 … … 152 156 ******************************************/ 153 157 154 ConnectionDescriptor::ConnectionDescriptor ( int sd):158 ConnectionDescriptor::ConnectionDescriptor (EventMachine_t *em, int sd): 155 159 EventableDescriptor (sd), 156 160 bConnectPending (false), … … 162 166 bIsServer (false), 163 167 LastIo (gCurrentLoopTime), 164 InactivityTimeout (0) 165 { 168 InactivityTimeout (0), 169 MyEventMachine (em) 170 { 171 #ifdef HAVE_EPOLL 172 EpollEvent.events = EPOLLOUT; 173 #endif 166 174 } 167 175 … … 275 283 OutboundPages.push_back (OutboundPage (buffer, length)); 276 284 OutboundDataSize += length; 285 #ifdef HAVE_EPOLL 286 EpollEvent.events = (EPOLLIN | EPOLLOUT); 287 assert (MyEventMachine); 288 MyEventMachine->_ModifyEpollEvent (this); 289 #endif 277 290 return length; 278 291 } … … 480 493 (*EventCallback)(GetBinding().c_str(), EM_CONNECTION_COMPLETED, "", 0); 481 494 bConnectPending = false; 495 #ifdef HAVE_EPOLL 496 // The callback may have scheduled outbound data. 497 EpollEvent.events = EPOLLIN | (SelectForWrite() ? EPOLLOUT : 0); 498 #endif 482 499 } 483 500 else … … 546 563 OutboundPages.push_front (OutboundPage (buffer, len)); 547 564 } 565 566 #ifdef HAVE_EPOLL 567 EpollEvent.events = (EPOLLIN | (SelectForWrite() ? EPOLLOUT : 0)); 568 assert (MyEventMachine); 569 MyEventMachine->_ModifyEpollEvent (this); 570 #endif 548 571 } 549 572 else { … … 673 696 674 697 AcceptorDescriptor::AcceptorDescriptor (EventMachine_t *parent_em, int sd): 675 EventableDescriptor (sd), 676 MyEventMachine (parent_em) 677 { 678 /* This is really bad and ugly. Change someday if possible. 679 * We have to know about an event-machine (probably the one that owns us), 680 * so we can pass newly-created connections to it. 681 */ 682 683 if (!MyEventMachine) 684 throw std::runtime_error ("bad event-machine passed to acceptor"); 698 EventableDescriptor (sd), 699 MyEventMachine (parent_em) 700 { 701 /* This is really bad and ugly. Change someday if possible. 702 * We have to know about an event-machine (probably the one that owns us), 703 * so we can pass newly-created connections to it. 704 */ 705 706 if (!MyEventMachine) 707 throw std::runtime_error ("bad event-machine passed to acceptor"); 708 709 #ifdef HAVE_EPOLL 710 EpollEvent.events = EPOLLIN; 711 #endif 685 712 } 686 713 … … 745 772 746 773 747 ConnectionDescriptor *cd = new ConnectionDescriptor ( sd);774 ConnectionDescriptor *cd = new ConnectionDescriptor (MyEventMachine, sd); 748 775 if (!cd) 749 776 throw std::runtime_error ("no newly accepted connection"); … … 752 779 (*EventCallback) (GetBinding().c_str(), EM_CONNECTION_ACCEPTED, cd->GetBinding().c_str(), cd->GetBinding().size()); 753 780 } 781 #ifdef HAVE_EPOLL 782 cd->GetEpollEvent()->events = EPOLLIN | (cd->SelectForWrite() ? EPOLLOUT : 0); 783 #endif 754 784 assert (MyEventMachine); 755 785 MyEventMachine->Add (cd);
