Commit Graph

5303 Commits

Author SHA1 Message Date
Corinna Vinschen 54e4df33a2 * fhandler.h (class fhandler_base): Remove uninterruptible_io status
flag.
	(fhandler_base::ready_for_read): Remove declaration.
	(fhandler_socket::ready_for_read): Ditto.
	(fhandler_pipe::ready_for_read): Ditto.
	(fhandler_tty_master::is_slow): Remove.
	* fhandler_console.cc (fhandler_console::open): Drop setting
	uninterruptible_io.
	* fhandler_serial.cc (fhandler_serial::open): Ditto.
	* fhandler_tty.cc (fhandler_tty_slave::fhandler_tty_slave): Ditto.
	(fhandler_tty_master::init_console): Ditto.
	* pipe.cc (fhandler_pipe::fhandler_pipe): Ditto.
	(fhandler_pipe::open): Ditto.
	(_pipe): Ditto.
	* select.cc (fhandler_pipe::ready_for_read): Remove.
	(fhandler_base::ready_for_read): Remove.
	* syscalls.cc (readv): Drop unneeded wait variable.  Remove entire test
	which might lead to calling ready_for_read.  Remove now unused label
	out.
2011-05-04 13:06:10 +00:00
Corinna Vinschen 82fa6b929b * fhandler.h (class fhandler_mailslot): Move down in file and change
parent class to fhandler_base_overlapped.  Remove declaration of
	method write.  Add declaraiotns for raw_read and raw_write.
	* fhandler_mailslot.cc (fhandler_mailslot::fhandler_mailslot): Call
	fhandler_base_overlapped constructor.
	(fhandler_mailslot::fstat): Call fhandler_base_overlapped::fstat.
	(fhandler_mailslot::open): Drop FILE_SYNCHRONOUS_IO_NONALERT flag from
	call to NtOpenFile.
	(fhandler_mailslot::raw_read): New method.
	(fhandler_mailslot::raw_write): Ditto.  Take over length algorithm from
	former write method.
	(fhandler_mailslot::write): Remove.
	(fhandler_mailslot::ioctl): Call fhandler_base_overlapped::ioctl.
2011-05-04 12:56:12 +00:00
Corinna Vinschen 412693ab65 * fhandler.h (fhandler_dev_tape::_lock): Add bool parameter.
* fhandler_tape.cc (lock): Call _lock with false argument.
	(_lock): Take bool cancelable parameter.  Handle O_NONBLOCK.
	Make cancelable if cancelabe parameter is true.
	(fhandler_dev_tape::raw_read): Call _lock with true argument.
	(fhandler_dev_tape::raw_write): Ditto.
2011-05-04 12:23:00 +00:00
Corinna Vinschen 5152a53ade * fhandler_dsp.cc (fhandler_dev_dsp::Audio): Add fh member.
(fhandler_dev_dsp::Audio_out::Audio_out): Take pointer to encapsulating
	fhandler_dev_dsp as parameter.
	(fhandler_dev_dsp::Audio_in::Audio_in): Ditto.
	(fhandler_dev_dsp::Audio::Audio): Take pointer to encapsulating
	fhandler_dev_dsp as parameter and store in fh.
	(fhandler_dev_dsp::Audio_out::write): Change return type to int and
	return number of bytes written.  Return -1 if waitforspace returns false
	and no bytes have been written so far.
	(fhandler_dev_dsp::Audio_out::waitforspace): Change return type to bool.
	Handle O_NONBLOCK.  Make waiting loop interruptible and cancelable.
	Return false in any of these cases, otherwise true.
	(fhandler_dev_dsp::Audio_in::read): Set returned nBytes to -1 if
	waitfordata returns false and nothing has been read so far.
	(fhandler_dev_dsp::Audio_in::waitfordata): Change return type to bool.
	Handle O_NONBLOCK.  Make waiting loop interruptible and cancelable.
	Return false in any of these cases, otherwise true.
	(fhandler_dev_dsp::write): Call Audio_out constructor with this as
	parameter.
	(fhandler_dev_dsp::read): Call Audio_in constructor with this as
	parameter.
