X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=generator%2Fgenerator_perl.ml;h=f42bc8798dcd3b36e067765454a5bc6e34ba3aeb;hp=09bf20ff74a723adff8d9ba1a457d5e195fd9825;hb=f4dadd0fcfe41b9cc6fcd6097c4c3cf509d69879;hpb=bc468c87d04b34faacd208c49cca4a5096e5103c diff --git a/generator/generator_perl.ml b/generator/generator_perl.ml index 09bf20f..f42bc87 100644 --- a/generator/generator_perl.ml +++ b/generator/generator_perl.ml @@ -256,11 +256,32 @@ delete_event_callback (g, event_handle) int event_handle; PREINIT: char key[64]; + SV *cb; CODE: snprintf (key, sizeof key, \"_perl_event_%%d\", event_handle); - guestfs_set_private (g, key, NULL); + cb = guestfs_get_private (g, key); + if (cb) { + SvREFCNT_dec (cb); + guestfs_set_private (g, key, NULL); + guestfs_delete_event_callback (g, event_handle); + } - guestfs_delete_event_callback (g, event_handle); +SV * +last_errno (g) + guestfs_h *g; +PREINIT: + int errnum; + CODE: + errnum = guestfs_last_errno (g); + RETVAL = newSViv (errnum); + OUTPUT: + RETVAL + +void +user_cancel (g) + guestfs_h *g; + PPCODE: + guestfs_user_cancel (g); "; @@ -625,6 +646,9 @@ with libvirt. All errors turn into calls to C (see L). +The error string from libguestfs is directly available from +C<$@>. Use the C method if you want to get the errno. + =head1 METHODS =over 4 @@ -738,6 +762,31 @@ this function. This removes the callback which was previously registered using C. +=item $errnum = $h->last_errno (); + +This returns the last error number (errno) that happened on the +handle C<$h>. + +If successful, an errno integer not equal to zero is returned. + +If no error number is available, this returns 0. +See L for more details of why +this can happen. + +You can use the standard Perl module L to compare +the numeric error returned from this call with symbolic +errnos: + + $h->mkdir (\"/foo\"); + if ($h->last_errno() == Errno::EEXIST()) { + # mkdir failed because the directory exists already. + } + +=item $h->user_cancel (); + +Cancel current transfer. This is safe to call from Perl signal +handlers and threads. + =cut ";