1 //! The `pxar` encoder state machine.
3 //! This is the implementation used by both the synchronous and async pxar wrappers.
6 use std
::mem
::{forget, size_of, size_of_val, take}
;
7 use std
::os
::unix
::ffi
::OsStrExt
;
10 use std
::sync
::{Arc, Mutex}
;
11 use std
::task
::{Context, Poll}
;
13 use endian_trait
::Endian
;
15 use crate::binary_tree_array
;
16 use crate::decoder
::{self, SeqRead}
;
17 use crate::format
::{self, GoodbyeItem}
;
18 use crate::poll_fn
::poll_fn
;
25 pub use sync
::Encoder
;
27 /// File reference used to create hard links.
28 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)]
29 pub struct LinkOffset(u64);
33 pub fn raw(self) -> u64 {
38 /// Sequential write interface used by the encoder's state machine.
40 /// This is our internal writer trait which is available for `std::io::Write` types in the
41 /// synchronous wrapper and for both `tokio` and `future` `AsyncWrite` types in the asynchronous
48 ) -> Poll
<io
::Result
<usize>>;
50 fn poll_flush(self: Pin
<&mut Self>, cx
: &mut Context
) -> Poll
<io
::Result
<()>>;
53 /// Allow using trait objects for generics taking a `SeqWrite`.
54 impl<S
> SeqWrite
for &mut S
62 ) -> Poll
<io
::Result
<usize>> {
64 self.map_unchecked_mut(|this
| &mut **this
)
65 .poll_seq_write(cx
, buf
)
69 fn poll_flush(self: Pin
<&mut Self>, cx
: &mut Context
) -> Poll
<io
::Result
<()>> {
70 unsafe { self.map_unchecked_mut(|this| &mut **this).poll_flush(cx) }
74 /// awaitable verison of `poll_seq_write`.
75 async
fn seq_write
<T
: SeqWrite
+ ?Sized
>(
79 ) -> io
::Result
<usize> {
81 poll_fn(|cx
| unsafe { Pin::new_unchecked(&mut *output).poll_seq_write(cx, buf) }
).await?
;
82 *position
+= put
as u64;
86 /// awaitable version of 'poll_flush'.
87 async
fn flush
<T
: SeqWrite
+ ?Sized
>(output
: &mut T
) -> io
::Result
<()> {
88 poll_fn(|cx
| unsafe { Pin::new_unchecked(&mut *output).poll_flush(cx) }
).await
91 /// Write the entire contents of a buffer, handling short writes.
92 async
fn seq_write_all
<T
: SeqWrite
+ ?Sized
>(
97 while !buf
.is_empty() {
98 let got
= seq_write(&mut *output
, buf
, &mut *position
).await?
;
104 /// Write an endian-swappable struct.
105 async
fn seq_write_struct
<E
: Endian
, T
>(
111 T
: SeqWrite
+ ?Sized
,
113 let data
= data
.to_le();
115 unsafe { std::slice::from_raw_parts(&data as *const E as *const u8, size_of_val(&data)) }
;
116 seq_write_all(output
, buf
, position
).await
119 /// Write a pxar entry.
120 async
fn seq_write_pxar_entry
<T
>(
127 T
: SeqWrite
+ ?Sized
,
129 let header
= format
::Header
::with_content_size(htype
, data
.len() as u64);
130 header
.check_header_size()?
;
132 seq_write_struct(&mut *output
, header
, &mut *position
).await?
;
133 seq_write_all(output
, data
, position
).await
136 /// Write a pxar entry terminated by an additional zero which is not contained in the provided
138 async
fn seq_write_pxar_entry_zero
<T
>(
145 T
: SeqWrite
+ ?Sized
,
147 let header
= format
::Header
::with_content_size(htype
, 1 + data
.len() as u64);
148 header
.check_header_size()?
;
150 seq_write_struct(&mut *output
, header
, &mut *position
).await?
;
151 seq_write_all(&mut *output
, data
, &mut *position
).await?
;
152 seq_write_all(output
, &[0u8], position
).await
155 /// Write a pxar entry consiting of an endian-swappable struct.
156 async
fn seq_write_pxar_struct_entry
<E
, T
>(
163 T
: SeqWrite
+ ?Sized
,
166 let data
= data
.to_le();
168 unsafe { std::slice::from_raw_parts(&data as *const E as *const u8, size_of_val(&data)) }
;
169 seq_write_pxar_entry(output
, htype
, buf
, position
).await
172 /// Error conditions caused by wrong usage of this crate.
173 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
174 pub enum EncodeError
{
175 /// The user dropped a `File` without without finishing writing all of its contents.
177 /// This is required because the payload lengths is written out at the begining and decoding
178 /// requires there to follow the right amount of data.
181 /// The user dropped a directory without finalizing it.
183 /// Finalizing is required to build the goodbye table at the end of a directory.
188 struct EncoderState
{
189 /// Goodbye items for this directory, excluding the tail.
190 items
: Vec
<GoodbyeItem
>,
192 /// User caused error conditions.
193 encode_error
: Option
<EncodeError
>,
195 /// Offset of this directory's ENTRY.
199 /// Offset to this directory's first FILENAME.
202 /// If this is a subdirectory, this points to the this directory's FILENAME.
203 file_offset
: Option
<u64>,
205 /// If this is a subdirectory, this contains this directory's hash for the goodbye item.
208 /// We need to keep track how much we have written to get offsets.
213 fn merge_error(&mut self, error
: Option
<EncodeError
>) {
214 // one error is enough:
215 if self.encode_error
.is_none() {
216 self.encode_error
= error
;
220 fn add_error(&mut self, error
: EncodeError
) {
221 self.merge_error(Some(error
));
225 pub(crate) enum EncoderOutput
<'a
, T
> {
230 impl<'a
, T
> EncoderOutput
<'a
, T
> {
232 fn to_borrowed_mut
<'s
>(&'s
mut self) -> EncoderOutput
<'s
, T
>
236 EncoderOutput
::Borrowed(self.as_mut())
240 impl<'a
, T
> std
::convert
::AsMut
<T
> for EncoderOutput
<'a
, T
> {
241 fn as_mut(&mut self) -> &mut T
{
243 EncoderOutput
::Owned(o
) => o
,
244 EncoderOutput
::Borrowed(b
) => b
,
249 impl<'a
, T
> std
::convert
::From
<T
> for EncoderOutput
<'a
, T
> {
250 fn from(t
: T
) -> Self {
251 EncoderOutput
::Owned(t
)
255 impl<'a
, T
> std
::convert
::From
<&'a
mut T
> for EncoderOutput
<'a
, T
> {
256 fn from(t
: &'a
mut T
) -> Self {
257 EncoderOutput
::Borrowed(t
)
261 /// The encoder state machine implementation for a directory.
263 /// We use `async fn` to implement the encoder state machine so that we can easily plug in both
264 /// synchronous or `async` I/O objects in as output.
265 pub(crate) struct EncoderImpl
<'a
, T
: SeqWrite
+ 'a
> {
266 output
: EncoderOutput
<'a
, T
>,
268 parent
: Option
<&'a
mut EncoderState
>,
271 /// Since only the "current" entry can be actively writing files, we share the file copy
273 file_copy_buffer
: Arc
<Mutex
<Vec
<u8>>>,
276 impl<'a
, T
: SeqWrite
+ 'a
> Drop
for EncoderImpl
<'a
, T
> {
278 if let Some(ref mut parent
) = self.parent
{
280 parent
.merge_error(self.state
.encode_error
);
282 parent
.add_error(EncodeError
::IncompleteDirectory
);
284 } else if !self.finished
{
285 // FIXME: how do we deal with this?
286 // eprintln!("Encoder dropped without finishing!");
291 impl<'a
, T
: SeqWrite
+ 'a
> EncoderImpl
<'a
, T
> {
293 output
: EncoderOutput
<'a
, T
>,
295 ) -> io
::Result
<EncoderImpl
<'a
, T
>> {
296 if !metadata
.is_dir() {
297 io_bail
!("directory metadata must contain the directory mode flag");
299 let mut this
= Self {
301 state
: EncoderState
::default(),
304 file_copy_buffer
: Arc
::new(Mutex
::new(crate::util
::vec_new(1024 * 1024))),
307 this
.encode_metadata(metadata
).await?
;
308 this
.state
.files_offset
= this
.position();
313 fn check(&self) -> io
::Result
<()> {
314 match self.state
.encode_error
{
315 Some(EncodeError
::IncompleteFile
) => io_bail
!("incomplete file"),
316 Some(EncodeError
::IncompleteDirectory
) => io_bail
!("directory not finalized"),
321 pub async
fn create_file
<'b
>(
326 ) -> io
::Result
<FileImpl
<'b
, T
>>
330 self.create_file_do(metadata
, file_name
.as_os_str().as_bytes(), file_size
)
334 async
fn create_file_do
<'b
>(
339 ) -> io
::Result
<FileImpl
<'b
, T
>>
345 let file_offset
= self.position();
346 self.start_file_do(Some(metadata
), file_name
).await?
;
348 let header
= format
::Header
::with_content_size(format
::PXAR_PAYLOAD
, file_size
);
349 header
.check_header_size()?
;
351 seq_write_struct(self.output
.as_mut(), header
, &mut self.state
.write_position
).await?
;
353 let payload_data_offset
= self.position();
355 let meta_size
= payload_data_offset
- file_offset
;
358 output
: self.output
.as_mut(),
359 goodbye_item
: GoodbyeItem
{
360 hash
: format
::hash_filename(file_name
),
362 size
: file_size
+ meta_size
,
364 remaining_size
: file_size
,
365 parent
: &mut self.state
,
369 /// Return a file offset usable with `add_hardlink`.
370 pub async
fn add_file(
375 content
: &mut dyn SeqRead
,
376 ) -> io
::Result
<LinkOffset
> {
377 let buf
= Arc
::clone(&self.file_copy_buffer
);
378 let mut file
= self.create_file(metadata
, file_name
, file_size
).await?
;
379 let mut buf
= buf
.lock().expect("failed to lock temporary buffer mutex");
381 let got
= decoder
::seq_read(&mut *content
, &mut buf
[..]).await?
;
385 file
.write_all(&buf
[..got
]).await?
;
388 Ok(file
.file_offset())
391 /// Return a file offset usable with `add_hardlink`.
392 pub async
fn add_symlink(
397 ) -> io
::Result
<()> {
398 let target
= target
.as_os_str().as_bytes();
399 let mut data
= Vec
::with_capacity(target
.len() + 1);
402 let _ofs
: LinkOffset
= self
406 Some((format
::PXAR_SYMLINK
, &data
)),
412 /// Return a file offset usable with `add_hardlink`.
413 pub async
fn add_hardlink(
417 target_offset
: LinkOffset
,
418 ) -> io
::Result
<()> {
419 let current_offset
= self.position();
420 if current_offset
<= target_offset
.0 {
421 io_bail
!("invalid hardlink offset, can only point to prior files");
424 let offset_bytes
= (current_offset
- target_offset
.0).to_le_bytes();
425 let target_bytes
= target
.as_os_str().as_bytes();
426 let mut hardlink
= Vec
::with_capacity(offset_bytes
.len() + target_bytes
.len() + 1);
427 hardlink
.extend(&offset_bytes
);
428 hardlink
.extend(target_bytes
);
430 let _this_offset
: LinkOffset
= self
431 .add_file_entry(None
, file_name
, Some((format
::PXAR_HARDLINK
, &hardlink
)))
436 /// Return a file offset usable with `add_hardlink`.
437 pub async
fn add_device(
441 device
: format
::Device
,
442 ) -> io
::Result
<()> {
443 if !metadata
.is_device() {
444 io_bail
!("entry added via add_device must have a device mode in its metadata");
447 let device
= device
.to_le();
448 let device
= unsafe {
449 std
::slice
::from_raw_parts(
450 &device
as *const format
::Device
as *const u8,
451 size_of
::<format
::Device
>(),
454 let _ofs
: LinkOffset
= self
458 Some((format
::PXAR_DEVICE
, device
)),
464 /// Return a file offset usable with `add_hardlink`.
465 pub async
fn add_fifo(&mut self, metadata
: &Metadata
, file_name
: &Path
) -> io
::Result
<()> {
466 if !metadata
.is_fifo() {
467 io_bail
!("entry added via add_device must be of type fifo in its metadata");
470 let _ofs
: LinkOffset
= self.add_file_entry(Some(metadata
), file_name
, None
).await?
;
474 /// Return a file offset usable with `add_hardlink`.
475 pub async
fn add_socket(&mut self, metadata
: &Metadata
, file_name
: &Path
) -> io
::Result
<()> {
476 if !metadata
.is_socket() {
477 io_bail
!("entry added via add_device must be of type socket in its metadata");
480 let _ofs
: LinkOffset
= self.add_file_entry(Some(metadata
), file_name
, None
).await?
;
484 /// Return a file offset usable with `add_hardlink`.
485 async
fn add_file_entry(
487 metadata
: Option
<&Metadata
>,
489 entry_htype_data
: Option
<(u64, &[u8])>,
490 ) -> io
::Result
<LinkOffset
> {
493 let file_offset
= self.position();
495 let file_name
= file_name
.as_os_str().as_bytes();
497 self.start_file_do(metadata
, file_name
).await?
;
498 if let Some((htype
, entry_data
)) = entry_htype_data
{
499 seq_write_pxar_entry(
500 self.output
.as_mut(),
503 &mut self.state
.write_position
,
508 let end_offset
= self.position();
510 self.state
.items
.push(GoodbyeItem
{
511 hash
: format
::hash_filename(file_name
),
513 size
: end_offset
- file_offset
,
516 Ok(LinkOffset(file_offset
))
520 fn position(&mut self) -> u64 {
521 self.state
.write_position
524 pub async
fn create_directory(
528 ) -> io
::Result
<EncoderImpl
<'_
, T
>> {
531 if !metadata
.is_dir() {
532 io_bail
!("directory metadata must contain the directory mode flag");
535 let file_name
= file_name
.as_os_str().as_bytes();
536 let file_hash
= format
::hash_filename(file_name
);
538 let file_offset
= self.position();
539 self.encode_filename(file_name
).await?
;
541 let entry_offset
= self.position();
542 self.encode_metadata(&metadata
).await?
;
544 let files_offset
= self.position();
546 // the child will write to OUR state now:
547 let write_position
= self.position();
549 let file_copy_buffer
= Arc
::clone(&self.file_copy_buffer
);
552 // always forward as Borrowed(), to avoid stacking references on nested calls
553 output
: self.output
.to_borrowed_mut(),
554 state
: EncoderState
{
557 file_offset
: Some(file_offset
),
562 parent
: Some(&mut self.state
),
568 async
fn start_file_do(
570 metadata
: Option
<&Metadata
>,
572 ) -> io
::Result
<()> {
573 self.encode_filename(file_name
).await?
;
574 if let Some(metadata
) = metadata
{
575 self.encode_metadata(&metadata
).await?
;
580 async
fn encode_metadata(&mut self, metadata
: &Metadata
) -> io
::Result
<()> {
581 seq_write_pxar_struct_entry(
582 self.output
.as_mut(),
584 metadata
.stat
.clone(),
585 &mut self.state
.write_position
,
589 for xattr
in &metadata
.xattrs
{
590 self.write_xattr(xattr
).await?
;
593 self.write_acls(&metadata
.acl
).await?
;
595 if let Some(fcaps
) = &metadata
.fcaps
{
596 self.write_file_capabilities(fcaps
).await?
;
599 if let Some(qpid
) = &metadata
.quota_project_id
{
600 self.write_quota_project_id(qpid
).await?
;
606 async
fn write_xattr(&mut self, xattr
: &format
::XAttr
) -> io
::Result
<()> {
607 seq_write_pxar_entry(
608 self.output
.as_mut(),
611 &mut self.state
.write_position
,
616 async
fn write_acls(&mut self, acl
: &crate::Acl
) -> io
::Result
<()> {
617 for acl
in &acl
.users
{
618 seq_write_pxar_struct_entry(
619 self.output
.as_mut(),
620 format
::PXAR_ACL_USER
,
622 &mut self.state
.write_position
,
627 for acl
in &acl
.groups
{
628 seq_write_pxar_struct_entry(
629 self.output
.as_mut(),
630 format
::PXAR_ACL_GROUP
,
632 &mut self.state
.write_position
,
637 if let Some(acl
) = &acl
.group_obj
{
638 seq_write_pxar_struct_entry(
639 self.output
.as_mut(),
640 format
::PXAR_ACL_GROUP_OBJ
,
642 &mut self.state
.write_position
,
647 if let Some(acl
) = &acl
.default {
648 seq_write_pxar_struct_entry(
649 self.output
.as_mut(),
650 format
::PXAR_ACL_DEFAULT
,
652 &mut self.state
.write_position
,
657 for acl
in &acl
.default_users
{
658 seq_write_pxar_struct_entry(
659 self.output
.as_mut(),
660 format
::PXAR_ACL_DEFAULT_USER
,
662 &mut self.state
.write_position
,
667 for acl
in &acl
.default_groups
{
668 seq_write_pxar_struct_entry(
669 self.output
.as_mut(),
670 format
::PXAR_ACL_DEFAULT_GROUP
,
672 &mut self.state
.write_position
,
680 async
fn write_file_capabilities(&mut self, fcaps
: &format
::FCaps
) -> io
::Result
<()> {
681 seq_write_pxar_entry(
682 self.output
.as_mut(),
685 &mut self.state
.write_position
,
690 async
fn write_quota_project_id(
692 quota_project_id
: &format
::QuotaProjectId
,
693 ) -> io
::Result
<()> {
694 seq_write_pxar_struct_entry(
695 self.output
.as_mut(),
696 format
::PXAR_QUOTA_PROJID
,
698 &mut self.state
.write_position
,
703 async
fn encode_filename(&mut self, file_name
: &[u8]) -> io
::Result
<()> {
704 crate::util
::validate_filename(file_name
)?
;
705 seq_write_pxar_entry_zero(
706 self.output
.as_mut(),
707 format
::PXAR_FILENAME
,
709 &mut self.state
.write_position
,
714 pub async
fn finish(mut self) -> io
::Result
<()> {
715 let tail_bytes
= self.finish_goodbye_table().await?
;
716 seq_write_pxar_entry(
717 self.output
.as_mut(),
718 format
::PXAR_GOODBYE
,
720 &mut self.state
.write_position
,
724 if let EncoderOutput
::Owned(output
) = &mut self.output
{
725 flush(output
).await?
;
728 // done up here because of the self-borrow and to propagate
729 let end_offset
= self.position();
731 if let Some(parent
) = &mut self.parent
{
732 parent
.write_position
= end_offset
;
734 let file_offset
= self
737 .expect("internal error: parent set but no file_offset?");
739 parent
.items
.push(GoodbyeItem
{
740 hash
: self.state
.file_hash
,
742 size
: end_offset
- file_offset
,
745 self.finished
= true;
749 async
fn finish_goodbye_table(&mut self) -> io
::Result
<Vec
<u8>> {
750 let goodbye_offset
= self.position();
752 // "take" out the tail (to not leave an array of endian-swapped structs in `self`)
753 let mut tail
= take(&mut self.state
.items
);
754 let tail_size
= (tail
.len() + 1) * size_of
::<GoodbyeItem
>();
755 let goodbye_size
= tail_size
as u64 + size_of
::<format
::Header
>() as u64;
757 // sort, then create a BST
758 tail
.sort_unstable_by(|a
, b
| a
.hash
.cmp(&b
.hash
));
760 let mut bst
= Vec
::with_capacity(tail
.len() + 1);
762 bst
.set_len(tail
.len());
764 binary_tree_array
::copy(tail
.len(), |src
, dest
| {
765 let mut item
= tail
[src
].clone();
766 // fixup the goodbye table offsets to be relative and with the right endianess
767 item
.offset
= goodbye_offset
- item
.offset
;
769 std
::ptr
::write(&mut bst
[dest
], item
.to_le());
776 hash
: format
::PXAR_GOODBYE_TAIL_MARKER
,
777 offset
: goodbye_offset
- self.state
.entry_offset
,
783 // turn this into a byte vector since after endian-swapping we can no longer guarantee that
784 // the items make sense:
785 let data
= bst
.as_mut_ptr() as *mut u8;
786 let capacity
= bst
.capacity() * size_of
::<GoodbyeItem
>();
788 Ok(unsafe { Vec::from_raw_parts(data, tail_size, capacity) }
)
792 /// Writer for a file object in a directory.
793 pub struct FileImpl
<'a
, S
: SeqWrite
> {
796 /// This file's `GoodbyeItem`. FIXME: We currently don't touch this, can we just push it
797 /// directly instead of on Drop of FileImpl?
798 goodbye_item
: GoodbyeItem
,
800 /// While writing data to this file, this is how much space we still have left, this must reach
804 /// The directory containing this file. This is where we propagate the `IncompleteFile` error
805 /// to, and where we insert our `GoodbyeItem`.
806 parent
: &'a
mut EncoderState
,
809 impl<'a
, S
: SeqWrite
> Drop
for FileImpl
<'a
, S
> {
811 if self.remaining_size
!= 0 {
812 self.parent
.add_error(EncodeError
::IncompleteFile
);
815 self.parent
.items
.push(self.goodbye_item
.clone());
819 impl<'a
, S
: SeqWrite
> FileImpl
<'a
, S
> {
820 /// Get the file offset to be able to reference it with `add_hardlink`.
821 pub fn file_offset(&self) -> LinkOffset
{
822 LinkOffset(self.goodbye_item
.offset
)
825 fn check_remaining(&self, size
: usize) -> io
::Result
<()> {
826 if size
as u64 > self.remaining_size
{
827 io_bail
!("attempted to write more than previously allocated");
833 /// Poll write interface to more easily connect to tokio/futures.
834 #[cfg(feature = "tokio-io")]
836 self: Pin
<&mut Self>,
839 ) -> Poll
<io
::Result
<usize>> {
840 let this
= self.get_mut();
841 this
.check_remaining(data
.len())?
;
842 let output
= unsafe { Pin::new_unchecked(&mut *this.output) }
;
843 match output
.poll_seq_write(cx
, data
) {
844 Poll
::Ready(Ok(put
)) => {
845 this
.remaining_size
-= put
as u64;
846 this
.parent
.write_position
+= put
as u64;
853 /// Poll flush interface to more easily connect to tokio/futures.
854 #[cfg(feature = "tokio-io")]
855 pub fn poll_flush(self: Pin
<&mut Self>, cx
: &mut Context
) -> Poll
<io
::Result
<()>> {
856 unsafe { self.map_unchecked_mut(|this| this.output).poll_flush(cx) }
859 /// Poll close/shutdown interface to more easily connect to tokio/futures.
861 /// This just calls flush, though, since we're just a virtual writer writing to the file
862 /// provided by our encoder.
863 #[cfg(feature = "tokio-io")]
864 pub fn poll_close(self: Pin
<&mut Self>, cx
: &mut Context
) -> Poll
<io
::Result
<()>> {
865 unsafe { self.map_unchecked_mut(|this| this.output).poll_flush(cx) }
868 /// Write file data for the current file entry in a pxar archive.
870 /// This forwards to the output's `SeqWrite::poll_seq_write` and may write fewer bytes than
871 /// requested. Check the return value for how many. There's also a `write_all` method available
873 pub async
fn write(&mut self, data
: &[u8]) -> io
::Result
<usize> {
874 self.check_remaining(data
.len())?
;
876 poll_fn(|cx
| unsafe { Pin::new_unchecked(&mut self.output).poll_seq_write(cx, data) }
)
878 //let put = seq_write(self.output.as_mut().unwrap(), data).await?;
879 self.remaining_size
-= put
as u64;
880 self.parent
.write_position
+= put
as u64;
884 /// Completely write file data for the current file entry in a pxar archive.
885 pub async
fn write_all(&mut self, data
: &[u8]) -> io
::Result
<()> {
886 self.check_remaining(data
.len())?
;
887 seq_write_all(self.output
, data
, &mut self.parent
.write_position
).await?
;
888 self.remaining_size
-= data
.len() as u64;
893 #[cfg(feature = "tokio-io")]
894 impl<'a
, S
: SeqWrite
> tokio
::io
::AsyncWrite
for FileImpl
<'a
, S
> {
895 fn poll_write(self: Pin
<&mut Self>, cx
: &mut Context
, buf
: &[u8]) -> Poll
<io
::Result
<usize>> {
896 FileImpl
::poll_write(self, cx
, buf
)
899 fn poll_flush(self: Pin
<&mut Self>, cx
: &mut Context
) -> Poll
<io
::Result
<()>> {
900 FileImpl
::poll_flush(self, cx
)
903 fn poll_shutdown(self: Pin
<&mut Self>, cx
: &mut Context
) -> Poll
<io
::Result
<()>> {
904 FileImpl
::poll_close(self, cx
)