2011-05-04 11:41:22 +00:00
Christopher Faylor 9d2b7928b5 * thread.h (pthread::static_cancel_self): Mark as noreturn.
(pthread::cancel_self): Ditto.
* thread.cc (pthread::cancel_self): Explicitly use pthread::exit to avoid a
"function returns" error.
2011-05-04 06:16:59 +00:00
Christopher Faylor cdbb272b4c * pinfo.cc (pinfo::pinfo): Set procinfo to NULL to avoid potential cleanup of
uninitialized garbage.  (Suggested by Ryan Johnson)
2011-05-04 06:00:54 +00:00
Corinna Vinschen 781822a646 * select.cc (cygwin_select): Make degenerate case cancelable.
(select_stuff::destroy): New inline method to delete memory taken
	by select_stuff.
	(select_stuff::~select_stuff): Call destroy.
	(select_stuff::wait): Add case to allow canceling select.
	* select.h (select_stuff::destroy): Declare.
	* thread.cc: Mark poll, pselect and poll as cancelable.
2011-05-03 15:58:52 +00:00
Corinna Vinschen c402095aae * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Make
cancelable.  Remove test for main thread, always add signal_arrived
	to waited objects.
2011-05-03 10:11:19 +00:00
Corinna Vinschen 3ff46ba853 * fhandler_tty.cc (fhandler_tty_slave::read): Set WFMO timeout to 0 for
nonblocking case.  Drop useless waiter variable.  Rewrite wait for
	input_available_event to use a switch statement.  Handle timeout and
	failure more gracefully.  Make restartable and cancelable.  Rewrite
	wait for input_mutex to use WFMO and a switch statement.  Handle
	timeout and failure more gracefully.  Make restartable and cancelable.
2011-05-03 07:58:13 +00:00
Christopher Faylor 3f359e3254 * signal.cc (_pinfo::kill): Avoid referencing 'pid' after ESRCH. 2011-05-03 02:03:04 +00:00
Yaakov Selkowitz 705a187ee9 * cygwin.din (pthread_attr_getstack): Export.
(pthread_attr_getstackaddr): Export.
(pthread_getattr_np): Export.
* ntdll.h (enum _THREAD_INFORMATION_CLASS): Add ThreadBasicInformation.
(struct _THREAD_BASIC_INFORMATION): Define.
(NtQueryInformationThread): Declare.
* posix.sgml (std-susv4): Add pthread_attr_getstack.
(std-gnu): Add pthread_getattr_np.
(std-deprec): Add pthread_attr_getstackaddr.
(std-notimpl): Remove pthread_attr_[gs]etstackaddr, as they were
removed from SUSv4.
* thread.cc (pthread_attr::pthread_attr): Initialize stackaddr.
(pthread_attr_getstack): New function.
(pthread_attr_getstackaddr): New function.
(pthread_attr_setstacksize): Return EINVAL if passed size less than
PTHREAD_STACK_MIN, as required by POSIX.
(pthread_getattr_np): New function.
* thread.h (class pthread_attr): Add stackaddr member.
* include/pthread.h (pthread_attr_getstack): Declare.
(pthread_attr_getstackaddr): Declare unconditionally.
(pthread_attr_setstack): Declare inside false conditional for reference.
(pthread_getattr_np): Declare.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
2011-05-03 01:13:37 +00:00
Christopher Faylor 1e92c34ee4 fix typo 2011-05-02 23:11:18 +00:00
Christopher Faylor 2671ba6f3a * Makefile.in: Allow CFLAGS to be overridden from the environment. 2011-05-02 19:14:39 +00:00
Corinna Vinschen 183ad8597c * thread.cc (cancelable_wait): Remove test for main thread.
* fhandler_fifo.cc (fhandler_fifo::open_nonserver): Ditto.
2011-05-02 18:48:11 +00:00
Corinna Vinschen 27dd7bfbcd * fhndler_tty.cc (andler_pty_master::process_slave_output): Make
interruptible and cancelable.  Fix nonblocking case.
2011-05-02 18:41:10 +00:00
Corinna Vinschen e4f70cddcd * fhandler_console.cc (fhandler_console::read): Make restartable and
cancelable.
2011-05-02 17:38:16 +00:00
Christopher Faylor d85a0c243b * strace.cc (strace::vprntf): Avoid closing unopened handle. 2011-05-02 17:05:10 +00:00
Yaakov Selkowitz 58349d7c9d * sysconf.cc (sca): Set _SC_SPIN_LOCKS to _POSIX_SPIN_LOCKS. 2011-05-02 16:11:06 +00:00
Christopher Faylor 8978381c2a Eliminate trailing whitespace in some files.
* dll_init.cc (dll_list::alloc): Reset 'p' in forked process.
* select.cc (select_stuff::wait): Move cleanup() closer to WFMO to minimize
unavoidable (?) race.
2011-05-02 15:28:35 +00:00
Corinna Vinschen 29b1327208 * fhandler_serial.cc (fhandler_serial::raw_read): Add restartability
after a signal.  Add cancelability.
	(fhandler_serial::raw_write): Wait for write to succeed if O_NONBLOCK
	is not set.  Add signal handling and cancelability.
2011-05-02 10:20:35 +00:00
Corinna Vinschen a91ac4dca9 * fhandler_windows.cc (fhandler_windows::read): Use
pthread::get_cancel_event to fetch thread's cancel event.
	* flock.cc (lf_setlock): Ditto.
	* posix_ipc.cc (ipc_cond_timedwait): Ditto.
	* thread.cc (pthread::get_cancel_event): New static method.
	* thread.h (pthread::get_cancel_event): Declare.
2011-05-01 17:42:41 +00:00
Corinna Vinschen 1112b2c38f * libc/minires-os-if.c (get_dns_info): Remove unnecessary test for
existence of DnsQuery_A.
2011-05-01 14:56:46 +00:00
Corinna Vinschen 5c2be92ec4 Add missing ChangeLog entry:
* fhandler.h (fhandler_windows::is_slow): Remove.
2011-05-01 14:36:17 +00:00
Corinna Vinschen c60d0bbe68 * net.cc (fdsock): Drop setting uninterruptible_io to true. 2011-05-01 08:14:40 +00:00
Corinna Vinschen 8b6d43aecf * fhandler.h (fhandler_socket::is_slow): Remove. 2011-05-01 08:01:55 +00:00
Corinna Vinschen 1804be048a * fcntl.cc (fcntl64): Call pthread_testcancel.
* fhandler_socket.cc (fhandler_socket::connect): Ditto.
	(fhandler_socket::accept4): Ditto.
	(fhandler_socket::recvfrom): Ditto.
	(fhandler_socket::recvmsg): Ditto.
	(fhandler_socket::sendto): Ditto.
	(fhandler_socket::sendmsg): Ditto.
	* flock.cc (lf_setlock): Allow to cancel thread running blocking
	file lock.  Try to make code more readable.
	(lockf): Call pthread_testcancel.
	* mmap.cc (msync): Ditto.
	* posix_ipc.cc (ipc_cond_timedwait): Call pthread::static_cancel_self
	rather than pthread_testcancel.
	* select.cc (cygwin_select): Call pthread_testcancel.
	* syscalls.cc (pread): Ditto.
	(pwrite): Ditto.
	(readv): Ditto.
	(writev): Ditto.
	(open): Ditto.
	(close): Ditto.
	(fsync): Ditto.
	* termios.cc (tcdrain): Ditto.
	* thread.cc: Align list of cancellation points with above changes.
	Mark not-implemented functions, too.
	(cancelable_wait): Don't set unused object indices to WAIT_FAILED
	since that could result in wrong behaviour.  Set them to the invalid
	value WAIT_TIMEOUT + 1 instead.
