mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-28 15:04:51 +00:00
SubProcess.pm: buffer reads, messages amended
git-svn-id: https://svn.fhem.de/fhem/trunk@14334 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
149bbb8dd7
commit
f617a5408b
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- change: SubProcess.pm: buffer reads, messages amended
|
||||||
- feature: 98_alarmclock: New feature PresenceDevice
|
- feature: 98_alarmclock: New feature PresenceDevice
|
||||||
- change: 49_SSCam: version 2.2.1, last record playback possible as iFrame,
|
- change: 49_SSCam: version 2.2.1, last record playback possible as iFrame,
|
||||||
deviceoverview available,
|
deviceoverview available,
|
||||||
|
@ -125,7 +125,7 @@ sub wait() {
|
|||||||
if(defined($pid)) {
|
if(defined($pid)) {
|
||||||
main::Log3 $pid, 5, "Waiting for SubProcess $pid...";
|
main::Log3 $pid, 5, "Waiting for SubProcess $pid...";
|
||||||
waitpid($pid, 0);
|
waitpid($pid, 0);
|
||||||
main::Log3 $pid, 5, "SubProcess $pid terminated...";
|
main::Log3 $pid, 5, "SubProcess $pid terminated.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,8 +176,6 @@ sub parent() {
|
|||||||
|
|
||||||
# this is a helper function for reading
|
# this is a helper function for reading
|
||||||
# returns 1 datagram or undef on error
|
# returns 1 datagram or undef on error
|
||||||
# this version does not handle split transmissions that result in short datagrams
|
|
||||||
# Todo: buffer such datagrams
|
|
||||||
sub readFrom() {
|
sub readFrom() {
|
||||||
my ($self, $fh) = @_;
|
my ($self, $fh) = @_;
|
||||||
|
|
||||||
@ -210,14 +208,15 @@ sub readFrom() {
|
|||||||
|
|
||||||
# Read datagram
|
# Read datagram
|
||||||
my $size = unpack ('N', $header);
|
my $size = unpack ('N', $header);
|
||||||
my $bytes = sysread ($fh, $data, $size);
|
my $buffer;
|
||||||
if (!defined ($bytes)) {
|
while($size> 0) {
|
||||||
$self->{lasterror} = $!;
|
my $bytes = sysread ($fh, $buffer, $size);
|
||||||
return undef;
|
if (!defined ($bytes)) {
|
||||||
}
|
$self->{lasterror} = $!;
|
||||||
elsif ($bytes != $size) {
|
return undef;
|
||||||
$self->{lasterror} = "read: incomplete data";
|
}
|
||||||
return undef;
|
$data.= $buffer;
|
||||||
|
$size-= $bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@ -312,6 +311,7 @@ sub run() {
|
|||||||
# CHILD
|
# CHILD
|
||||||
|
|
||||||
# run
|
# run
|
||||||
|
main::Log3 undef, 5, "SubProcess $$ started.";
|
||||||
my $onRun= $self->{onRun};
|
my $onRun= $self->{onRun};
|
||||||
if(defined($onRun)) {
|
if(defined($onRun)) {
|
||||||
eval { &$onRun($self) };
|
eval { &$onRun($self) };
|
||||||
@ -325,7 +325,7 @@ sub run() {
|
|||||||
main::Log3 undef, 2, "SubProcess: onExit returned error: $@" if($@);
|
main::Log3 undef, 2, "SubProcess: onExit returned error: $@" if($@);
|
||||||
}
|
}
|
||||||
|
|
||||||
#close(PARENT);
|
main::Log3 undef, 5, "SubProcess $$ ended.";
|
||||||
POSIX::_exit(0);
|
POSIX::_exit(0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user