summaryrefslogtreecommitdiff
path: root/remote-cstms.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>1998-07-30 20:54:47 +0000
committerPaul Smith <psmith@gnu.org>1998-07-30 20:54:47 +0000
commite2403327e9913bbcbd515f9c38b8f4e26fb9b0d9 (patch)
tree8ac64ff471e0a976daf75ef913c084adba4972fc /remote-cstms.c
parent65a7296e2c81b04761b3f024572310a02c9de691 (diff)
downloadgunmake-e2403327e9913bbcbd515f9c38b8f4e26fb9b0d9.tar.gz
GNU make release 3.77.
Diffstat (limited to 'remote-cstms.c')
-rw-r--r--remote-cstms.c73
1 files changed, 55 insertions, 18 deletions
diff --git a/remote-cstms.c b/remote-cstms.c
index 6aa2c96..e1d63a3 100644
--- a/remote-cstms.c
+++ b/remote-cstms.c
@@ -21,15 +21,15 @@ along with GNU Make; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "make.h"
+#include "job.h"
+#include "filedef.h"
#include "commands.h"
#include "job.h"
#include <sys/time.h>
#include <netdb.h>
-#define __STRICT_BSD__ /* Don't make conflicting declarations. */
#include "customs.h"
-
char *remote_description = "Customs";
/* File name of the Customs `export' client command.
@@ -42,25 +42,47 @@ static ExportPermit permit;
/* Normalized path name of the current directory. */
static char *normalized_cwd;
+/* Call once at startup even if no commands are run. */
+
+void
+remote_setup ()
+{
+}
+
+/* Called before exit. */
+
+void
+remote_cleanup ()
+{
+}
+
/* Return nonzero if the next job should be done remotely. */
int
-start_remote_job_p ()
+start_remote_job_p (first_p)
+ int first_p;
{
static int inited = 0;
int status;
-
- /* Allow the user to turn off job exportation
- (useful while he is debugging Customs, for example). */
- if (getenv ("GNU_MAKE_NO_CUSTOMS") != 0)
- return 0;
+ int njobs;
if (!inited)
{
+ /* Allow the user to turn off job exportation (useful while he is
+ debugging Customs, for example). */
+ if (getenv ("GNU_MAKE_NO_CUSTOMS") != 0)
+ {
+ inited = -1;
+ return 0;
+ }
+
/* For secure Customs, make is installed setuid root and
Customs requires a privileged source port be used. */
make_access ();
+ if (debug_flag)
+ Rpc_Debug(1);
+
/* Ping the daemon once to see if it is there. */
inited = Customs_Ping () == RPC_SUCCESS ? 1 : -1;
@@ -87,6 +109,15 @@ start_remote_job_p ()
if (inited < 0)
return 0;
+ njobs = job_slots_used;
+ if (!first_p)
+ njobs -= 1; /* correction for being called from reap_children() */
+
+ /* the first job should run locally, or, if the -l flag is given, we use
+ that as clue as to how many local jobs should be scheduled locally */
+ if (max_load_average < 0 && njobs == 0 || njobs < max_load_average)
+ return 0;
+
status = Customs_Host (EXPORT_SAME, &permit);
if (status != RPC_SUCCESS)
{
@@ -113,8 +144,8 @@ start_remote_job (argv, envp, stdin_fd, is_remote, id_ptr, used_stdin)
int *id_ptr;
int *used_stdin;
{
- extern int vfork (), execve ();
char waybill[MAX_DATA_SIZE], msg[128];
+ struct hostent *host;
struct timeval timeout;
struct sockaddr_in sin;
int len;
@@ -150,8 +181,8 @@ start_remote_job (argv, envp, stdin_fd, is_remote, id_ptr, used_stdin)
/* Modify the waybill as if the remote child had done `child_access ()'. */
{
WayBill *wb = (WayBill *) waybill;
- wb->euid = wb->ruid;
- wb->rgid = wb->rgid;
+ wb->ruid = wb->euid;
+ wb->rgid = wb->egid;
}
/* Send the request to the server, timing out in 20 seconds. */
@@ -164,26 +195,31 @@ start_remote_job (argv, envp, stdin_fd, is_remote, id_ptr, used_stdin)
len, (Rpc_Opaque) waybill,
sizeof(msg), (Rpc_Opaque) msg,
1, &timeout);
+
+ host = gethostbyaddr((char *)&permit.addr, sizeof(permit.addr), AF_INET);
+
if (status != RPC_SUCCESS)
{
(void) close (retsock);
(void) close (sock);
- error ("exporting: %s", Rpc_ErrorMessage (status));
+ error ("exporting to %s: %s",
+ host ? host->h_name : inet_ntoa (permit.addr),
+ Rpc_ErrorMessage (status));
return 1;
}
else if (msg[0] != 'O' || msg[1] != 'k' || msg[2] != '\0')
{
(void) close (retsock);
(void) close (sock);
- error ("CUSTOMS_IMPORT: %s", msg);
+ error ("exporting to %s: %s",
+ host ? host->h_name : inet_ntoa (permit.addr),
+ msg);
return 1;
}
- else if (debug_flag)
+ else
{
- struct hostent *host = gethostbyaddr (&permit.addr, sizeof (permit.addr),
- AF_INET);
- printf ("Job exported to %s ID %u\n",
- host == 0 ? inet_ntoa (permit.addr) : host->h_name,
+ error ("*** exported to %s (id %u)",
+ host ? host->h_name : inet_ntoa (permit.addr),
permit.id);
}
@@ -225,6 +261,7 @@ start_remote_job (argv, envp, stdin_fd, is_remote, id_ptr, used_stdin)
(void) close (sock);
*is_remote = 0;
*id_ptr = pid;
+ *used_stdin = 1;
return 0;
}