|
From: Jamie C. <jca...@we...> - 2001-12-16 04:46:04
|
"Chip Kaye" <Chi...@op...> wrote ..
> The "Webmin Modules" documentation & example code indicate that there is
> no
> restriction on return value types from remote_foreign_call() but I am
> getting some odd behaviour when calling a remote function which returns
> an
> array as opposed to an array reference. The following code fragments
> illustrate what I am seeing:
>
> ---------------------------------------------------
> # The following two functions are in a module on host #1 :
>
> sub remote_function1()
> {
> # create an empty array.
> @empty_array1 = ();
>
> # return the empty array.
> return(@empty_array1);
> }
>
> sub remote_function2()
> {
> # create an empty array.
> @empty_array2 = ();
>
> # return a REFERENCE to the empty array.
> return(\@empty_array2);}
> }
>
> -------------------------------------------------
> # The following function is in a module on host #2 and calls the
> # two remote functions on host #1:
>
> sub sandbox()
> {
> @array1 = &remote_foreign_call(some_server, some_module, remote_function1);
> $length_array1 = scalar(@array1);
>
> $ref_array2 = &remote_foreign_call(some_server, some_module,
> remote_function2);
> @array2 = @$ref_array2;
> $length_array2 = scalar(@array2);
> }
>
> -------------------------------------------------
>
> Executing the function "sanbox()" above will result in $length_array1 ==
> 1
> (WRONG), while $length_array2 == 0 (CORRECT). Why the descrepency? Should
> functions called via remote_foreign_call() always return references? I
> am
> new to Perl, but the serialize/unserialize_variable() functions in
> web-lib.pl suggest that only references to arrays & hashes are supported.
Remote functions are supposed to be able to return arrays, but due to a bug
in webmin that I just discovered a zero-length array will not be returned
properly if in non-fast RPC mode. The simple solution if all your servers
are webmin 0.90 or later is to go into Webmin Servers, click on the called
server and change it to fast RPC mode.
I'll fix this bug properly in the next release ..
- Jamie |