@@ -928,39 +928,6 @@ zfs_send_progress(zfs_handle_t *zhp, int fd, uint64_t *bytes_written,
928
928
return (0 );
929
929
}
930
930
931
- static volatile boolean_t send_progress_thread_signal_duetotimer ;
932
- static void
933
- send_progress_thread_act (int sig , siginfo_t * info , void * ucontext )
934
- {
935
- (void ) sig , (void ) ucontext ;
936
- send_progress_thread_signal_duetotimer = info -> si_code == SI_TIMER ;
937
- }
938
-
939
- struct timer_desirability {
940
- timer_t timer ;
941
- boolean_t desired ;
942
- };
943
- static void
944
- timer_delete_cleanup (void * timer )
945
- {
946
- struct timer_desirability * td = timer ;
947
- if (td -> desired )
948
- timer_delete (td -> timer );
949
- }
950
-
951
- #ifdef SIGINFO
952
- #define SEND_PROGRESS_THREAD_PARENT_BLOCK_SIGINFO sigaddset(&new, SIGINFO)
953
- #else
954
- #define SEND_PROGRESS_THREAD_PARENT_BLOCK_SIGINFO
955
- #endif
956
- #define SEND_PROGRESS_THREAD_PARENT_BLOCK (old ) { \
957
- sigset_t new; \
958
- sigemptyset(&new); \
959
- sigaddset(&new, SIGUSR1); \
960
- SEND_PROGRESS_THREAD_PARENT_BLOCK_SIGINFO; \
961
- pthread_sigmask(SIG_BLOCK, &new, old); \
962
- }
963
-
964
931
static void *
965
932
send_progress_thread (void * arg )
966
933
{
@@ -974,26 +941,6 @@ send_progress_thread(void *arg)
974
941
struct tm tm ;
975
942
int err ;
976
943
977
- const struct sigaction signal_action =
978
- {.sa_sigaction = send_progress_thread_act , .sa_flags = SA_SIGINFO };
979
- struct sigevent timer_cfg =
980
- {.sigev_notify = SIGEV_SIGNAL , .sigev_signo = SIGUSR1 };
981
- const struct itimerspec timer_time =
982
- {.it_value = {.tv_sec = 1 }, .it_interval = {.tv_sec = 1 }};
983
- struct timer_desirability timer = {};
984
-
985
- sigaction (SIGUSR1 , & signal_action , NULL );
986
- #ifdef SIGINFO
987
- sigaction (SIGINFO , & signal_action , NULL );
988
- #endif
989
-
990
- if ((timer .desired = pa -> pa_progress || pa -> pa_astitle )) {
991
- if (timer_create (CLOCK_MONOTONIC , & timer_cfg , & timer .timer ))
992
- return ((void * )(uintptr_t )errno );
993
- (void ) timer_settime (timer .timer , 0 , & timer_time , NULL );
994
- }
995
- pthread_cleanup_push (timer_delete_cleanup , & timer );
996
-
997
944
if (!pa -> pa_parsable && pa -> pa_progress ) {
998
945
(void ) fprintf (stderr ,
999
946
"TIME %s %sSNAPSHOT %s\n" ,
@@ -1006,12 +953,12 @@ send_progress_thread(void *arg)
1006
953
* Print the progress from ZFS_IOC_SEND_PROGRESS every second.
1007
954
*/
1008
955
for (;;) {
1009
- pause ( );
956
+ ( void ) sleep ( 1 );
1010
957
if ((err = zfs_send_progress (zhp , pa -> pa_fd , & bytes ,
1011
958
& blocks )) != 0 ) {
1012
959
if (err == EINTR || err == ENOENT )
1013
- err = 0 ;
1014
- pthread_exit ((( void * )(uintptr_t )err ) );
960
+ return (( void * ) 0 ) ;
961
+ return (( void * )(uintptr_t )err );
1015
962
}
1016
963
1017
964
(void ) time (& t );
@@ -1044,26 +991,22 @@ send_progress_thread(void *arg)
1044
991
(void ) fprintf (stderr , "%02d:%02d:%02d\t%llu\t%s\n" ,
1045
992
tm .tm_hour , tm .tm_min , tm .tm_sec ,
1046
993
(u_longlong_t )bytes , zhp -> zfs_name );
1047
- } else if (pa -> pa_progress ||
1048
- !send_progress_thread_signal_duetotimer ) {
994
+ } else if (pa -> pa_progress ) {
1049
995
zfs_nicebytes (bytes , buf , sizeof (buf ));
1050
996
(void ) fprintf (stderr , "%02d:%02d:%02d %5s %s\n" ,
1051
997
tm .tm_hour , tm .tm_min , tm .tm_sec ,
1052
998
buf , zhp -> zfs_name );
1053
999
}
1054
1000
}
1055
- pthread_cleanup_pop (B_TRUE );
1056
1001
return (NULL );
1057
1002
}
1058
1003
1059
1004
static boolean_t
1060
- send_progress_thread_exit (
1061
- libzfs_handle_t * hdl , pthread_t ptid , sigset_t * oldmask )
1005
+ send_progress_thread_exit (libzfs_handle_t * hdl , pthread_t ptid )
1062
1006
{
1063
1007
void * status = NULL ;
1064
1008
(void ) pthread_cancel (ptid );
1065
1009
(void ) pthread_join (ptid , & status );
1066
- pthread_sigmask (SIG_SETMASK , oldmask , NULL );
1067
1010
int error = (int )(uintptr_t )status ;
1068
1011
if (error != 0 && status != PTHREAD_CANCELED )
1069
1012
return (zfs_standard_error (hdl , error ,
@@ -1257,8 +1200,7 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
1257
1200
* If progress reporting is requested, spawn a new thread to
1258
1201
* poll ZFS_IOC_SEND_PROGRESS at a regular interval.
1259
1202
*/
1260
- sigset_t oldmask ;
1261
- {
1203
+ if (sdd -> progress || sdd -> progressastitle ) {
1262
1204
pa .pa_zhp = zhp ;
1263
1205
pa .pa_fd = sdd -> outfd ;
1264
1206
pa .pa_parsable = sdd -> parsable ;
@@ -1273,13 +1215,13 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
1273
1215
zfs_close (zhp );
1274
1216
return (err );
1275
1217
}
1276
- SEND_PROGRESS_THREAD_PARENT_BLOCK (& oldmask );
1277
1218
}
1278
1219
1279
1220
err = dump_ioctl (zhp , sdd -> prevsnap , sdd -> prevsnap_obj ,
1280
1221
fromorigin , sdd -> outfd , flags , sdd -> debugnv );
1281
1222
1282
- if (send_progress_thread_exit (zhp -> zfs_hdl , tid , & oldmask ))
1223
+ if ((sdd -> progress || sdd -> progressastitle ) &&
1224
+ send_progress_thread_exit (zhp -> zfs_hdl , tid ))
1283
1225
return (-1 );
1284
1226
}
1285
1227
@@ -1621,9 +1563,8 @@ estimate_size(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags,
1621
1563
progress_arg_t pa = { 0 };
1622
1564
int err = 0 ;
1623
1565
pthread_t ptid ;
1624
- sigset_t oldmask ;
1625
1566
1626
- {
1567
+ if ( flags -> progress || flags -> progressastitle ) {
1627
1568
pa .pa_zhp = zhp ;
1628
1569
pa .pa_fd = fd ;
1629
1570
pa .pa_parsable = flags -> parsable ;
@@ -1637,15 +1578,15 @@ estimate_size(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags,
1637
1578
return (zfs_error (zhp -> zfs_hdl ,
1638
1579
EZFS_THREADCREATEFAILED , errbuf ));
1639
1580
}
1640
- SEND_PROGRESS_THREAD_PARENT_BLOCK (& oldmask );
1641
1581
}
1642
1582
1643
1583
err = lzc_send_space_resume_redacted (zhp -> zfs_name , from ,
1644
1584
lzc_flags_from_sendflags (flags ), resumeobj , resumeoff , bytes ,
1645
1585
redactbook , fd , & size );
1646
1586
* sizep = size ;
1647
1587
1648
- if (send_progress_thread_exit (zhp -> zfs_hdl , ptid , & oldmask ))
1588
+ if ((flags -> progress || flags -> progressastitle ) &&
1589
+ send_progress_thread_exit (zhp -> zfs_hdl , ptid ))
1649
1590
return (-1 );
1650
1591
1651
1592
if (!flags -> progress && !flags -> parsable )
@@ -1936,12 +1877,11 @@ zfs_send_resume_impl_cb_impl(libzfs_handle_t *hdl, sendflags_t *flags,
1936
1877
if (!flags -> dryrun ) {
1937
1878
progress_arg_t pa = { 0 };
1938
1879
pthread_t tid ;
1939
- sigset_t oldmask ;
1940
1880
/*
1941
1881
* If progress reporting is requested, spawn a new thread to
1942
1882
* poll ZFS_IOC_SEND_PROGRESS at a regular interval.
1943
1883
*/
1944
- {
1884
+ if ( flags -> progress || flags -> progressastitle ) {
1945
1885
pa .pa_zhp = zhp ;
1946
1886
pa .pa_fd = outfd ;
1947
1887
pa .pa_parsable = flags -> parsable ;
@@ -1959,15 +1899,15 @@ zfs_send_resume_impl_cb_impl(libzfs_handle_t *hdl, sendflags_t *flags,
1959
1899
zfs_close (zhp );
1960
1900
return (error );
1961
1901
}
1962
- SEND_PROGRESS_THREAD_PARENT_BLOCK (& oldmask );
1963
1902
}
1964
1903
1965
1904
error = lzc_send_resume_redacted (zhp -> zfs_name , fromname , outfd ,
1966
1905
lzc_flags , resumeobj , resumeoff , redact_book );
1967
1906
if (redact_book != NULL )
1968
1907
free (redact_book );
1969
1908
1970
- if (send_progress_thread_exit (hdl , tid , & oldmask )) {
1909
+ if ((flags -> progressastitle || flags -> progress ) &&
1910
+ send_progress_thread_exit (hdl , tid )) {
1971
1911
zfs_close (zhp );
1972
1912
return (-1 );
1973
1913
}
@@ -2754,8 +2694,7 @@ zfs_send_one_cb_impl(zfs_handle_t *zhp, const char *from, int fd,
2754
2694
* If progress reporting is requested, spawn a new thread to poll
2755
2695
* ZFS_IOC_SEND_PROGRESS at a regular interval.
2756
2696
*/
2757
- sigset_t oldmask ;
2758
- {
2697
+ if (flags -> progress || flags -> progressastitle ) {
2759
2698
pa .pa_zhp = zhp ;
2760
2699
pa .pa_fd = fd ;
2761
2700
pa .pa_parsable = flags -> parsable ;
@@ -2772,13 +2711,13 @@ zfs_send_one_cb_impl(zfs_handle_t *zhp, const char *from, int fd,
2772
2711
return (zfs_error (zhp -> zfs_hdl ,
2773
2712
EZFS_THREADCREATEFAILED , errbuf ));
2774
2713
}
2775
- SEND_PROGRESS_THREAD_PARENT_BLOCK (& oldmask );
2776
2714
}
2777
2715
2778
2716
err = lzc_send_redacted (name , from , fd ,
2779
2717
lzc_flags_from_sendflags (flags ), redactbook );
2780
2718
2781
- if (send_progress_thread_exit (hdl , ptid , & oldmask ))
2719
+ if ((flags -> progress || flags -> progressastitle ) &&
2720
+ send_progress_thread_exit (hdl , ptid ))
2782
2721
return (-1 );
2783
2722
2784
2723
if (err == 0 && (flags -> props || flags -> holds || flags -> backup )) {
0 commit comments