149 |
|
|
150 |
$sock->send( "Set-Cookie: ID=" . $state->{ID} . "; path=/\r\n" ) if ( $state->{ID} ); |
$sock->send( "Set-Cookie: ID=" . $state->{ID} . "; path=/\r\n" ) if ( $state->{ID} ); |
151 |
|
|
152 |
|
my $uid = $self->store->ID_to_uid( $state->{ID}, $state ); |
153 |
|
|
154 |
my $queue = CWMP::Queue->new({ |
my $queue = CWMP::Queue->new({ |
155 |
id => $self->store->ID_to_uid( $state->{ID}, $state ), |
id => $uid, |
156 |
debug => $self->debug, |
debug => $self->debug, |
157 |
}); |
}); |
158 |
my $job; |
my $job; |
163 |
} elsif ( $job = $queue->dequeue ) { |
} elsif ( $job = $queue->dequeue ) { |
164 |
$xml = $self->dispatch( $job->dispatch ); |
$xml = $self->dispatch( $job->dispatch ); |
165 |
} elsif ( $size == 0 ) { |
} elsif ( $size == 0 ) { |
166 |
warn ">>> no more queued commands, closing connection\n"; |
warn ">>> no more queued commands, closing connection to $uid\n"; |
167 |
return 0; |
return 0; |
168 |
} else { |
} else { |
169 |
warn ">>> empty response\n"; |
warn ">>> empty response to $uid\n"; |
170 |
$state->{NoMoreRequests} = 1; |
$state->{NoMoreRequests} = 1; |
171 |
$xml = $self->dispatch( 'xml', sub {} ); |
$xml = $self->dispatch( 'xml', sub {} ); |
172 |
} |
} |
174 |
$sock->send( "Content-Length: " . length( $xml ) . "\r\n\r\n" ); |
$sock->send( "Content-Length: " . length( $xml ) . "\r\n\r\n" ); |
175 |
$sock->send( $xml ) or die "can't send response"; |
$sock->send( $xml ) or die "can't send response"; |
176 |
|
|
177 |
warn ">>>> " . $sock->peerhost . " [" . localtime() . "] sent ", length( $xml )," bytes\n"; |
warn ">>>> " . $sock->peerhost . " [" . localtime() . "] sent ", length( $xml )," bytes to $uid\n"; |
178 |
|
|
179 |
$job->finish if $job; |
$job->finish if $job; |
180 |
warn "### request over\n" if $self->debug; |
warn "### request over for $uid\n" if $self->debug; |
181 |
|
|
182 |
return 1; # next request |
return 1; # next request |
183 |
}; |
}; |