MOON
Server: Apache
System: Linux s5.yayogua.com.py 6.12.0-124.55.3.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:54:02 EDT 2026 x86_64
User: sanbercountryclu (1012)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: //lib/python3.12/site-packages/tuned/daemon/__pycache__/application.cpython-312.pyc
�

�]�i�����ddlmZmZmZmZmZmZmZddlm	Z	ddl
ZddlZddlm
Z
ddlmZddlZddlZddlZddlZddlZddlmZddlmZej0j3�ZdgZGd	�de�Zy)
�)�storage�units�monitors�plugins�profiles�exports�hardware)�TunedExceptionN�)�
controller)�daemon)�GlobalConfig�Applicationc��eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	e
jfd	�Zd
�Z
d�Ze
jfd�Zed
��Zed��Zd�Zy)rNc
��tjdtjj�dtj�d���d|_d|_tj�}tj|�}|�
t�n||_
|jjtj �rtjd�ntjd�t#j$�}|jj'dtj(�}t+j,|��}t+j.�}t+j0�}	t2j4j�}
t6j8j;�|_t3j$|||||	|
|j|j8�}t=|jj?tj@tjB��}tEjF|||||j�}
t7j�}t7jH�}t7jJ|jjMtjNtjP��}t7jR||||j|j8�}tUjV|
|||j|�|_,t[j\|jX|j�|_/|ja�d|_1y)NzTuneD: z
, kernel: �z8dynamic tuning is enabled (can be overridden in plugins)z#dynamic tuning is globally disabled�udev_buffer_size)�buffer_size)2�log�info�tuned�version�TUNED_VERSION_STR�os�uname�_dbus_exporter�_unix_socket_exporterr�PickleProvider�Factoryr�config�get_bool�consts�CFG_DYNAMIC_TUNINGr�
Repository�get_size�CFG_DEF_UDEV_BUFFER_SIZEr	�	Inventory�
DeviceMatcher�DeviceMatcherUdevr�instancer�	variables�	Variables�int�get�CFG_DEFAULT_INSTANCE_PRIORITY�!CFG_DEF_DEFAULT_INSTANCE_PRIORITYr�Manager�Merger�Locator�get_list�CFG_PROFILE_DIRS�CFG_DEF_PROFILE_DIRS�Loaderr
�Daemon�_daemonr�
Controller�_controller�
_init_signals�	_pid_file)�self�profile_namer �storage_provider�storage_factory�monitors_repositoryr�hardware_inventory�device_matcher�device_matcher_udev�plugin_instance_factory�plugins_repository�def_instance_priority�unit_manager�profile_factory�profile_merger�profile_locator�profile_loaders                  �=/usr/lib/python3.12/site-packages/tuned/daemon/application.py�__init__zApplication.__init__sQ���(�(�e�m�m�&E�&E�r�x�x�z�RS�}�U�V��$��#�$���+�+�-���O�O�$4�5�/�"(�.���f�$�+�	�[�[���&�3�3�4��8�8�F�G��8�8�1�2� �+�+�-���[�[�)�)�*<�f�>]�>]�^���)�)�6F�G���)�)�+�.� �2�2�4��#�,�,�4�4�6���%�%�/�/�1�$�.��)�)�*=��Pb��&�(?����d�n�n�^���d�k�k�o�o�f�.R�.R�TZ�T|�T|�}�~������+��-�t�{�{�<�,��$�$�&�/��?�?�$�.��$�$�T�[�[�%9�%9�&�:Q�:Q�SY�Sn�Sn�%o�p�/��?�?�?�O�^�UY�U`�U`�bf�bp�bp�q�.����|�^�\�4�;�;�X\�]�$�,��*�*�4�<�<����E�$�������$�.�c�@�����fd�}tj�|�y)Nc� ���|k(r��yy�N�)�_signal_number�_frame�handler�
signal_numbers  ��rN�handler_wrapperz3Application._handle_signal.<locals>.handler_wrapper@s����~�%��I�&rP)�signal)r>rXrWrYs `` rN�_handle_signalzApplication._handle_signal?s����	�-�-�
��/rPc�<�|jtj|jj�|jtj
|jj�|jtj|jj�yrS)r[rZ�SIGHUPr;�sighup�SIGINT�	terminate�SIGTERM�r>s rNr<zApplication._init_signalsEsb�����f�m�m�T�%5�%5�%<�%<�=����f�m�m�T�%5�%5�%?�%?�@����f�n�n�d�&6�&6�&@�&@�ArPc��|j�td��tjj	||||�|_tj
|j�y)Nz&DBus interface is already initialized.)rr
r�dbus�DBusExporter�register_exporter)r>�bus_name�object_name�interface_name�	namespaces     rN�attach_to_dbuszApplication.attach_to_dbusJsL��	���$�	�@�	A�A����1�1�(�N�K�Yb�c�$��	���D�/�/�0rPc	�F�|j�td��tjj	|j
j
tj�|j
jtj�|j
j
tj�|j
jtj�|j
jtj��|_tj|j�y)Nz-Unix socket interface is already initialized.)rr
r�unix_socket�UnixSocketExporterr r.r"�CFG_UNIX_SOCKET_PATHr4�CFG_UNIX_SOCKET_SIGNAL_PATHS�CFG_UNIX_SOCKET_OWNERSHIP�get_int�CFG_UNIX_SOCKET_PERMISIONS�#CFG_UNIX_SOCKET_CONNECTIONS_BACKLOGrfrbs rN�attach_to_unix_socketz!Application.attach_to_unix_socketQs���	���+�	�G�	H�H�&�2�2�E�E�d�k�k�o�o�V\�Vq�Vq�Fr��;�;�'�'��(K�(K�L��;�;�?�?�6�#C�#C�D��;�;�&�&�v�'H�'H�I��;�;�&�&�v�'Q�'Q�R�	 T�$��

