|
27 | 27 | /* FIXME: Implement max_retry_abort and retry logic in general */ |
28 | 28 | /* FIXME: Add more timeout config options and have consistent behavior */ |
29 | 29 | /* FIXME: Do a finishing pass over the default.toml config options / comments */ |
| 30 | +/* FIXME: Improve behavior when using incremental_snapshots = false */ |
30 | 31 |
|
31 | 32 | #define GOSSIP_PEERS_MAX (FD_CONTACT_INFO_TABLE_SIZE) |
32 | 33 | #define SERVER_PEERS_MAX (FD_TOPO_SNAPSHOTS_SERVERS_MAX) |
@@ -333,11 +334,18 @@ rename_snapshots( fd_snapct_tile_t * ctx ) { |
333 | 334 | static ulong |
334 | 335 | rlimit_file_cnt( fd_topo_t const * topo FD_PARAM_UNUSED, |
335 | 336 | fd_topo_tile_t const * tile ) { |
336 | | - return 1UL + /* stderr */ |
337 | | - 1UL + /* logfile */ |
338 | | - 3UL + /* dirfd + 2 snapshot file fds in the worst case */ |
339 | | - !!download_enabled( tile ) + /* ssping socket */ |
340 | | - 2UL*tile->snapct.sources.servers_cnt; /* http resolver peer sockets (full + incr) */ |
| 337 | + ulong cnt = 1UL + /* stderr */ |
| 338 | + 1UL; /* logfile */ |
| 339 | + if( download_enabled( tile ) ) { |
| 340 | + cnt += 1UL + /* ssping socket */ |
| 341 | + 2UL + /* dirfd + full snapshot download temp fd */ |
| 342 | + tile->snapct.sources.servers_cnt; /* http resolver peer full sockets */ |
| 343 | + if( tile->snapct.incremental_snapshots ) { |
| 344 | + cnt += 1UL + /* incr snapshot download temp fd */ |
| 345 | + tile->snapct.sources.servers_cnt; /* http resolver peer incr sockets */ |
| 346 | + } |
| 347 | + } |
| 348 | + return cnt; |
341 | 349 | } |
342 | 350 |
|
343 | 351 | static ulong |
@@ -1110,31 +1118,20 @@ privileged_init( fd_topo_t * topo, |
1110 | 1118 | } |
1111 | 1119 | } |
1112 | 1120 |
|
1113 | | - /* FIXME: Do not create the temporary files if downloading is not |
1114 | | - enabled by the configuration. Account for this in rlimit. */ |
1115 | | - |
1116 | 1121 | ctx->local_out.dir_fd = -1; |
1117 | 1122 | ctx->local_out.full_snapshot_fd = -1; |
1118 | 1123 | ctx->local_out.incremental_snapshot_fd = -1; |
| 1124 | + if( FD_LIKELY( download_enabled( tile ) ) ) { |
| 1125 | + ctx->local_out.dir_fd = open( tile->snapct.snapshots_path, O_DIRECTORY|O_CLOEXEC ); |
| 1126 | + if( FD_UNLIKELY( -1==ctx->local_out.dir_fd ) ) FD_LOG_ERR(( "open(%s) failed (%i-%s)", tile->snapct.snapshots_path, errno, fd_io_strerror( errno ) )); |
1119 | 1127 |
|
1120 | | - /* Set up download descriptors because even if we have local |
1121 | | - snapshots, we may need to download new snapshots if the local |
1122 | | - snapshots are too old. */ |
1123 | | - ctx->local_out.dir_fd = open( tile->snapct.snapshots_path, O_DIRECTORY|O_CLOEXEC ); |
1124 | | - if( FD_UNLIKELY( -1==ctx->local_out.dir_fd ) ) FD_LOG_ERR(( "open() failed `%s` (%i-%s)", tile->snapct.snapshots_path, errno, fd_io_strerror( errno ) )); |
1125 | | - |
1126 | | - char full_snapshot_path[ PATH_MAX ]; |
1127 | | - FD_TEST( fd_cstr_printf_check( full_snapshot_path, PATH_MAX, NULL, "%s/" TEMP_FULL_SNAP_NAME, tile->snapct.snapshots_path ) ); |
1128 | | - ctx->local_out.full_snapshot_fd = openat( ctx->local_out.dir_fd, TEMP_FULL_SNAP_NAME, O_WRONLY|O_CREAT|O_TRUNC|O_NONBLOCK, S_IRUSR|S_IWUSR ); |
1129 | | - if( FD_UNLIKELY( -1==ctx->local_out.full_snapshot_fd ) ) FD_LOG_ERR(( "open() failed `%s` (%i-%s)", full_snapshot_path, errno, fd_io_strerror( errno ) )); |
1130 | | - |
1131 | | - if( FD_LIKELY( tile->snapct.incremental_snapshots ) ) { |
1132 | | - char incremental_snapshot_path[ PATH_MAX ]; |
1133 | | - FD_TEST( fd_cstr_printf_check( incremental_snapshot_path, PATH_MAX, NULL, "%s/" TEMP_INCR_SNAP_NAME, tile->snapct.snapshots_path ) ); |
1134 | | - ctx->local_out.incremental_snapshot_fd = openat( ctx->local_out.dir_fd, TEMP_INCR_SNAP_NAME, O_WRONLY|O_CREAT|O_TRUNC|O_NONBLOCK, S_IRUSR|S_IWUSR ); |
1135 | | - if( FD_UNLIKELY( -1==ctx->local_out.incremental_snapshot_fd ) ) FD_LOG_ERR(( "open() failed `%s` (%i-%s)", incremental_snapshot_path, errno, fd_io_strerror( errno ) )); |
1136 | | - } else { |
1137 | | - ctx->local_out.incremental_snapshot_fd = -1; |
| 1128 | + ctx->local_out.full_snapshot_fd = openat( ctx->local_out.dir_fd, TEMP_FULL_SNAP_NAME, O_WRONLY|O_CREAT|O_TRUNC|O_NONBLOCK, S_IRUSR|S_IWUSR ); |
| 1129 | + if( FD_UNLIKELY( -1==ctx->local_out.full_snapshot_fd ) ) FD_LOG_ERR(( "open(%s/%s) failed (%i-%s)", tile->snapct.snapshots_path, TEMP_FULL_SNAP_NAME, errno, fd_io_strerror( errno ) )); |
| 1130 | + |
| 1131 | + if( FD_LIKELY( tile->snapct.incremental_snapshots ) ) { |
| 1132 | + ctx->local_out.incremental_snapshot_fd = openat( ctx->local_out.dir_fd, TEMP_INCR_SNAP_NAME, O_WRONLY|O_CREAT|O_TRUNC|O_NONBLOCK, S_IRUSR|S_IWUSR ); |
| 1133 | + if( FD_UNLIKELY( -1==ctx->local_out.incremental_snapshot_fd ) ) FD_LOG_ERR(( "open(%s/%s) failed (%i-%s)", tile->snapct.snapshots_path, TEMP_INCR_SNAP_NAME, errno, fd_io_strerror( errno ) )); |
| 1134 | + } |
1138 | 1135 | } |
1139 | 1136 | } |
1140 | 1137 |
|
|
0 commit comments