MTProxy icon indicating copy to clipboard operation
MTProxy copied to clipboard

support systems with long PIDs

Open heni opened this issue 3 years ago • 4 comments

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

heni avatar Oct 12 '22 19:10 heni

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.

dvershinin avatar Mar 20 '24 17:03 dvershinin

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

heni avatar Mar 20 '24 17:03 heni

@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.

dvershinin avatar Mar 20 '24 17:03 dvershinin

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.

SpriteOvO avatar May 03 '24 11:05 SpriteOvO