2011-04-30 16:34:48 +00:00
Corinna Vinschen 42faed4128 * thread.h (class pthread): Add bool member canceled.
* thread.cc (pthread::pthread): Initialize canceled to false.
	(pthread::cancel): Set canceled before setting cancel_event.
	(pthread::testcancel): Check for canceled.  Only wait for cancel_event
	if canceled is true.  Explain why.
	(pthread::_fixup_after_fork): Set canceled to false.
2011-04-30 10:20:25 +00:00
Corinna Vinschen e0b0b9e4ff * errno.cc (errmap): Sort. Map ERROR_EXE_MACHINE_TYPE_MISMATCH to
ENOEXEC.
2011-04-29 18:54:23 +00:00
Corinna Vinschen 37e680bb6b * thread.cc: Update comment listing cancellation points per POSIX. 2011-04-29 18:29:26 +00:00
Corinna Vinschen 5735d5f6f4 * advapi32.cc: Add comment.
(EqualSid): Remove.
	(CopySid): Remove.
	(AddAccessAllowedAce): Remove.
	(AddAccessDeniedAce): Remove.
	(MakeSelfRelativeSD): Remove.
	* flock.cc: Replace above functions throughout with their ntdll.dll
	equivalent.
	* sec_acl.cc: Ditto.
	* sec_auth.cc: Ditto.
	* sec_helper.cc: Ditto.
	* security.cc: Ditto.
	* security.h: Ditto.
	(RtlEqualSid): Declare.  Explain why.
	(RtlCopySid): Ditto.
2011-04-29 10:38:12 +00:00
Corinna Vinschen 3e8e0c33c0 * advapi32.cc (AccessCheck): Remove.
(PrivilegeCheck): Remove.
	(OpenThreadToken): Remove.
	* fhandler_tty.cc: Replace above functions throughout with their
	ntdll.dll equivalent.
	* security.cc: Ditto.
2011-04-29 09:48:25 +00:00
Corinna Vinschen bd139e52b4 * ntdll.h (IsEventSignalled): New inline function.
* cygthread.cc (cygthread::terminate_thread): Use IsEventSignalled in
	place of WaitForSingleObject on event with 0 timeout.
	* fhandler.cc (fhandler_base_overlapped::has_ongoing_io): Ditto.
	* fhandler_fifo.cc (fhandler_fifo::open_nonserver): Ditto.
	(fhandler_fifo::wait): Ditto.
	* fhandler_termios.cc (fhandler_termios::bg_check): Ditto.
	* select.cc (verify_tty_slave): Ditto.
	* thread.cc (pthread::testcancel): Ditto.
2011-04-29 08:27:11 +00:00
Corinna Vinschen 12eac211c9 * advapi32.cc (GetTokenInformation): Remove.
(SetTokenInformation): Remove.
	* grp.cc: Replace above functions throughout with their ntdll.dll
	equivalent.
	* sec_auth.cc: Ditto.
	* syscalls.cc: Ditto.
	* uinfo.cc: Ditto.
2011-04-29 07:34:05 +00:00
Corinna Vinschen 541820d0ee * posix_ipc.cc (ipc_cond_timedwait): Only wait for pthread's
cancel_event if thread's cancelability isn't disabled.
2011-04-29 07:22:07 +00:00
Corinna Vinschen fd04c2f004 * advapi32.cc (SetSecurityDescriptorDacl): Remove.
(SetSecurityDescriptorGroup): Remove.
	(SetSecurityDescriptorOwner): Remove.
	* pinfo.cc: Replace above functions throughout with their ntdll.dll
	equivalent.
	* sec_acl.cc: Ditto.
	* sec_helper.cc: Ditto.
	* security.cc: Ditto.

	* sec_helper.cc (__sec_user): Remove old comment.
2011-04-28 15:54:47 +00:00
Corinna Vinschen 206a6ee9c8 * posix_ipc.cc (ipc_cond_timedwait): Also wait for pthread's
cancel_event, if any.  Call pthread_testcancel if cancel_event has been
	signalled.