���D�6�6�7rPc�B�tj|j�yrS)r�register_objectr;rbs rN�register_controllerzApplication.register_controller\s��	���$�*�*�+rPc��tj|�tj|gggtj�\}}}t|�dk7r tj|�t
d��tj|d�}tj|�t|�dk(rt
d��	tjd|�d}|dk7rt
d	��y
#tj$rt
d��wxYw)z|
		Wait till the child signalizes that the initialization is complete by writing
		some uninteresting data into the pipe.
		rz=Cannot daemonize, timeout when waiting for the child process.�rz:Cannot daemonize, no response from child process received.�?z?Cannot daemonize, invalid response from child process received.Tz0Cannot daemonize, child process reports failure.N)r�close�selectr"�DAEMONIZE_PARENT_TIMEOUT�lenr
�read�struct�unpack�error)r>�parent_in_fd�child_out_fd�
read_ready�drop�response�vals       rN�_daemonize_parentzApplication._daemonize_parent_s���
�(�(�<��#�]�]�L�>�2�r�6�Cb�Cb�c��:�t�T���_����8�8�L��	�W�	X�X�
�W�W�\�1�
%�(��(�(�<����]�a��	�T�	U�U�[�	���s�H�	%�a�	(�3�	�D�[�	�J�	K�K���
���[�	�Y�	Z�Z�[�s�4C�C=c	���||_|j�	tjj	|j�}tjj|�stj|�tjtj|jtjtjztjzd�d�5}|jdtj�z�ddd�y#1swYyxYw#ttf$r8}t j#d|j�dt%|����Yd}~yd}~wwxYw)Ni��wz%dzcannot write the PID to z: )r=�_delete_pid_filer�path�dirname�exists�makedirs�fdopen�open�O_CREAT�O_TRUNC�O_WRONLY�write�getpid�OSError�IOErrorr�critical�str)r>�pid_file�dir_name�fr�s     rN�write_pid_filezApplication.write_pid_filexs����$�.�����Q��g�g�o�o�d�n�n�-�8�
�'�'�.�.��
"��K�K���
�	�	�"�'�'�$�.�.�"�*�*�R�Z�Z�*?����*K�e�T�VY�Z�^_��G�G�D�2�9�9�;���	[�Z�Z��
�'�	�Q��<�<�D�N�N�C��J�O�P�P��Q�s6�CD�'D�D�D�D�D�E�&.E�Ec	� �tjj|j�r!	tj|j�yy#t
$r8}tjd|j�dt|����Yd}~yd}~wwxYw)Nz cannot remove existing PID file z, )	rr�r�r=�unlinkr�r�warningr�)r>r�s  rNr�zApplication._delete_pid_file�sb���W�W�^�^�D�N�N�#�Y��I�I�d�n�n��$���Y��K�K�D�N�N�C�PU�J�W�X�X��Y�s�A�	B
�.B�B
c�j�tj|�tjd�tj�tjd�	tj
�}|dkDrt
jd�t!dd	�}tj"|j%�tj&j%��tj"|j%�tj(j%��tj"|j%�tj*j%��|j-|�tj/d
�tjdd�}tj||�tj|�y#t$rr}tjdt|�z�tjdd�}tj||�tj|�td��d}~wwxYw)zy
		Finishes daemonizing process, writes a PID file and signalizes to the parent
		that the initialization is complete.
		�/rz"cannot daemonize, fork() error: %sr{Fz'Cannot daemonize, second fork() failed.Nz	/dev/nullzw+zsuccessfully daemonizedT)rr|�chdir�setsid�umask�fork�sys�exitr�rr�r�r��packr�r
