§ WèÄjeãó´—ddlZddlZddlmZddlmZddlmZddl m Z m Z ddl m Z ddlmZmZmZejd ¦«ZeGd „d ¦«¦«ZdS) éN)Ú dataclass)ÚOptional)Úgettexté)Úfpm_stat_storageÚfpm_reload_timeout)Ú XRayError)Ú dbm_storageÚfilelockÚ timestampÚ fpm_utilscóp—eZdZUdZeed<edeefd„¦«Z d„Z de fd„Z de fd„Zde fd„Zd S) ÚFPMReloadControllerzA Class to control the frequency of FPM service reloading Ú fpm_serviceÚreturncór— tt¦«5} t||j ¦«¦«cddd¦«S#t $rYddd¦«dSwxYw#1swxYwYdS#t $r3}ttd¦«t|¦«zd¬¦«‚d}~wwxYw)zC Get the timestamp of latest reload of FPM service Nz4Failed to get the timestamp of latest FPM reload: %sÚwarning©Úflag) r rÚintrÚdecodeÚKeyErrorÚ RuntimeErrorr Ú_Ústr©ÚselfÚ_fpm_reload_statÚes úN/opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/internal/fpm_utils.pyÚ latest_reloadz!FPMReloadController.latest_reloads7€ð  pÝÕ-Ñ.Ô.ð Ð2Bð ÝÐ/°Ô0@ÔA×HÒHÑJÔJÑKÔKð ð ð ð ñ ô ð ð øõ ð ð ð Øð  ð ð ñ ô ð ð ð ð øøøð ð ð ð øøøð ð ð ð ð ð øõ ð pð pð pÝ�AÐTÑUÔUÕX[Ð\]ÑX^ÔX^Ñ^ÐenÐoÑoÔoÐ oøøøøð pøøøs]‚A9–A,˜+AÁ A9Á A)ÁA,Á A9Á(A)Á)A,Á,A0Á0A9Á3A0Á4A9Á9 B6Â.B1Â1B6có(— tt¦«5}tt¦«¦«||j<ddd¦«dS#1swxYwYdS#t $r3}t td¦«t|¦«zd¬¦«‚d}~wwxYw)zD Save the timestamp of latest reload of FPM service NzQFailed to save the timestamp of latest FPM reload %s, but main operation executedrr)r rrr rrr rrs r Úsave_latest_reloadz&FPMReloadController.save_latest_reload+sù€ð åÕ-Ñ.Ô.ð FÐ2BÝ58½¹¼Ñ5EÔ5EÐ  Ô!1Ñ2ð Fð Fð Fñ Fô Fð Fð Fð Fð Fð Fð Fð Føøøð Fð Fð Fð Fð Fð Føåð ð ð ÝÝÐeÑfÔfÕilÐmnÑioÔioÑoØðñôð øøøøð øøøs9‚A–$Aº AÁA Á AÁA ÁAÁ BÁ.B  Bcóf— t¦«|jz dz S#ttf$rYdSwxYw)zM Get the time delta between current time and saved timestamp é<gN@)r r!Ú TypeErrorr ©rs r ÚdeltazFPMReloadController.delta9sI€ð õ‘K”K $Ô"4Ñ4¸Ñ:Ð :øÝ�9Ð%ð ð ð ð�4�4ð øøøs ‚›0¯0có<—| ¦«tkS)z7 Check if FPM reload should be blocked )r(rr's r ÚrestrictzFPMReloadController.restrictFs€ð�zŠz‰|Œ|Õ1Ò1Ð1ócó—t›d|j›d�} tj|tjtjztjzd¦«}n4#t$r'}t  d||¦«Yd}~dSd}~wwxYw t|¦«5|  ¦«r" ddd¦«tj |¦«dS|  ¦« ddd¦«tj |¦«dS#1swxYwYnM#t$r@}t  d|j|¦«Yd}~tj |¦«dSd}~wwxYw tj |¦«dS#tj |¦«wxYw) aø Atomically decide whether THIS caller may perform the throttled reload and, if so, reserve the slot before returning. ``restrict`` (the check) and ``save_latest_reload`` (the reserve) must run as a single critical section shared across processes. Otherwise several concurrent user-mode user-agent processes can each observe an expired window, all pass the check, and each run the service reload -- preserving the server-wide DoS this throttle is meant to close (a tenant who owns a mod_php DirectAdmin domain firing N parallel start/stop requests triggers N global `service httpd restart`s). A cross-process exclusive flock makes check-and-reserve atomic: at most one caller per window records the timestamp and returns True; the losers re-read the just-saved timestamp under the same lock and return False. Reserve-before-act (the timestamp is saved BEFORE the reload runs, not after) is deliberate: the reservation must be visible to concurrent callers immediately, and a reload that later fails should still consume the window (the throttle errs toward FEWER restarts). Root/operator callers do not use this method -- they are never throttled. Returns True if the slot was reserved (caller must proceed with the reload); False if throttled (caller must skip). Any lock/storage failure fails safe (returns False) rather than risk an unthrottled restart. ú.z.locki€z!Failed to open reload lock %s: %sNFTz(Failed to reserve reload slot for %s: %s)rrÚosÚopenÚO_CREATÚO_RDWRÚ O_CLOEXECÚOSErrorÚloggerrr r*Úcloser#r )rÚ lock_pathÚlock_fdrs r Úreserve_reload_slotz'FPMReloadController.reserve_reload_slotLsù€õ4%5Ð$4Ð$4°dÔ6FÐ6FÐ6FÐGˆ ð Ý”g˜i­¬µb´iÑ)?Å"Ä,Ñ)NÐPUÑVÔVˆGˆGøÝð ð ð Ý �NŠNÐ>À È1Ñ MÔ MÐ MØ�5�5�5�5�5øøøøð øøøð ݘ'Ñ"Ô"ð ð Ø—=’=‘?”?ð!Ø ð ð ð ñ ô ð õ ŒH�WÑ Ô Ð Ð Ð ð×'Ò'Ñ)Ô)Ð)Øð  ð ð ñ ô ð õ ŒH�WÑ Ô Ð Ð Ð ð ð ð ð øøøð ð ð ð ð øõ ð ð ð å �NŠNÐEÀtÔGWÐYZÑ [Ô [Ð [Ø�5�5�5å ŒH�WÑ Ô Ð Ð Ð øøøøð  øøøð  õ ŒH�WÑ Ô Ð Ð Ð ø�BŒH�WÑ Ô Ð Ð øøøsw”:AÁ BÁA;Á;BÂD ÂDÂ) D à Dà D ÄDÄD ÄDÄD Ä E0Ä EÄ!EÄ7E0ÅEÅE0Å0FN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚ__annotations__Úpropertyrrr!r#Úfloatr(Úboolr*r8©r+r rrs¼€€€€€€ðððÐÐÑà ð p˜x¨œ}ð pð pð pñ„Xð pð ð ð ð �uð ð ð ð ð2˜$ð2ð2ð2ð2ð + Tð+ð+ð+ð+ð+ð+r+r)Úloggingr.Ú dataclassesrÚtypingrÚxrayrrÚ constantsrrÚ exceptionsr Úutilsr r r Ú getLoggerr4rrAr+r úrJsñðð€€€Ø € € € Ø!Ð!Ð!Ð!Ð!Ð!ØÐÐÐÐÐàÐÐÐÐÐØ;Ð;Ð;Ð;Ð;Ð;Ð;Ð;Ø!Ð!Ð!Ð!Ð!Ð!Ø3Ð3Ð3Ð3Ð3Ð3Ð3Ð3Ð3Ð3à ˆÔ ˜;Ñ 'Ô '€ð ðaðaðaðaðañaôañ „ðaðaðar+