File: //opt/saltstack/salt/lib/python3.10/site-packages/cheroot/__pycache__/connections.cpython-310.pyc
o
�N�g�3 � @ s. d Z ddlmZmZmZ eZddlZddlZddl Z ddl
Z
ddlZddlm
Z
ddlmZ ddlmZ ddlmZ ddlZzddlZW n> ey� z#dd lmZmZ ddlZejjZejjejjejjge_ ejj!e_"W n
ey{ d
d� Z#Y nw dd� Z#Y nw d
d� Z#G dd� d�Z$G dd� d�Z%dS )z%Utilities to manage open connections.� )�absolute_import�division�print_functionN� )�errors)� selectors)�suppress)�MakeFile)�windll�WinErrorc C s dS )ztStub inheritance prevention.
Dummy function, since neither fcntl nor ctypes are available.
N� ��sockr r �G/opt/saltstack/salt/lib/python3.10/site-packages/cheroot/connections.py�prevent_socket_inheritance! s r c C s t | �� dd�st� �dS )z6Mark the given socket fd as non-inheritable (Windows).r r N)�_SetHandleInformation�filenor r
r r r r ( s �c C s0 | � � }t�|tj�}t�|tj|tjB � dS )z4Mark the given socket fd as non-inheritable (POSIX).N)r �fcntl�F_GETFD�F_SETFD�
FD_CLOEXEC)r �fdZ old_flagsr r r r - s c @ sP e Zd ZdZdd� Zdd� Zedd� �Zdd d
�Zdd� Z dd
d�Z
dd� ZdS )�_ThreadsafeSelectora� Thread-safe wrapper around a DefaultSelector.
There are 2 thread contexts in which it may be accessed:
* the selector thread
* one of the worker threads in workers/threadpool.py
The expected read/write patterns are:
* :py:func:`~iter`: selector thread
* :py:meth:`register`: selector thread and threadpool,
via :py:meth:`~cheroot.workers.threadpool.ThreadPool.put`
* :py:meth:`unregister`: selector thread only
Notably, this means :py:class:`_ThreadsafeSelector` never needs to worry
that connections will be removed behind its back.
The lock is held when iterating or modifying the selector but is not
required when :py:meth:`select()ing <selectors.BaseSelector.select>` on it.
c C s t �� | _t�� | _d S �N)r �DefaultSelector� _selector� threading�Lock�_lock��selfr r r �__init__H s
z_ThreadsafeSelector.__init__c C s<