diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index c034d0df7..62f6c11e6 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -41,17 +41,6 @@ struct __cygwin_perfile *perfile_table; HANDLE NO_COPY fhandler_base_overlapped::asio_done; LONG NO_COPY fhandler_base_overlapped::asio_close_counter; -void -fhandler_base::reset (const fhandler_base *from) -{ - ra.rabuf = NULL; - ra.ralen = 0; - ra.raixget = 0; - ra.raixput = 0; - ra.rabuflen = 0; - _refcnt = 0; -} - int fhandler_base::puts_readahead (const char *s, size_t len) { @@ -479,7 +468,7 @@ fhandler_base::open_with_arch (int flags, mode_t mode) { if (!archetype->get_handle ()) { - copyto (archetype); + archetype->copy_from (this); archetype_usecount (1); archetype->archetype = NULL; usecount = 0; @@ -496,7 +485,7 @@ fhandler_base::open_with_arch (int flags, mode_t mode) strcpy (name, get_name ()); } fhandler_base *arch = archetype; - archetype->copyto (this); + copy_from (archetype); if (name) set_name (name); archetype = arch; diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 29907a707..bc83d6f5d 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -229,7 +229,6 @@ class fhandler_base path_conv pc; - void reset (const fhandler_base *); virtual bool use_archetype () const {return false;} virtual void set_name (path_conv &pc); virtual void set_name (const char *s) @@ -496,18 +495,30 @@ public: fhandler_base (void *) {} - virtual void copyto (fhandler_base *x) + protected: + void _copy_from_reset_helper () { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + ra.rabuf = NULL; + ra.ralen = 0; + ra.raixget = 0; + ra.raixput = 0; + ra.rabuflen = 0; + _refcnt = 0; + } + + public: + virtual void copy_from (fhandler_base *x) + { + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } virtual fhandler_base *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_base)); fhandler_base *fh = new (ptr) fhandler_base (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -759,18 +770,18 @@ class fhandler_socket_inet: public fhandler_socket_wsock /* from here on: CLONING */ fhandler_socket_inet (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_socket_inet *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_socket_inet)); fhandler_socket_inet *fh = new (ptr) fhandler_socket_inet (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -859,18 +870,18 @@ class fhandler_socket_local: public fhandler_socket_wsock /* from here on: CLONING */ fhandler_socket_local (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_socket_local *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_socket_local)); fhandler_socket_local *fh = new (ptr) fhandler_socket_local (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -1302,18 +1313,18 @@ class fhandler_socket_unix : public fhandler_socket /* from here on: CLONING */ fhandler_socket_unix (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_socket_unix *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_socket_unix)); fhandler_socket_unix *fh = new (ptr) fhandler_socket_unix (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -1371,19 +1382,19 @@ public: cfree (atomic_write_buf); } - virtual void copyto (fhandler_base *x) + virtual void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - reinterpret_cast (x)->atomic_write_buf = NULL; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + atomic_write_buf = NULL; + _copy_from_reset_helper (); } virtual fhandler_base_overlapped *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_base_overlapped)); fhandler_base_overlapped *fh = new (ptr) fhandler_base_overlapped (ptr); - copyto (fh); + fh->copy_from (this); return fh; } @@ -1423,19 +1434,19 @@ public: fhandler_pipe (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - reinterpret_cast (x)->atomic_write_buf = NULL; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + atomic_write_buf = NULL; + _copy_from_reset_helper (); } fhandler_pipe *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pipe)); fhandler_pipe *fh = new (ptr) fhandler_pipe (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -1678,18 +1689,18 @@ public: fhandler_fifo (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_fifo *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_fifo)); fhandler_fifo *fhf = new (ptr) fhandler_fifo (ptr); - copyto (fhf); + fhf->copy_from (this); fhf->pipe_name_buf = NULL; return fhf; } @@ -1732,18 +1743,18 @@ class fhandler_dev_raw: public fhandler_base fhandler_dev_raw (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_dev_raw *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_raw)); fhandler_dev_raw *fh = new (ptr) fhandler_dev_raw (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -1793,18 +1804,18 @@ class fhandler_dev_floppy: public fhandler_dev_raw fhandler_dev_floppy (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_dev_floppy *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_floppy)); fhandler_dev_floppy *fh = new (ptr) fhandler_dev_floppy (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -1843,18 +1854,18 @@ class fhandler_dev_tape: public fhandler_dev_raw fhandler_dev_tape (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_dev_tape *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_tape)); fhandler_dev_tape *fh = new (ptr) fhandler_dev_tape (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -1918,18 +1929,18 @@ class fhandler_disk_file: public fhandler_base fhandler_disk_file (void *) {} dev_t get_dev () { return pc.fs_serial_number (); } - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_disk_file *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_disk_file)); fhandler_disk_file *fh = new (ptr) fhandler_disk_file (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -1956,18 +1967,18 @@ public: dev_t get_dev () { return dir_exists ? pc.fs_serial_number () : get_device (); } - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_dev *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev)); fhandler_dev *fh = new (ptr) fhandler_dev (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -1989,18 +2000,18 @@ class fhandler_cygdrive: public fhandler_disk_file fhandler_cygdrive (void *) {} dev_t get_dev () { return get_device (); } - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_cygdrive *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_cygdrive)); fhandler_cygdrive *fh = new (ptr) fhandler_cygdrive (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -2050,18 +2061,18 @@ class fhandler_serial: public fhandler_base fhandler_serial (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_serial *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_serial)); fhandler_serial *fh = new (ptr) fhandler_serial (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -2122,18 +2133,18 @@ class fhandler_termios: public fhandler_base fhandler_termios (void *) {} - virtual void copyto (fhandler_base *x) + virtual void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } virtual fhandler_termios *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_termios)); fhandler_termios *fh = new (ptr) fhandler_termios (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -2384,18 +2395,18 @@ private: fhandler_console (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_console *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_console)); fhandler_console *fh = new (ptr) fhandler_console (ptr); - copyto (fh); + fh->copy_from (this); return fh; } input_states process_input_message (); @@ -2459,18 +2470,18 @@ class fhandler_pty_common: public fhandler_termios fhandler_pty_common (void *) {} - virtual void copyto (fhandler_base *x) + virtual void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } virtual fhandler_pty_common *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pty_common)); fhandler_pty_common *fh = new (ptr) fhandler_pty_common (ptr); - copyto (fh); + fh->copy_from (this); return fh; } @@ -2542,18 +2553,18 @@ class fhandler_pty_slave: public fhandler_pty_common fhandler_pty_slave (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_pty_slave *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pty_slave)); fhandler_pty_slave *fh = new (ptr) fhandler_pty_slave (ptr); - copyto (fh); + fh->copy_from (this); return fh; } bool setup_pseudoconsole (bool nopcon); @@ -2640,18 +2651,18 @@ public: fhandler_pty_master (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_pty_master *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_pty_master)); fhandler_pty_master *fh = new (ptr) fhandler_pty_master (ptr); - copyto (fh); + fh->copy_from (this); return fh; } bool to_be_read_from_pcon (void); @@ -2672,18 +2683,18 @@ class fhandler_dev_null: public fhandler_base fhandler_dev_null (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_dev_null *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_null)); fhandler_dev_null *fh = new (ptr) fhandler_dev_null (ptr); - copyto (fh); + fh->copy_from (this); return fh; } @@ -2710,18 +2721,18 @@ class fhandler_dev_zero: public fhandler_base fhandler_dev_zero (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_dev_zero *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_zero)); fhandler_dev_zero *fh = new (ptr) fhandler_dev_zero (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -2744,18 +2755,18 @@ class fhandler_dev_random: public fhandler_base fhandler_dev_random () : fhandler_base () {} fhandler_dev_random (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_dev_random *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_random)); fhandler_dev_random *fh = new (ptr) fhandler_dev_random (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -2784,18 +2795,18 @@ class fhandler_dev_clipboard: public fhandler_base fhandler_dev_clipboard (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_dev_clipboard *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_clipboard)); fhandler_dev_clipboard *fh = new (ptr) fhandler_dev_clipboard (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -2824,18 +2835,18 @@ class fhandler_windows: public fhandler_base fhandler_windows (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_windows *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_windows)); fhandler_windows *fh = new (ptr) fhandler_windows (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -2880,18 +2891,18 @@ class fhandler_dev_dsp: public fhandler_base fhandler_dev_dsp (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_dev_dsp *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_dev_dsp)); fhandler_dev_dsp *fh = new (ptr) fhandler_dev_dsp (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -2933,18 +2944,18 @@ class fhandler_virtual : public fhandler_base fhandler_virtual (void *) {} - virtual void copyto (fhandler_base *x) + virtual void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } virtual fhandler_virtual *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_virtual)); fhandler_virtual *fh = new (ptr) fhandler_virtual (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -2967,18 +2978,18 @@ class fhandler_proc: public fhandler_virtual fhandler_proc (void *) {} - virtual void copyto (fhandler_base *x) + virtual void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } virtual fhandler_proc *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_proc)); fhandler_proc *fh = new (ptr) fhandler_proc (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -3005,18 +3016,18 @@ class fhandler_procsys: public fhandler_virtual fhandler_procsys (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_procsys *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_procsys)); fhandler_procsys *fh = new (ptr) fhandler_procsys (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -3036,18 +3047,18 @@ class fhandler_procsysvipc: public fhandler_proc fhandler_procsysvipc (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_procsysvipc *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_procsysvipc)); fhandler_procsysvipc *fh = new (ptr) fhandler_procsysvipc (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -3069,18 +3080,18 @@ class fhandler_netdrive: public fhandler_virtual fhandler_netdrive (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_netdrive *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_netdrive)); fhandler_netdrive *fh = new (ptr) fhandler_netdrive (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -3112,18 +3123,18 @@ class fhandler_registry: public fhandler_proc fhandler_registry (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_registry *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_registry)); fhandler_registry *fh = new (ptr) fhandler_registry (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -3148,18 +3159,18 @@ class fhandler_process: public fhandler_proc fhandler_process (void *) {} - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_process *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_process)); fhandler_process *fh = new (ptr) fhandler_process (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -3178,18 +3189,18 @@ class fhandler_process_fd : public fhandler_process size_t get_size () const { return sizeof *this; } - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_process_fd *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_process_fd)); fhandler_process_fd *fh = new (ptr) fhandler_process_fd (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -3208,18 +3219,18 @@ class fhandler_procnet: public fhandler_proc size_t get_size () const { return sizeof *this; } - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_procnet *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_procnet)); fhandler_procnet *fh = new (ptr) fhandler_procnet (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -3250,18 +3261,18 @@ class fhandler_signalfd : public fhandler_base size_t get_size () const { return sizeof *this; } - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_signalfd *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_signalfd)); fhandler_signalfd *fh = new (ptr) fhandler_signalfd (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; @@ -3302,18 +3313,18 @@ class fhandler_timerfd : public fhandler_base size_t get_size () const { return sizeof *this; } - void copyto (fhandler_base *x) + void copy_from (fhandler_base *x) { - x->pc.free_strings (); - *reinterpret_cast (x) = *this; - x->reset (this); + pc.free_strings (); + *this = *reinterpret_cast (x); + _copy_from_reset_helper (); } fhandler_timerfd *clone (cygheap_types malloc_type = HEAP_FHANDLER) { void *ptr = (void *) ccalloc (malloc_type, 1, sizeof (fhandler_timerfd)); fhandler_timerfd *fh = new (ptr) fhandler_timerfd (ptr); - copyto (fh); + fh->copy_from (this); return fh; } }; diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc index bf9613dc1..476fe1fcc 100644 --- a/winsup/cygwin/fhandler_pipe.cc +++ b/winsup/cygwin/fhandler_pipe.cc @@ -96,7 +96,7 @@ fhandler_pipe::open (int flags, mode_t mode) if ((rwflags == O_RDONLY && !(cfd->get_access () & GENERIC_READ)) || (rwflags == O_WRONLY && !(cfd->get_access () & GENERIC_WRITE))) continue; - cfd->copyto (this); + copy_from (cfd); set_handle (NULL); pc.close_conv_handle (); if (!cfd->dup (this, flags))