Permalink
Browse files

speed up kernel; fix bad filehandle in test 4

  • Loading branch information...
rcaputo committed Dec 3, 2000
1 parent c5f1cec commit 761b0d6dae4952afc605e2729689c100567558ab
Showing with 187 additions and 104 deletions.
  1. +20 −2 Changes
  2. +5 −0 lib/POE.pm
  3. +36 −17 lib/POE/Kernel.pm
  4. +3 −1 lib/POE/Wheel/ReadWrite.pm
  5. +116 −78 lib/POE/Wheel/SocketFactory.pm
  6. +5 −5 tests/04_selects.t
  7. +2 −1 tests/10_wheels_tcp.t
View
22 Changes
@@ -29,10 +29,28 @@ Version numbers have four fields: X.YYZZAA
0.1201 2000.??.??
-----------------
-Move POE::Kernel's data structures out of $self and into lexicals.
-Keep references to the structures in $self so Data::Dumper can dump
+Moved POE::Kernel's data structures out of $self and into lexicals.
+Kept references to the structures in $self so Data::Dumper can dump
the whole shebang at once.
+Mike Fletcher found a bug in the TRACE_SELECT code that kept it from
+showing the input bits for read select. D'oh.
+
+Fixed Wheel::SocketFactory to prevent it from clobbering another
+wheel's selects upon destruction. This fixes the longstanding "wheel
+swap" bug listed in the FAQ (on the web site). Replaced its blessed
+hashref with a blessed listref, so it should be a wee bit faster too.
+
+Fixed t/10_wheels_tcp.t to stop working around the longstanding "wheel
+swap" bug. This exercises the previous SocketFactory fix.
+
+Dave Paris found a recurring bug in t/04_selects.t. It was opening
+40-some filehandles at once, which consistently runs out of available
+handles in some situations. I cut the number of handles approximately
+in half, so it should work better everywhere. This has the
+unfortunate side-effect of cutting 10 tests from the suite. We're
+still not sure how the environment is using extra handles, though.
+
0.12 2000.11.19
---------------
View
@@ -1019,6 +1019,11 @@ was his idea. Versions 0.06 and later should scale to higher loads
because of his work. His intangible contributions include lots of
testing and feedback, some of which is visible in the Changes file.
+And I do mean *lots* of testing. I go and announce a new development
+version, and he's, like, "All tests passed!" just a few minutes later.
+If that wasn't enough, he investigates any bugs that turn up, and
+often fixes them. The man's scarily good.
+
=item *
Dieter Pearcey is <dieter@bullfrog.perlhacker.org>. He goes by
View
@@ -251,7 +251,12 @@ macro test_for_idle_poe_kernel {
"| States : ", scalar(@kr_states), "\n",
"| Alarms : ", scalar(@kr_alarms), "\n",
"| Files : ", scalar(keys(%kr_handles)), "\n",
- "| `--> : ", join(', ', keys(%kr_handles)), "\n",
+ "| `--> : ", join( ', ',
+ sort { $a <=> $b }
+ map { fileno($_->[HND_HANDLE]) }
+ values(%kr_handles)
+ ),
+ "\n",
"| Extra : ", $self->[KR_EXTRA_REFS], "\n",
"`---------------------------\n",
" ..."
@@ -1332,7 +1337,7 @@ sub run {
if (TRACE_SELECT) { # include
warn ",----- SELECT BITS IN -----\n";
- warn "| READ : ", unpack('b*', $kr_vectors[VEC_WR]), "\n";
+ warn "| READ : ", unpack('b*', $kr_vectors[VEC_RD]), "\n";
warn "| WRITE : ", unpack('b*', $kr_vectors[VEC_WR]), "\n";
warn "| EXPEDITE: ", unpack('b*', $kr_vectors[VEC_EX]), "\n";
warn "`--------------------------\n";
@@ -1416,7 +1421,14 @@ sub run {
if (TRACE_SELECT) { # include
if (@selects) {
- warn "found pending selects: @selects\n";
+ warn( "found pending selects: ",
+ join( ', ',
+ sort { $a <=> $b }
+ map { fileno($_->[HND_HANDLE]) }
+ @selects
+ ),
+ "\n"
+ );
}
} # include
@@ -1478,14 +1490,14 @@ sub run {
while (@kr_states) {
if (TRACE_QUEUE) { # include
-
- my $event = $kr_states[0];
- warn( sprintf('now(%.2f) ', $now - $^T) .
- sprintf('sched_time(%.2f) ', $event->[ST_TIME] - $^T) .
- "seq($event->[ST_SEQ]) " .
- "name($event->[ST_NAME])\n"
- );
-
+ { # scope to limit this use of my $event
+ my $event = $kr_states[0];
+ warn( sprintf('now(%.2f) ', $now - $^T) .
+ sprintf('sched_time(%.2f) ', $event->[ST_TIME] - $^T) .
+ "seq($event->[ST_SEQ]) " .
+ "name($event->[ST_NAME])\n"
+ );
+ }
} # include
# Pull an event off the queue, and dispatch it.
@@ -2459,14 +2471,19 @@ sub _internal_select {
my ($self, $session, $handle, $state, $select_index) = @_;
my $fileno = fileno($handle);
- # Register a select state.
+ # If a state is specify register it. This may be a new handle, or
+ # it may be replacing an existing select with a new destination.
+
if ($state) {
+
+ # The handle is unknown. Register it anew.
+
unless (exists $kr_handles{$handle}) {
$kr_handles{$handle} =
- [ $handle, # HND_HANDLE
- 0, # HND_REFCOUNT
- [ 0, 0, 0 ], # HND_VECCOUNT (VEC_RD, VEC_WR, VEC_EX)
- [ { }, { }, { } ], # HND_SESSIONS (VEC_RD, VEC_WR, VEC_EX)
+ [ $handle, # HND_HANDLE
+ 0, # HND_REFCOUNT
+ [ 0, 0, 0 ], # HND_VECCOUNT (VEC_RD, VEC_WR, VEC_EX)
+ [ { }, { }, { } ], # HND_SESSIONS (VEC_RD, VEC_WR, VEC_EX)
];
# For DOSISH systems like OS/2
@@ -2494,6 +2511,8 @@ sub _internal_select {
# This depends heavily on socket.ph, or somesuch. It's
# extremely unportable. I can't begin to figure out a way to
# make this work everywhere, so I'm not even going to try.
+ # Besides, it should be some sort of option. Feel free to set
+ # it before calling a select_* function.
#
# setsockopt($handle, SOL_SOCKET, &TCP_NODELAY, 1)
# or die "Couldn't disable Nagle's algorithm: $!\a\n";
@@ -2502,7 +2521,7 @@ sub _internal_select {
select((select($handle), $| = 1)[0]);
}
- # KR_HANDLES
+ # Cache the handle. Save a repeated hash lookup.
my $kr_handle = $kr_handles{$handle};
# If this session hasn't already been watching the filehandle,
@@ -328,7 +328,9 @@ sub event {
sub DESTROY {
my $self = shift;
- # remove tentacles from our owner
+
+ # Turn off the select. This is a problem if a wheel is being
+ # swapped, since it will turn off selects for the other wheel.
$poe_kernel->select($self->[HANDLE_INPUT]);
if ($self->[STATE_READ]) {
Oops, something went wrong.

0 comments on commit 761b0d6

Please sign in to comment.