r��dup2�fileno�stdin�stdout�stderrr��debug)r>r�r�r��pidr�r��fds        rN�_daemonize_childzApplication._daemonize_child�sh��
�(�(�<���(�(�3�-��)�)�+��(�(�1�+�	C�	����3�	�A�g��H�H�Q�K��K���"��'�'�"�)�)�+�s�y�y�'�'�)�*��'�'�"�)�)�+�s�z�z�(�(�*�+��'�'�"�)�)�+�s�z�z�(�(�*�+����h���)�)�%�&����C���#��(�(�<����(�(�<���#
�C��<�<�4�s�5�z�A�B�	���S�%�	 �3��8�8�L�#���8�8�L��	�A�	B�B��C�s�.F7�7	H2�A-H-�-H2c��tj�}	tj�}	|dkDr%|j|�tjd�y|j|g|���y#t$r@}tj|d�tj|d�td��d}~wwxYw#|dkDr�tjd�YyxYw)z�
		Daemonizes the application. In case of failure, TunedException is raised
		in the parent process. If the operation is successfull, the main process
		is terminated and only child process returns from this method.
		rrz Cannot daemonize, fork() failed.N)
r�piper�r�r|r
r�r�r�r�)r>r��parent_child_fds�	child_pidr�s     rN�	daemonizezApplication.daemonize�s����W�W�Y��<��w�w�y�9���!�m��D���,�-��H�H�Q�K��D���(�6�%5�6��
�<��8�8��Q�� ��8�8��Q�� �	�:�	;�;��<����!�m�	��H�H�Q�K�s(�A)�)B5�B5�)	B2�2;B-�-B2�5Cc��|jSrS)r9rbs rNr
zApplication.daemon�s��	
���rPc��|jSrS)r;rbs rNrzApplication.controller�s��	
�	�	�rPc��|r*|jjtjd�|jj	tjtj
�stjd�|jj�}|jj	tjtj
�rtj�|j�|j�|S)NTzrUsing one shot no daemon mode, most of the functionality will be not available, it can be changed in global config)r �setr"�
CFG_DAEMONr!�CFG_DEF_DAEMONrr�r;�runr�stopr=r�)r>r
�results   rNr�zApplication.run�s�����;�;�?�?�6�$�$�d�+�	
���	�	�f�/�/��1F�1F�	G��;�;�D�E������!�&�	�[�[���&�+�+�V�-B�-B�C�
�<�<�>�	�^�^������	�-rP)NN)�__name__�
__module__�__qualname__rOr[r<rkrurxr�r"�PID_FILEr�r�r�r��propertyr
rr�rTrPrNrrs~��)�V0�B�
1�	8�,�L�2&,�_�_�Q�Y� �D!'����6��������
rP)rrrrrrrr	�tuned.exceptionsr
�
tuned.logs�
tuned.version�rr
rZrr�r}r��tuned.constsr"�tuned.utils.global_configr�logsr.r�__all__�objectrrTrPrN�<module>r�sW��P�P�P�+�����
�	�
�
�
��2��j�j�n�n����/��K�&�KrP