2011-04-28 14:44:24 +00:00
Corinna Vinschen 74f9ac5be0 * posix_ipc.cc (ipc_cond_timedwait): Remove pthread_testcancel calls.
(_mq_send): Add pthread_testcancel call at start of function.
	(_mq_receive): Ditto.
2011-04-28 12:36:27 +00:00
Corinna Vinschen 86bf572ef0 * cygerrno.h (geterrno_from_nt_status): Declare.
* errno.cc (geterrno_from_nt_status): Define.
	* flock.cc: Fix copyright dates.
	* ntdll.h (enum _TIMER_TYPE): Define.
	(PTIMER_APC_ROUTINE): Define.
	(NtCancelTimer): Declare.
	(NtCreateTimer): Declare.
	(NtSetTimer): Declare.
	* posix_ipc.cc (ipc_cond_timedwait): Rewrite to make interruptible and
	restartable.  Call pthread_testcancel in case of timeout to enable
	pthread_cancel on waiting thread.  Replace WFMO timeout with waiting
	for a waitable timer.  Explain why.  Replace single call to WFMO with
	two calls, one for the event, one for the mutex.  Don't lock mutex in
	case of error.
	(ipc_cond_signal): Make void function.
	(ipc_cond_close): Ditto.
	(_mq_send): Immediately return -1 in case of error from
	ipc_cond_timedwait.
	(_mq_receive): Ditto.
2011-04-28 12:13:41 +00:00
Corinna Vinschen 1838d97b0a * advapi32.cc (GetSecurityDescriptorDacl): Remove.
(GetSecurityDescriptorGroup): Remove.
	(GetSecurityDescriptorOwner): Remove.
	* sec_acl.cc: Replace above functions throughout with their ntdll.dll
	equivalent.  Remove redundant debug output.
	* sec_auth.cc: Ditto.
	* security.cc: Ditto.
	* uinfo.cc: Ditto.
2011-04-28 09:53:11 +00:00
Corinna Vinschen 1754539e56 * advapi32.cc (InitializeAcl): Remove.
(AddAce): Remove.
	(FindFirstFreeAce): Remove.
	(GetAce): Remove.
	(InitializeSecurityDescriptor): Remove.
	(OpenProcessToken): Remove.
	* dcrt0.cc: Replace above functions throughout with their ntdll.dll
	equivalent.
	* fhandler_tty.cc: Ditto.
	* flock.cc: Ditto.
	* pinfo.cc: Ditto.  Drop unnecessary error handling.
	* sec_acl.cc: Ditto.
	* sec_auth.cc: Ditto.
	* sec_helper.cc: Ditto.
	* security.cc: Ditto.
2011-04-28 09:30:36 +00:00
Corinna Vinschen 158e516b9d * advapi32.cc (InitializeSid): Remove.
(EqualPrefixSid): Remove.
	(GetLengthSid): Remove.
	(GetSidSubAuthority): Remove.
	(GetSidSubAuthorityCount): Remove.
	(GetSidIdentifierAuthority): Remove.
	* fhandler_disk_file.cc: Remove above functions throughout with their
	ntdll.dll equivalent.
	* sec_auth.cc: Ditto.
	* sec_helper.cc: Ditto.
	* security.cc: Ditto.
2011-04-28 08:34:49 +00:00
Corinna Vinschen 41e9c14558 * advapi32.cc (AllocateLocallyUniqueId): Remove.
* fhandler_disk_file.cc (fhandler_base::open_fs): Replace call to
	AllocateLocallyUniqueId with call to NtAllocateLocallyUniqueId;
	* posix_ipc.cc (mq_open): Ditto.  Drop error handling for that call.
	(sem_open): Ditto.
