Skip to content

Instantly share code, notes, and snippets.

@libc
Created December 16, 2009 05:52
Show Gist options
  • Save libc/257628 to your computer and use it in GitHub Desktop.
Save libc/257628 to your computer and use it in GitHub Desktop.
diff --git a/ext/ed.cpp b/ext/ed.cpp
index 19fc4d4..c8b4307 100644
--- a/ext/ed.cpp
+++ b/ext/ed.cpp
@@ -1538,6 +1538,8 @@ void DatagramDescriptor::Write()
assert (sd != INVALID_SOCKET);
LastActivity = MyEventMachine->GetCurrentTime();
+ cerr << "DatagramDescriptor::Write(); sd " << sd << " OutboundPages.size() " << OutboundPages.size() << endl;
+
assert (OutboundPages.size() > 0);
// Send out up to 10 packets, then cycle the machine.
@@ -1573,8 +1575,10 @@ void DatagramDescriptor::Write()
MyEventMachine->Modify (this);
#endif
#ifdef HAVE_KQUEUE
- if (SelectForWrite())
+ if (SelectForWrite()) {
+ cerr << "Arming kqueue sd " << sd << " OutboundPages.size() " << OutboundPages.size() << endl;
MyEventMachine->ArmKqueueWriter (this);
+ }
#endif
}
diff --git a/ext/em.cpp b/ext/em.cpp
index 495ac7c..89934a6 100644
--- a/ext/em.cpp
+++ b/ext/em.cpp
@@ -605,6 +605,9 @@ bool EventMachine_t::_RunKqueueOnce()
k = kevent (kqfd, NULL, 0, Karray, MaxEvents, &ts);
#endif
+
+ cerr << "kqueue tick" << endl;
+
struct kevent *ke = Karray;
while (k > 0) {
switch (ke->filter)
@@ -625,6 +628,8 @@ bool EventMachine_t::_RunKqueueOnce()
if (ed->IsWatchOnly() && ed->GetSocket() == INVALID_SOCKET)
break;
+ cerr << "kqueue sd " << ed->GetSocket() << " filter: " << (ke->filter == EVFILT_READ ? "read" : "write") << endl;
+
if (ke->filter == EVFILT_READ)
ed->Read();
else if (ke->filter == EVFILT_WRITE)
@@ -639,6 +644,7 @@ bool EventMachine_t::_RunKqueueOnce()
++ke;
}
+ cerr << "kqueue tick end" << endl;
// TODO, replace this with rb_thread_blocking_region for 1.9 builds.
#ifdef BUILD_FOR_RUBY
if (!rb_thread_alone()) {
@@ -1649,6 +1655,7 @@ void EventMachine_t::ArmKqueueWriter (EventableDescriptor *ed)
if (bKqueue) {
if (!ed)
throw std::runtime_error ("added bad descriptor");
+ cerr << "arming kqueue writer " << ed->GetSocket() << endl;
struct kevent k;
EV_SET (&k, ed->GetSocket(), EVFILT_WRITE, EV_ADD | EV_ONESHOT, 0, 0, ed);
int t = kevent (kqfd, &k, 1, NULL, 0, NULL);
arming kqueue writer 6
kqueue tick
kqueue sd 3 filter: read
arming kqueue writer 6
kqueue sd 6 filter: write
DatagramDescriptor::Write(); sd 6 OutboundPages.size() 2
kqueue tick end
kqueue tick
kqueue sd 6 filter: write
DatagramDescriptor::Write(); sd 6 OutboundPages.size() 0
Assertion failed: (OutboundPages.size() > 0), function Write, file ed.cpp, line 1543.
Abort trap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment