Skip to content

support systems with long PIDs#486

Open
heni wants to merge 1 commit intoTelegramMessenger:masterfrom
heni:fix-long-pids
Open

support systems with long PIDs#486
heni wants to merge 1 commit intoTelegramMessenger:masterfrom
heni:fix-long-pids

Conversation

@heni
Copy link

@heni heni commented Oct 12, 2022

Current code fails when the kernel returns PIDs >= 65536. At my system (Ubuntu/20.04.4 LTS) it happens.
This simple patch fixes the problem in my case.

Related issue: #41

@dvershinin
Copy link

I now confirm that this patch 100% breaks installation on CentOS 7 and CentOS 8, at least. Nothing can connect to proxy when this patch is applied.

@heni
Copy link
Author

heni commented Mar 20, 2024

I now confirm that this patch 100% breaks installation on CentOS 7 and CentOS 8, at least. Nothing can connect to proxy when this patch is applied.

Could you please attach related server logs

@dvershinin
Copy link

dvershinin commented Mar 20, 2024

@heni there are literally no logs aside from the standard logging:

Mar 20 17:24:43 redacted-hostname systemd[1]: Started MTProxy.
Mar 20 17:24:43 redacted-hostname mtproxy[29440]: [29440][2024-03-20 17:24:43.400283 local] Invoking engine mtproxy-3.0.3-1.el7 compiled at Mar 22 2023 08:59:56 by gcc 8.3.1 20190311 (Red Hat 8.3.1-3) 64-bit after commit 1268005
Mar 20 17:24:43 redacted-hostname mtproxy[29440]: [29440][2024-03-20 17:24:43.400451 local] config_filename = '/usr/share/mtproxy/proxy-multi.conf'
Mar 20 17:24:43 redacted-hostname mtproxy[29440]: [29440][2024-03-20 17:24:43.400719 local] creating 1 workers
Mar 20 17:24:43 redacted-hostname mtproxy[29440]: [29440][2024-03-20 17:24:43.404977 local] Started as [redacted-ip:8888:29440:1710955483]
Mar 20 17:24:43 redacted-hostname mtproxy[29440]: [29441][2024-03-20 17:24:43.404989 local] Started as [redacted-ip:8888:29441:1710955483]
Mar 20 17:24:43 redacted-hostname mtproxy[29440]: [29440][2024-03-20 17:24:43.405189 local] configuration file /usr/share/mtproxy/proxy-multi.conf re-read successfully (797 bytes parsed), new configuration active
Mar 20 17:24:43 redacted-hostname mtproxy[29440]: [29440][2024-03-20 17:24:43.405215 local] main loop
Mar 20 17:24:43 redacted-hostname mtproxy[29440]: [29441][2024-03-20 17:24:43.405243 local] configuration file /usr/share/mtproxy/proxy-multi.conf re-read successfully (797 bytes parsed), new configuration active
Mar 20 17:24:43 redacted-hostname mtproxy[29440]: [29441][2024-03-20 17:24:43.405310 local] main loop

After these lines the proxy is defunct and nothing can connect to it. Merely reverting your patch and updating makes things work normally. Note: testing on my fork which integrates quite a few changes from others.

@SpriteOvO
Copy link

The field type in struct cannot be changed, since it is used in the protocol packets, user clients have already assumed that it is 16-bit not 32-bit. This is why the PR doesn't work for some people.

I would recommend patch it this way

--- a/common/pid.c
+++ b/common/pid.c
@@ -39,8 +39,7 @@ npid_t PID;
 void init_common_PID (void) {
   if (!PID.pid) {
     int p = getpid ();
-    assert (!(p & 0xffff0000));
-    PID.pid = p;
+    PID.pid = (unsigned short)p;
   }
   if (!PID.utime) {
     PID.utime = time (0);

But the best solution would be to select a other 16-bit unique ID for each MTProxy process.

CloudPassenger added a commit to CloudPassenger/MTProxy that referenced this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants