From 77ebaecf895b8b863e3e80382bd6ec0e18305dcd Mon Sep 17 00:00:00 2001 From: chatty Date: Tue, 27 Jul 1993 13:51:56 +0000 Subject: Incorporated changes from mbl@prl and mbl@europarc --- comm/OLD/PortServer.cc | 85 ++++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 38 deletions(-) (limited to 'comm/OLD') diff --git a/comm/OLD/PortServer.cc b/comm/OLD/PortServer.cc index db4b020..3c7d0a5 100644 --- a/comm/OLD/PortServer.cc +++ b/comm/OLD/PortServer.cc @@ -24,6 +24,11 @@ #include #include +#define DEFKEY "%s:" + +// *** horrible patch +bool PortServerInquireSysError = FALSE; + /*?class UchPortServer The class \typ{UchPortServer} described here implements the communication with the port server. Both servers and clients need to use this class. @@ -51,7 +56,8 @@ UchPortServer :: UchPortServer (const char* serv, const char* host) if (port) portno = atoi (port); else - Error (ErrFatal, "getservbyname", "service not available"); + portno = 3003; +// Error (ErrFatal, "getservbyname", "service not available"); } /* open datagram socket */ @@ -121,22 +127,13 @@ UchPortServer :: Remove (const char* key, UchInetAddress& addr, int id) SendRequest (Serv, req); } -#if 0 -static jmp_buf JmpTimeOut; - -static void -Timeout (int) -{ - longjmp (JmpTimeOut, 1); -} -#else static bool expired = FALSE; static void Expire (Millisecond) { expired = TRUE; } -#endif + /*? Get a server address from the port server. @@ -152,20 +149,12 @@ This function is to be used by clients to retrieve the address of the server the UchInetAddress* UchPortServer :: Inquire (const char* key, int timeout) { +// *** horrible patch +PortServerInquireSysError = FALSE; UchPortServerReq req (PortServInquire, 0, 0, 0, MakeKey (key)); SendRequest (Serv, req); UchMsgBuffer buf (256); -#if 0 - if (setjmp (JmpTimeOut)) { - alarm (0); - Error (ErrWarn, "UchPortServer::Inquire", "timeout"); - return 0; - } - signal (SIGALRM, Timeout); - alarm (timeout); - int n = Serv->Receive (buf); - alarm (0); -#else + expired = FALSE; CcuTimer timer (timeout * 1000, Expire); int n = Serv->Receive (buf); @@ -173,9 +162,11 @@ UchPortServer :: Inquire (const char* key, int timeout) Error (ErrWarn, "UchPortServer::Inquire", "timeout"); return 0; } -#endif + if (n <= 0) { SysError (ErrWarn, "Inquire"); +// *** horrible patch +PortServerInquireSysError = TRUE; return 0; } if (! buf.Get (&req)) { @@ -215,25 +206,15 @@ UchPortServer :: Match (const char* key, PortServMatchFun f, int timeout) UchMsgBuffer buf (1024); for (;;) { buf.Flush (); -#if 0 - if (setjmp (JmpTimeOut)) { - alarm (0); - Error (ErrWarn, "UchPortServer::Match", "timeout"); - return 0; - } - signal (SIGALRM, Timeout); - alarm (timeout); - int n = Serv->Receive (buf); - alarm (0); -#else expired = FALSE; CcuTimer timer (timeout * 1000, Expire); int n = Serv->Receive (buf); + if (expired) { Error (ErrWarn, "UchPortServer::Match", "timeout"); return 0; } -#endif + if (n <= 0) { SysError (ErrWarn, "Match"); break; @@ -359,9 +340,19 @@ Be sure however that the address is an internet address (and not a Unix address void PortServerRegister (const char* service, const char* name, UchInetAddress& addr) { +#if 0 UchPortServer ps (service); +#else + UchPortServer ps ("agentman"); +#endif + char key [256]; - strcpy (key, "%s:%u:"); +#if 0 + strcpy (key, DEFKEY); +#else + strcpy (key, service); + strcpy (key, name); +#endif strcat (key, name); ps.Register (key, addr, getpid ()); } @@ -385,9 +376,18 @@ Be sure however that the address is an internet address (and not a Unix address void PortServerRemove (const char* service, const char* name, UchInetAddress& addr) { +#if 0 UchPortServer ps (service); +#else + UchPortServer ps ("agentman"); +#endif char key [256]; - strcpy (key, "%s:%u:"); +#if 0 + strcpy (key, DEFKEY); +#else + strcpy (key, service); + strcpy (key, name); +#endif strcat (key, name); ps.Remove (key, addr, getpid ()); } @@ -400,9 +400,18 @@ It connects to the port server on the given host (default is local). UchInetAddress* PortServerInquire (const char* service, const char* name, const char* host) { +#if 0 UchPortServer ps (service, (host && *host) ? host : 0); +#else + UchPortServer ps ("agentman", (host && *host) ? host : 0); +#endif char key [256]; - strcpy (key, "%s:%u:"); +#if 0 + strcpy (key, DEFKEY); +#else + strcpy (key, service); + strcpy (key, name); +#endif strcat (key, name); return ps.Inquire (key); } -- cgit v1.1