summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/flock.cc
Commit message (Collapse)AuthorAgeFilesLines
* Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout optioncygwin-2_5_2-releaseCorinna Vinschen2016-06-231-2/+0
| | | | | | | | | | | | | | Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause. Everything else stays under GPLv3+. New Linking Exception exempts resulting executables from LGPLv3 section 4. Add CONTRIBUTORS file to keep track of licensing. Remove 'Copyright Red Hat Inc' comments. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix race condition when waiting for a signalCorinna Vinschen2015-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * cygtls.h (_cygtls::wait_signal_arrived): Renamed from set_signal_arrived. (_cygtls::set_signal_arrived): New function signalling signal_arrived. (_cygtls::reset_signal_arrived): Don't reset will_wait_for_signal. (_cygtls::unwait_signal_arrived): New function only resetting will_wait_for_signal. (class wait_signal_arrived): Rename from set_signal_arrived. Accommodate name change throughout Cygwin. (wait_signal_arrived::~wait_signal_arrived): Call _cygtls::unwait_signal_arrived. Add comment. * cygserver_ipc.h (ipc_set_proc_info): Fetch signal_arrived handle via call to _cygtls::get_signal_arrived. * exceptions.cc (_cygtls::interrupt_setup): Signal signal_arrived via call to _cygtls::set_signal_arrived. (_cygtls::handle_SIGCONT): Ditto. * fhandler_socket.cc (fhandler_socket::wait_for_events): Generate WSAEVENT array prior to entering wait loop. Add cancel event object if available. Remove calls to pthread_testcancel and just call pthread::static_cancel_self if the cancel event object is signalled. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* flock: Fix hang in object collision caseCorinna Vinschen2015-11-121-2/+2
| | | | | | | * flock.cc (lockf_t::create_lock_obj): Correctly recreate lock object attributes anew in each loop. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Avoid deadlock in flock(2)Corinna Vinschen2015-11-051-3/+3
| | | | | | | | * fcntl.cc (fcntl64): Don't lock fd table when performing locking. * flock.cc (flock): Ditto. (lockf): Ditto. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* flock.cc: Fix stack allocation from callee used in callerCorinna Vinschen2015-09-081-6/+8
| | | | | | | | | | * flock.cc (lockf_t::create_lock_obj_attr): Add buffer parameter. Call _everyone_sd with buffer argument from caller rather than everyone_sd with locally allocated stack buffer. (lockf_t::create_lock_obj): Call create_lock_obj_attr only once outside the loop and with additional buffer argument. (lockf_t::open_lock_obj): Call create_lock_obj_attr with additional buffer argument.
* * flock.cc (fhandler_base::lock): Convert accidental system_printf toCorinna Vinschen2015-02-111-2/+2
| | | | debug_printf in case of non-matching file modes. Clear up debug output.
* * flock.cc (create_lock_in_parent): Make lf_obj handle inheritable.Corinna Vinschen2014-12-021-2/+10
| | | | | | | Explain why. (lockf_t::create_lock_obj): Use FALSE, rather than 0 for BOOL argument. (lockf_t::del_lock_obj): Check if NtSetEvent succeeded and print system message if not.
* * Throughout, use __try/__except/__endtry blocks, rather than myfaultCorinna Vinschen2014-08-221-70/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | handler. * cygtls.cc (_cygtls::remove): Accommodate the fact that pathbufs has been moved from _local_storage to _cygtls. * cygtls.h (class tls_pathbuf): Add comment to hint to gendef usage of counters. Change type of counters to uint32_t for clarity. Remove _cygtls as friend class. (struct _local_storage): Move pathbufs from here... (struct _cygtls): ...to here, allowing to access it from _sigbe. (class san): Only define on 32 bit. Remove errno, _c_cnt and _w_cnt members. (san::setup): Drop parameter. Don't initialize removed members. (san::leave): Don't set removed members. (class myfault): Only define on 32 bit. (myfault::faulted): Only keep implementation not taking any parameter. Drop argument in call to sebastian.setup. (__try/__leave/__except/__endtry): Implement to support real SEH. For now stick to SJLJ on 32 bit. * dcrt0.cc (dll_crt0_0): Drop 64 bit call to exception::install_myfault_handler. * exception.h (exception_handler): Define with EXCEPTION_DISPOSITION as return type. (PDISPATCHER_CONTEXT): Define as void * on 32 bit. Define as pointer to _DISPATCHER_CONTEXT on 64 bit. (class exception): Define separately for 32 and 64 bit. (exception::myfault): Add handler for myfault SEH handling on 64 bit. (exception::exception): Fix mangled method name to account for change in type of last parameter. (exception::install_myfault_handler): Remove. * exceptions.cc (exception::myfault_handle): Remove. (exception::myfault): New SEH handler for 64 bit. * gendef (_sigbe): Set tls_pathbuf counters to 0 explicitely when returning to the caller. * ntdll.h: Move a comment to a better place. (struct _SCOPE_TABLE): Define on 64 bit. * thread.cc (verifyable_object_isvalid): Remove gcc 4.7 workaround. * tls_pbuf.cc (tls_pbuf): Fix to accommodate new place of pathbufs. (tls_pathbuf::destroy): Change type of loop variables to uint32_t. * tls_pbuf.h (class tmp_pathbuf): Change type of buffer counters to uint32_t. Accommodate new place of pathbufs. * tlsoffsets.h: Regenerate. * tlsoffsets64.h: Regenerate.
* * flock.cc (delete_lock_in_parent): Use LIST_FOREACH_SAFE to avoidCorinna Vinschen2014-05-201-3/+3
| | | | dereferencing freed pointer (CID 60224).
* * dcrt0.cc (child_info_spawn::handle_spawn): Call fixup_lockf_after_execCorinna Vinschen2014-02-101-6/+22
| | | | | | | | with additional argument to specify if the process has been execed or spawned. * flock.cc (fixup_lockf_after_exec): Take bool parameter to handle exec and spawn differently. In case of spawn, just give up POSIX locks in favor of the still running parent. Add comments to explain.
* * flock.cc (fhandler_base::lock): Only refuse to lock nohandle andCorinna Vinschen2013-10-251-4/+10
| | | | | | | | old-style console devices when called to perform BSD flock locking. Add a FIXME to comment and align description. * ntdll.h (THREADINFOCLASS): Following MSDN, rename throughout from THREAD_INFORMATION_CLASS.
* * devices.in (dev_storage): Map /dev/zero and /dev/full to \Device\Null.Corinna Vinschen2013-10-241-30/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * devices.cc: Regenerate. * dtable.h (struct dtable): Make fhandler_base friend, rather than fhandler_disk_file. * fhandler.cc (fhandler_base::open_with_arch): Create unique id. (fhandler_base::cleanup): Call del_my_locks. (fhandler_base::fcntl): Handle F_GETLK, F_SETLK and F_SETLKW. * fhandler.h (fhandler_base::get_dev): Return real device number. (fhandler_base::set_unique_id): New inline method. (fhandler_disk_file::lock): Drop declaration. (fhandler_disk_file::get_dev): New method, return pc.fs_serial_number. (fhandler_dev_zero::open): Drop declaration. * fhandler_disk_file.cc (fhandler_disk_file::close): Move del_my_locks call to fhandler_base::open_with_arch. (fhandler_disk_file::fcntl): Move handling of locking commands to fhandler_base::fcntl. (fhandler_base::open_fs): Drop call to NtAllocateLocallyUniqueId. * fhandler_zero.cc (fhandler_dev_zero::open): Remove so that default fhandler_base::open is used to open \Device\Null. * flock.cc (fixup_lockf_after_exec): Finding a single fhandler is enough here. (fhandler_base::lock): Replace fhandler_disk_file::lock. Refuse to lock nohandle devices. Handle read/write test using POSIX flags. Explain why. Never fail on SEEK_CUR or SEEK_END, rather assume position 0, just as Linux. * net.cc (fdsock): Create unique id.
* * flock.cc (lockf_t::from_obj_name): Fix test for valid pid.Corinna Vinschen2013-08-231-1/+1
|
* * fhandler.cc (fhandler_base::lock): Move to flock.cc.Corinna Vinschen2013-06-041-5/+23
| | | | | | | | | | | | | | (fhandler_base::fixup_after_exec): Reset mandatory_locking. * fhandler.h (class fhandler_base): Add mandatory_locking status flag. Add mandatory_locking accessor methods. Accommodate change throughout. (fhandler_base::mand_lock): Declare. (class fhandler_disk_file): Drop in favor of new status flag. * (fhandler_disk_file::fcntl): Call need_fork_fixup if mandatory_locking flag gets set. * flock.cc (fhandler_base::lock): Define here. (flock): Handle mandatory_locking. (lockf): Ditto. (fhandler_base::mand_lock): Define.
* * autoload.cc (CancelSynchronousIo): Define.Corinna Vinschen2013-06-021-1/+200
| | | | | | | | | | | | | | | | | | | | | | | | * fcntl.cc (fcntl64): Drop handling of locking commands. * fhandler.h (class fhandler_disk_file): Add mandatory_locking. (fhandler_disk_file::fcntl): Declare. (fhandler_disk_file::mand_lock): Declare. * fhandler_disk_file.cc (fhandler_disk_file::fhandler_disk_file): Initialize mandatory_locking. (fhandler_disk_file::fcntl): New method. Handle F_LCK_MANDATORY and locking commands. (fhandler_disk_file::dup): Duplicate mandatory_locking. Fix a bug when duplicating prw_handle failed. (fhandler_disk_file::fixup_after_fork): Reset mandatory_locking. * flock.cc (fhandler_disk_file::lock): Add comment. (struct lock_parms): New struct to pass parameters to blocking_lock_thr thread function. (blocking_lock_thr): New thread function. (fhandler_disk_file::mand_lock): New methof implementing mandatory locking with Windows semantics. * ntdll.h (NtLockFile): Declare. (NtUnlockFile): Declare. * include/fcntl.h: Fix a comment. (F_LCK_MANDATORY): Define. Add lengthy comment to explain.
* * Merge in cygwin-64bit-branch.Corinna Vinschen2013-04-231-31/+31
|
* whitespace cleanupChristopher Faylor2012-08-161-1/+1
|
* Change "set_thread_waiting" to "set_signal_arrived" throughout.Christopher Faylor2012-07-231-1/+1
|
* * DevNotes: Add entry cgf-000013.Christopher Faylor2012-07-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * cygserver_ipc.h (ipc_set_proc_info): Use _cygtls::ipc_set_proc_info to set per-thread signal arrived value. * cygthread.cc (cygthread::detach): Use per-thread signal_arrived via set_thread_waiting. * fork.cc (_cygtls::fixup_after_fork): Clear signal_arrived. (_cygtls::remove): Close any signal_arrived handle when thread exists. (_cygtls::find_tls): Remove unneeded function. * cygtls.h: Update copyright. (class _cygtls): Reorganize to help avoid rebuilding newlib when structure changes. (_cygtls::event): Delete. (_cygtls::threadkill): Ditto. (_cygtls::signal_waiting): Declare new bool. (_cygtls::find_tls): Delete declaration. (_cygtls::set_threadkill): Ditto. (_cygtls::reset_threadkill): Ditto. (_cygtls::set_signal_arrived): Declare new function. (class set_thread_waiting): Declare new class. * cygwait.cc (cw_nowait_storage): Define. (cygwait): Set per-thread signal_arrived via set_thread_waiting. Don't special-case _main_tls. * cygwait.h (cw_nowait): Define. (cw_infinite): Ditto. (cygwait): Redefine pathological wait-only case. * dcrt0.cc (dll_crt0_0): Remove call to now-defunct events_init(). (dll_crt0_1): Remove call to now-defunct create_signal_arrived(). * exceptions.cc: Reflect set_signal_mask() argument reordering throughout. Remove signal mask synchronization throughout. (events_init): Delete definition. (mask_sync): Delete now-unneeded mask synchronization. (set_signal_mask): Reverse order of arguments to "standard" to, from layout. Rename "newmask" argument to "setmask". Remove debugging. (sig_handle_tty_stop): Use cancelable_wait rather than WFMO. (_cygtls::interrupt_setup): Don't treat "threadkill" events specially. Conditionally set signal_arrived depending on whether the thread has created it or not. (sigpacket::process): Reorganize to reflect thread-specific sending of signals which is more in line with the way it was actually supposed to work. * fhandler_socket.cc (get_inet_addr): Use cancelable_wait rather than IsEventSignalled to avoid potential race. (fhandler_socket::wait_for_events): Set signal_arrived event using set_thread_waiting(). (fhandler_socket::close): Use cygwait for the case of just waiting 10 ms for a signal. * fhandler_tape.cc (fhandler_dev_tape::_lock): Use cancelable_wait rather than WFMO. Redo switch/case tests accordingly. * fhandler_termios.cc (fhandler_termios::bg_check): Use cygwait for case of just waiting 0 ms for a potential signal. * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Use cancelable_wait rather than WFSO. * fhandler_windows.cc (fhandler_windows::read): Set per-thread signal_arrived via set_thread_waiting(). * flock.cc (lf_setlock): Ditto. * select.cc (pselect): Ditto. Set per-thread signal_arrived using set_thread_waiting(). * gendef: Don't special case handling of _cygtls::sig for threads. * gentls_offsets: Use #pragma once in tlsoffsets.h. * ntdll.h: Use #pragma once. * poll.cc: Reflect set_signal_mask() argument reordering. * posix_ipc.cc (ipc_mutex_lock): Use cancelable_wait rather than WFMO. (ipc_cond_timedwait): Set perl-thread signal arrived using set_thread_waiting(). * security.h: Use #pragma once. * signal.cc (abort): Reflect set_signal_mask() argument reordering. (clock_nanosleep): Ditto. Change call to cancelable_wait to properly specify handling of cancel and interrupt. (sigwaitinfo): Remove handling of per-thread event in favor of per-thread signal_arrived. Use cancelable_wait rather than WFSO. * sigproc.cc (signal_arrived): Delete definition. (create_signal_arrived): Ditto. * sigproc.h (signal_arrived): Delete declaration. (set_signal_mask): Avoid defining as a "C" function. Don't conditionally declare. (create_signal_arrived): Delete declaration. * syscalls.cc (rename): Use cygwait() rather than WFSO. * thread.h (fast_mutex::lock): Use cw_infinite rather than LARGE_NULL. * wait.cc (wait4): Ditto. * thread.cc (pthread_mutex::lock): Ditto. (pthread::join): Ditto. (semaphore::_wait): Ditto. (pthread_kill): Remove set_threadkill() accommodation. * tlsoffsets.h: Regenerate.
* * fhandler_serial.cc: Fix includes for IOCTL codes to support Mingw64.Corinna Vinschen2012-06-281-1/+1
| | | | | | | | * fhandler_tape.cc: Ditto. * flock.cc (allow_others_to_sync): Use PISECURITY_DESCRIPTOR since PSECURITY_DESCRIPTOR is supposed to be the opaque type. * ntdll.h: Remove CreateDisposition flags again, now that they are defined in Mingw64's ntdef.h. Ditto for Create/Open flags.
* Revert errneous checkin.Christopher Faylor2012-06-191-1/+1
| | | | Check in actual change associated with ChangeLog.
* * cygwait.cc (cancelable_wait): Mimic old cygwait behavior more closely wrtChristopher Faylor2012-06-191-1/+1
| | | | | | | | handling of call_signal_handler. * cygwait.h (WAIT_CANCELED): Move here and redefine. (WAIT_SIGNALED): Ditto. * thread.h (WAIT_CANCELED): Delete. (WAIT_SIGNALED): Ditto.
* * flock.cc (allow_others_to_sync): Reorder conditional expression toCorinna Vinschen2012-03-021-6/+6
| | | | | check for DACL presence first, since otherwise dacl pointer value is undefined. Add comment.
* * flock.cc (allow_others_to_sync): Use RtlGetDaclSecurityDescriptorCorinna Vinschen2012-03-021-2/+16
| | | | | rather than accessing the SECURITY_DESCRIPTOR structure directly. Take no DACL and NULL DACL into account.
* * flock.cc (LOCK_DIR_NAME_FMT): Define.Corinna Vinschen2012-02-261-45/+251
| | | | | | | | | | | | | | | | | | | | | | | | | | (LOCK_DIR_NAME_LEN): Define. (LOCK_DIR_NAME_DEV_OFF): Define. (LOCK_DIR_NAME_INO_OFF): Define. (LOCK_OBJ_NAME_FMT): Define. Add comment. (class lockf_t): Use bitsize-explicit types. Declare from_obj_name, (class inode_t): Make use, unuse and inuse methods public. Add a lock argument to get method declaration. (inode_t::get): Add lock argument. Only lock node if lock arg is true. (inode_t::inode_t): Use LOCK_DIR_NAME_FMT as format string. (lockf_t::from_obj_name): New method to generate lockf_t content from lock event object basename. (inode_t::get_all_locks_list): Just call from_obj_name here and copy result into final lockf_t. (create_lock_obj_attr): Use LOCK_OBJ_NAME_FMT as format string. (create_lock_in_parent): New thread function to create lockf_t structure in parent process. (delete_lock_in_parent): New thread function to reap stale BSD locks in parent process. (lockf_t::create_lock_obj): Try to duplicate lock object handle into parent process and call create_lock_in_parent as parent remote thread. (lockf_t::del_lock_obj): Call delete_lock_in_parent as parent remote thread. (fhandler_disk_file::lock): Add lock arg to inode_t::get call.
* * flock.cc (inode_t::del_my_locks): Drop useless counter lc. CloseCorinna Vinschen2012-02-201-3/+7
| | | | | | lock object handle explicitely in case of called during fork. Add comment to explain why. * fork.cc (frok::child): Drop declaration of fixup_lockf_after_fork.
* * flock.cc (lf_setlock): Add timeout variable and set before callingCorinna Vinschen2012-02-151-13/+15
| | | | | | | WFMO. Drop debug output if process is not available. Set timeout to 0 instead. Document timeout 0 in WFMO comment. (lf_getblock): Drop invalid F_POSIX lock type shortcut. Only return overlap if event is not signalled. Fix comment.
* * flock.cc (lf_setlock): Don't close waited lock object handle beforeCorinna Vinschen2012-02-141-2/+2
| | | | we own the node lock. Fix comment.
* Clean up whitespace.Christopher Faylor2011-12-171-1/+1
|
* Throughout, remove extra space after function name from debugging output.Christopher Faylor2011-12-031-2/+2
| | | | | | | | | | | | | | | Throughout, change syscalls to report on return values using new %R format option. * smallprint.cc (__small_vsprintf): Add parsing for %R to report on return values and possible errno from syscalls. * errno.cc (errmap): Add PRIVILEGE_NOT_HELD. * fhandler_tty.cc (fhandler_pty_master::setup): When creating a thread use shorter name to reduce debuggging output. * select.cc (start_thread_pipe): Ditto. (start_thread_serial): Ditto. (start_thread_socket): Ditto. (start_thread_mailslot): Ditto. * sigproc.cc (talktome): Ditto.
* * flock.cc (inode_t::unlock_and_remove_if_unused): Rename fromCorinna Vinschen2011-08-311-6/+6
| | | | unlock_and_remove.
* * flock.cc (LOCK_OBJ_NAME_LEN): Change to accommodate extra lf_verCorinna Vinschen2011-08-291-136/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | field. (class lockf_t): Add lf_ver field. (lockf_t::lockf_t): Initialize lf_ver to 0. (class inode_t): Change i_wait to i_cnt. Change comment to explain change in usage. (inode_t:use): Rename from wait. Make private. (inode_t::unuse): Rename from unwait. Make private. (inode_t::inuse): Rename from waiting. Make private. (inode_t::notused): New public method to set use count to 0. (inode_t::unlock_and_remove): New method to unlock node and to delete it if it's unused in current process. (fhandler_base::del_my_locks): Drop global list lock. Drop variable no_locks_left. Simpify unlocking and removing node by just calling unlock_and_remove. (fixup_lockf_after_exec): Call notused method for each node. (inode_t::get): Call use method. Lock node only if outside of list lock. (inode_t::get_all_locks_list): Accommodate additional lf_ver field when creating lockf_t structure from object name. (lockf_t::create_lock_obj_attr): Accommodate additional lf_ver field when creating object name from lockf_t structure. Handle STATUS_OBJECT_NAME_COLLISION gracefully in F_POSIX case as well. Change comment accordingly. Increment lf_ver field rather than high byte of lf_wid field. Simplify comment. (fhandler_disk_file::lock): Always call unlock_and_remove rather than just UNLOCK on node. (lf_setlock): Move ret definition where it's used. Drop unneeded tests for obj being not NULL. Only check for deadlock condition if the lock we're trying to establish is a POSIX lock. Revamp object collecting and wait code to cover all cases. Don't return with EDEADLK if blocking process can't be opened for synchronization in F_POSIX case, rather just wait like in F_FLOCK case. Change system_printf to debug_printf in that case. Only run WaitForMultipleObjects with high priority. Close obj and process handles prior to locking node.
* * fhandler.cc (fhandler_base::open): Fix typo in comment.Corinna Vinschen2011-08-271-89/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (fhandler_base::close): Move call to del_my_locks from here... * fhandler_disk_file.cc (fhandler_disk_file::open): ...to here. * flock.cc (struct lockfattr_t): New type. (lockf_t::close_lock_obj): New method, use throughout. (lockf_t::create_lock_obj_attr): New method. (lockf_t::create_lock_obj): Use create_lock_obj_attr method. Handle STATUS_OBJECT_NAME_COLLISION in F_FLOCK case gracefully. Add lengthy comments to explain why and how. (lockf_t::open_lock_obj): Use create_lock_obj_attr method. (lockf_t::del_lock_obj): Call NtSetEvent rather than SetEvent for symmetry. (fhandler_disk_file::lock): Define n only where it's used. Call need_fork_fixup only if call was successful. Handle EINTR and ECANCELED return values from lf_setlock. (lf_setlock): Drop WAIT_UNLOCKED and WAIT_PROC_EXITED. Don't wait for event object handle count to become <= 1 in F_LOCK case. Simplify WFMO return value handling. Don't handle signal and cancel events here; just return with appropriate error code instead. (lf_getblock): Ignore locks for which the handle can't be opened. Use IsEventSignalled. * ntdll.h (STATUS_INVALID_INFO_CLASS): Undef if defined elsewhere to make sure the definition is casted to NTSTATUS. (STATUS_INVALID_HANDLE): Define and ditto. (STATUS_OBJECT_NAME_COLLISION): Define. (NtSetEvent): Declare.
* whitespace eliminationChristopher Faylor2011-06-061-14/+14
|
* * fhandler_windows.cc (fhandler_windows::read): UseCorinna Vinschen2011-05-011-4/+1
| | | | | | | | 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.
* * fcntl.cc (fcntl64): Call pthread_testcancel.Corinna Vinschen2011-04-301-17/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* * advapi32.cc: Add comment.Corinna Vinschen2011-04-291-3/+4
| | | | | | | | | | | | | | | | | (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.
* * cygerrno.h (geterrno_from_nt_status): Declare.Corinna Vinschen2011-04-281-1/+1
| | | | | | | | | | | | | | | | | | | | | * 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.
* * advapi32.cc (InitializeAcl): Remove.Corinna Vinschen2011-04-281-2/+3
| | | | | | | | | | | | | | | | | (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.
* * flock.cc (allow_others_to_sync): Define MAX_PROCESS_SD_SIZE. UseCorinna Vinschen2010-09-101-2/+3
| | | | | | | | | | | instead of ACL_DEFAULT_SIZE. * sec_acl.cc (setacl): Use TLS buffer to allow maximum ACL size. * security.h (ACL_DEFAULT_SIZE): Drop definition. (ACL_MAXIMUM_SIZE): Define. (SD_MAXIMUM_SIZE): Define. * security.cc (get_file_sd): Allocate security_decscriptor with size SD_MAXIMUM_SIZE. (alloc_sd): Use TLS buffer to allow maximum ACL size.
* * flock.cc (allow_others_to_sync): Use small stack buffer ratherCorinna Vinschen2010-06-221-12/+12
| | | | | | than big temp buffer. Fix typo in comment. (lf_setlock): Revert to using tmp_pathbuf. (lf_getlock): Ditto.
* * tmpbuf.h: New file.Christopher Faylor2010-06-211-9/+10
| | | | | | | * flock.cc: Include tmpbuf.h for new tmpbuf functionality. (allow_others_to_sync): Use tmpbuf rather than tmp_pathbuf. Explain why. (lf_setlock): For consistency, use tmpbuf rather than tmp_pathbuf. (lf_getlock): Ditto.
* Throughout, replace hMainProc with GetCurrentProcess/NtCurrentProcessCorinna Vinschen2009-12-181-2/+3
| | | | | | | | | | | | according to context. Throughout, replace hMainThread with GetCurrentThread/NtCurrentThread according to context. * dcrt0.cc (dll_crt0_0): Drop duplication of GetCurrentProcess to hMainProc. Drop duplication of GetCurrentThread to hMainThread. * dtable.cc (dtable::stdio_init): Remove useless comment. * globals.cc (hMainProc): Remove. (hMainThread): Remove. * ntdll.h (NtCurrentProcess): Define. (NtCurrentThread: Define.
* * flock.cc (fhandler_disk_file::lock): Disable a shortcut from theCorinna Vinschen2009-11-181-0/+6
| | | | original BSD code, but keep it in and documented why we can't use it.
* * fhandler.h (enum del_lock_called_from): New enumeration.Corinna Vinschen2009-07-221-2/+12
| | | | | | | | | | | (fhandler_base::del_my_locks): Declare taking a del_lock_called_from as argument. * fhandler.cc (fhandler_base::close): Call del_my_locks with "on_close". (fhandler_base::fixup_after_fork): Call del_my_locks with "after_fork". (fhandler_base::fixup_after_exec): Call del_my_locks with "after_exec". * flock.cc (fhandler_base::del_my_locks): Take del_lock_called_from as argument. Call node->del_my_locks with NULL handle in after_exec case. Explain why.
* Throughout avoid having to initialize constant UNICODE_STRINGs.Corinna Vinschen2009-07-141-2/+1
| | | | | | | | | | | | | | | | | | | | | | * globals.cc: Define constant UNICODE_STRINGs and store in .rdata section. * fhandler_disk_file.cc: Throughout, use readonly UNICODE_STRINGs rather then initializing local UNICODE_STRING variable where applicable. * fhandler_mem.cc (fhandler_dev_mem::open): Ditto. * flock.cc (inode_t::inode_t): Ditto. * mmap.cc: Ditto. * syscalls.cc: Ditto. * mount.cc (fs_info::update): Ditto. * path.cc: Ditto. * ntdll.h (RtlEqualUnicodePathPrefix): Redefine to take prefix as UNICODE_STRING. (RtlEqualUnicodePathSuffix): Redefine to take suffix as UNICODE_STRING. * fhandler_disk_file.cc: Accommodate throughout. * mount.cc (fs_info::update): Ditto. * path.cc (cwdstuff::set): Ditto. * syscalls.cc: Ditto.
* * select.h: New file split from fhandler.h.Christopher Faylor2009-06-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (select_record::select_record): Define do-nothing constructor for "new" to avoid gratuitous zeroing. (select_info): New base class. (select_pipe_info): New class with methods for dealing with pipes. (select_socket_info): New class with methods for dealing with sockets. (select_serial_info): Dummy class for serial. (select_mailslot_info): Dummy class for mailslots. (select_stuff): Define device_specific_* as actual classes rather than void *. * dtable.h (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * dtable.cc (dtable::select_read): Accommodate return value change to 'bool' and argument change to "select_stuff". (dtable::select_write): Ditto. (dtable::select_except): Ditto. * fhandler.h: Excise select-related classes. (fhandler_*::select_read): Change argument to select_stuff. (fhandler_*::select_write): Ditto. (fhandler_*::select_except): Ditto. * select.cc (UNIX_FD_ZERO): Use memset rather than bzero. (select_stuff::test_and_set): Change return type to bool. Allocate select_record on entry and let fhandler_*::select_* operate on the start.next field of select_stuff. (pipeinf): Delete. (select_pipe_info::select_pipe_info): New constructor. Allocates event for controlling pipe waits. (select_pipe_info::~select_pipe_info): New destructor. Destroy event. Stop thread. (select_pipe_info::add_watch_handle): New function. (thread_pipe): Wait for the hEvent part of any overlapped pipes before peeking. (start_thread_pipe): Don't allocate device_specific_pipe stuff here. Assume that it has been allocated earlier. (pipe_cleanup): Rely on select_pipe_info destructor to clean up pipe paraphenalia. (fhandler_*::select_*): Derive select_record from new select_stuff argument. (fhandler_pipe::select_*): Ditto. Allocate pipe-specific field if not already allocated. (serialinf): Delete. (thread_serial): serialinf -> select_serial_info. (fhandler_base::ready_for_read): Rewrite to accommodate change in argument to fhandler_*::select_*. (socketinf): Delete. (thread_socket): socketinf -> select_socket_info. (mailslotinf): Delete. (thread_mailslot): mailslotinf -> select_mailslot_info.
* * flock.cc (lf_setlock): Handle border case which results in WFMO loopCorinna Vinschen2009-04-201-0/+8
| | | | | exiting with ret == WAIT_TIMEOUT gracefully. Add a system_printf to uncover other potential problems with WFMO loop.
* * flock.cc (class inode_t): Add i_wait member and matching methodsCorinna Vinschen2009-04-171-4/+14
| | | | | | | | | | wait(), unwait(), and waiting(). (inode_t::inode_t): Initialize i_wait to 0. (fhandler_disk_file::lock): Only remove node if no other thread is waiting for a blocking lock. (lf_setlock): Manipulate node->i_wait to signal that a thread is waiting for a blocking lock in this node. (lf_findoverlap): Reinstantiate SELF test as in original code.
* * flock.cc: Fix lockf copyright to latest version.Corinna Vinschen2009-03-131-12/+3
|