@@ -961,6 +961,20 @@ send_progress_thread(void *arg)
961
961
}
962
962
}
963
963
964
+ static boolean_t
965
+ send_progress_thread_exit (libzfs_handle_t * hdl , pthread_t ptid )
966
+ {
967
+ void * status = NULL ;
968
+ (void ) pthread_cancel (ptid );
969
+ (void ) pthread_join (ptid , & status );
970
+ int error = (int )(uintptr_t )status ;
971
+ if (error != 0 && status != PTHREAD_CANCELED )
972
+ return (zfs_standard_error (hdl , error ,
973
+ dgettext (TEXT_DOMAIN , "progress thread exited nonzero" )));
974
+ else
975
+ return (B_FALSE );
976
+ }
977
+
964
978
static void
965
979
send_print_verbose (FILE * fout , const char * tosnap , const char * fromsnap ,
966
980
uint64_t size , boolean_t parsable )
@@ -1133,17 +1147,9 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
1133
1147
err = dump_ioctl (zhp , sdd -> prevsnap , sdd -> prevsnap_obj ,
1134
1148
fromorigin , sdd -> outfd , flags , sdd -> debugnv );
1135
1149
1136
- if (sdd -> progress ) {
1137
- void * status = NULL ;
1138
- (void ) pthread_cancel (tid );
1139
- (void ) pthread_join (tid , & status );
1140
- int error = (int )(uintptr_t )status ;
1141
- if (error != 0 && status != PTHREAD_CANCELED ) {
1142
- return (zfs_standard_error (zhp -> zfs_hdl , error ,
1143
- dgettext (TEXT_DOMAIN ,
1144
- "progress thread exited nonzero" )));
1145
- }
1146
- }
1150
+ if (sdd -> progress &&
1151
+ send_progress_thread_exit (zhp -> zfs_hdl , tid ))
1152
+ return (-1 );
1147
1153
}
1148
1154
1149
1155
(void ) strcpy (sdd -> prevsnap , thissnap );
@@ -1505,20 +1511,8 @@ estimate_size(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags,
1505
1511
lzc_flags_from_sendflags (flags ), resumeobj , resumeoff , bytes ,
1506
1512
redactbook , fd , & size );
1507
1513
1508
- if (flags -> progress ) {
1509
- void * status = NULL ;
1510
- (void ) pthread_cancel (ptid );
1511
- (void ) pthread_join (ptid , & status );
1512
- int error = (int )(uintptr_t )status ;
1513
- if (error != 0 && status != PTHREAD_CANCELED ) {
1514
- char errbuf [1024 ];
1515
- (void ) snprintf (errbuf , sizeof (errbuf ),
1516
- dgettext (TEXT_DOMAIN , "progress thread exited "
1517
- "nonzero" ));
1518
- return (zfs_standard_error (zhp -> zfs_hdl , error ,
1519
- errbuf ));
1520
- }
1521
- }
1514
+ if (flags -> progress && send_progress_thread_exit (zhp -> zfs_hdl , ptid ))
1515
+ return (-1 );
1522
1516
1523
1517
if (err != 0 ) {
1524
1518
zfs_error_aux (zhp -> zfs_hdl , "%s" , strerror (err ));
@@ -1830,19 +1824,8 @@ zfs_send_resume_impl_cb_impl(libzfs_handle_t *hdl, sendflags_t *flags,
1830
1824
if (redact_book != NULL )
1831
1825
free (redact_book );
1832
1826
1833
- if (flags -> progress ) {
1834
- void * status = NULL ;
1835
- (void ) pthread_cancel (tid );
1836
- (void ) pthread_join (tid , & status );
1837
- int error = (int )(uintptr_t )status ;
1838
- if (error != 0 && status != PTHREAD_CANCELED ) {
1839
- char errbuf [1024 ];
1840
- (void ) snprintf (errbuf , sizeof (errbuf ),
1841
- dgettext (TEXT_DOMAIN ,
1842
- "progress thread exited nonzero" ));
1843
- return (zfs_standard_error (hdl , error , errbuf ));
1844
- }
1845
- }
1827
+ if (flags -> progress && send_progress_thread_exit (hdl , tid ))
1828
+ return (-1 );
1846
1829
1847
1830
char errbuf [1024 ];
1848
1831
(void ) snprintf (errbuf , sizeof (errbuf ), dgettext (TEXT_DOMAIN ,
@@ -2641,16 +2624,8 @@ zfs_send_one_cb_impl(zfs_handle_t *zhp, const char *from, int fd,
2641
2624
err = lzc_send_redacted (name , from , fd ,
2642
2625
lzc_flags_from_sendflags (flags ), redactbook );
2643
2626
2644
- if (flags -> progress ) {
2645
- void * status = NULL ;
2646
- (void ) pthread_cancel (ptid );
2647
- (void ) pthread_join (ptid , & status );
2648
- int error = (int )(uintptr_t )status ;
2649
- if (error != 0 && status != PTHREAD_CANCELED )
2650
- return (zfs_standard_error_fmt (hdl , error ,
2651
- dgettext (TEXT_DOMAIN ,
2652
- "progress thread exited nonzero" )));
2653
- }
2627
+ if (flags -> progress && send_progress_thread_exit (hdl , ptid ))
2628
+ return (-1 );
2654
2629
2655
2630
if (err == 0 && (flags -> props || flags -> holds || flags -> backup )) {
2656
2631
/* Write the final end record. */
0 commit comments