2011-04-28 08:15:56 +00:00
Corinna Vinschen f97612978a * autoload.cc (GetSecurityInfo): Remove.
* ntdll.h (RtlConvertToAutoInheritSecurityObject): Declare.
	(RtlDeleteSecurityObject): Declare.
	(RtlGetControlSecurityDescriptor): Declare.
	(RtlLengthSecurityDescriptor): Declare.
	* security.cc (file_mapping): New global variable.
	(get_file_sd): Rewrite.  Clean up code.  Get rid of GetSecurityInfo
	call.
	(alloc_sd): Call RtlSetControlSecurityDescriptor to set
	SE_DACL_PROTECTED flag.
	(check_file_access): Remove mapping.  Use file_mapping instead.
	(check_registry_access): Rename mapping to reg_mapping.
	* wincap.cc: Througout, drop use_get_sec_info_on_dirs,
	* wincap.h (struct wincaps): Drop use_get_sec_info_on_dirs.
2011-04-28 07:27:51 +00:00
Corinna Vinschen 7054950175 * include/fenv.h: Add missing _FENV_H_ define. 2011-04-24 11:54:06 +00:00
Corinna Vinschen cca89be9ad * registry.cc (reg_key::get_dword): Rename from get_int, use DWORD
rather than int type.  Avoid compiler warning.
	(reg_key::set_dword): Rename from set_int, use DWORD rather than int
	type.  Change return type to NTSTATUS.
	(reg_key::get_string): Change return type to NTSTATUS.
	(reg_key::set_string): Ditto.
	* registry.h: Accommodate above changes.
	* environ.cc (regopt): Test return value of reg_key::get_string as
	NTSTATUS.
	* sched.cc (sched_rr_get_interval): Change local int vars to DWORD.
	Call reg_key::get_dword instead of reg_key::get_int.
	* shared.cc (init_installation_root): Test return value of
	reg_key::get_string as NTSTATUS.
	(shared_info::heap_slop_size): Call reg_key::get_dword rather than
	reg_key::get_int.
	(shared_info::heap_chunk_size): Ditto.
	* shared_info.h (CURR_SHARED_MAGIC): Update.
	(class shared_info): Change heap_chunk and heap_slop to DWORD  values.
2011-04-23 13:15:46 +00:00
Corinna Vinschen a0307f9914 * cygtls.cc (_cygtls::init_thread): Drop setting locals.process_logmask.
* cygtls.cc (_cygtls::remove): Always free mallocated TLS storage on
	thread exit.  Drop freeing locals.process_ident.
	* cygtls.h (struct _local_storage): Remove syslog-related members.
	* syslog.cc (syslog_globals): New static storage for global syslog
	settings.  Use throughout instead of _my_tls.locals.
	(openlog): Set new syslog_globals.process_ident value more carefully.
	* tlsoffsets.h: Regenerate.
2011-04-21 08:10:28 +00:00
Corinna Vinschen 2656876fb3 * include/sys/poll.h: Include signal.h to get definition of sigset_t. 2011-04-21 07:18:42 +00:00
Christopher Faylor 71c17c5402 * cygheap.cc (init_cygheap::close_ctty): Avoid closing console-cttys since they
don't use archetypes and this will just result in double frees.
* dll_init.cc (dll_list::protect): Define.
(dll_list::alloc): Guard list access.
(dll_list::detach): Ditto.
* dll_init.h (dll_list::protect): Declare new muto.
(dll_list::guard): Define/declare function to guard list access.
* fhandler_termios.cc (fhandler_termios::sigflush): Avoid SEGV in pathological
condition of get_ttyp() == NULL.
2011-04-21 00:53:55 +00:00
Christopher Faylor 2f9c27131f * select.cc (serial_cleanup): Make sure that device_specific_pipe is always
deleted regardless of whether it has a unique thread associated with it
(socket_cleanup): Ditto.
(mailslot_cleanup): Ditto.
2011-04-20 15:32:31 +00:00
Corinna Vinschen 12c0f2d909 * devices.h: Renumber internal devices so that FH_PROCESS is part of
the /proc family of virtual devices.
	(FH_PROC_MAX_MINOR): Define.
	* path.h (isproc_dev): Use FH_PROC_MAX_MINOR rather than FH_PROC.
2011-04-20 07:29:10 +00:00