From a198d898e86d9950bbe87cd22df06eecee1709e1 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Fri, 17 May 2013 16:16:17 -0600 Subject: [PATCH] TT RPC server: Don't search 538 million transients trying to allocate one. Currently, mp_rpc_server.C tries 538 million ports to acquire an available transient rpcbind port number. This is bad when rpcbind is running in secure mode (and you are not using tirpc) - Xsession will 'hang' at the dthello (blue) screen filling up your error logs with RPC errors. Now, just try +- 50 (for a total of 100 ports) before bailing. The dthello 'blue screen of death' is the most common problem in starting CDE when rpcbind isn't set up properly. This should at least not cause the appearance of a 'hang'. --- cde/lib/tt/slib/mp_rpc_server.C | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cde/lib/tt/slib/mp_rpc_server.C b/cde/lib/tt/slib/mp_rpc_server.C index 1ed95468..8292c86f 100644 --- a/cde/lib/tt/slib/mp_rpc_server.C +++ b/cde/lib/tt/slib/mp_rpc_server.C @@ -417,8 +417,19 @@ gettransient(int proto, int vers, int *sockp) // if you try to grab a number for udp and we have it grabbed // for tcp). - // search up in the range 0x4fffffff - 0x5fffffff - for (prognum = 0x4fffffff; prognum <= 0x5fffffff; prognum++) { + // JET - this is way too many pnums to search, and causes what + // appears to be an infinite loop (though it isn't) if the + // user is running an rpcbind in secure mode and not using + // libtirpc - a common error. The end result is staring at + // the dthello welcome screen. So - rather than search this + // immense space, we will only search from start to +-50 + // before bailing. If a hundred attmepts to get a transient + // fail, I don't see that doing approximately 537 million + // attempts are worth it :) +#define MAX_TRANS_RANGE 50 + + // search up in the range 0x4fffffff to 0x4fffffff + MAX_TRANS_RANGE + for (prognum = 0x4fffffff; prognum <= (0x4fffffff + MAX_TRANS_RANGE); prognum++) { /* XXX: pmap_set allows the same prognum for different */ /* protocols so we hack around that by attemptint to */ /* set both tcp and udp. */ @@ -447,7 +458,7 @@ gettransient(int proto, int vers, int *sockp) } // search down in the range 0x4ffffffe - 0x40000000 - for (prognum = 0x4ffffffe; prognum >= 0x40000000; prognum--) { + for (prognum = 0x4ffffffe; prognum >= (0x4ffffffe - MAX_TRANS_RANGE); prognum--) { /* XXX: pmap_set allows the same prognum for different */ /* protocols so we hack around that by attemptint to */ /* set both tcp and udp. */ -- 2.25.1