aboutsummaryrefslogtreecommitdiff
path: root/src/Redirect.c
diff options
context:
space:
mode:
authortradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2001-05-21 22:00:21 +0000
committertradke <tradke@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2001-05-21 22:00:21 +0000
commit9d16a4d11ced1a08cf3f763beefd73b9d0f04405 (patch)
tree0da095341f1692488fda175e39e2d39df60c2aa4 /src/Redirect.c
parentcffd0ee596d8344c3e26185887c78246906adb98 (diff)
Print info message if an address gets redirected.
Switched off debugging output. git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@131 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'src/Redirect.c')
-rw-r--r--src/Redirect.c158
1 files changed, 87 insertions, 71 deletions
diff --git a/src/Redirect.c b/src/Redirect.c
index c987eaa..b7b7139 100644
--- a/src/Redirect.c
+++ b/src/Redirect.c
@@ -2,20 +2,24 @@
@file Redirect.c
@date Fri May 18 10:03:15 2001
@author Tom Goodale
- @desc
- File to contain John Shalf's HTTP redirect stuff.
+ @desc
+ File to contain John Shalf's HTTP redirect stuff.
@enddesc
- @version $Header$
+ @version $Id$
@@*/
-#include "cctk.h"
-
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "cctk.h"
#ifdef CCTK_MPI
-#include "mpi.h"
+#include <mpi.h>
#endif /* CCTK_MPI */
+#include "util_Network.h" /* Util_GetHostName() */
+
#include "httpd.h"
#include "http_Request.h"
@@ -57,18 +61,18 @@ static char httpmaster[1024];
@routine HTTP_SetupRedirect
@date Wed April 20 20:39:15 2001
@author John Shalf
- @desc
+ @desc
Creates a socket to listen on purely for server redirect to the root node.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
@@*/
-int HTTP_SetupRedirect(int port,
+int HTTP_SetupRedirect(int port,
int queue_size,
int hunt)
{
@@ -84,10 +88,12 @@ int HTTP_SetupRedirect(int port,
addrlen = 1024;
nprocs = CCTK_nProcs(NULL);
proc = CCTK_MyProc(NULL);
-
+
retval = 0;
+#ifdef HTTPD_DEBUG
CCTK_INFO("enter setup redirect------------");
+#endif
memset(hostnm,0,addrlen);
Util_GetHostName(hostnm, addrlen);
alladdr=(char*)malloc(addrlen * nprocs);
@@ -95,23 +101,31 @@ int HTTP_SetupRedirect(int port,
#ifdef CCTK_MPI
{ /* push stack */
+#ifdef HTTPD_DEBUG
CCTK_INFO("all gather");
+#endif
MPI_Allgather(hostnm,addrlen,MPI_CHAR,
- alladdr,addrlen,MPI_CHAR,
- MPI_COMM_WORLD);
+ alladdr,addrlen,MPI_CHAR,
+ MPI_COMM_WORLD);
+#ifdef HTTPD_DEBUG
CCTK_INFO("collected");
+#endif
}
#endif
/* set our master */
+#ifdef HTTPD_DEBUG
printf("alladdr is %s\n", alladdr);
+#endif
strcpy(httpmaster,alladdr); /* the 0th element is the master hostname */
/* so compare my addr to the list sequentially */
for(i=0;i<nprocs;i++)
{
+#ifdef HTTPD_DEBUG
printf("Cycle through %u\n",i);
+#endif
if(!strcmp(alladdr+i*addrlen,hostnm))
{
/* we matched addresses */
@@ -122,11 +136,15 @@ int HTTP_SetupRedirect(int port,
else
{
/* otherwise, I am the lowest ranked processor with this
- address that isn't the primary webserver. So
- I should do a server redirect */
+ address that isn't the primary webserver. So
+ I should do a server redirect */
httpredirect=1; /* this has a redirect socket */
HTTP_SetupServer(port,queue_size,hunt);
-
+
+ CCTK_VInfo(CCTK_THORNSTRING, "HTTP requests will be redirected to "
+ "primary webserver node on\n http://%s:%d/",
+ HTTP_Master(), (unsigned int) HTTP_Port());
+
RegisterRedirect();
retval = 1;
}
@@ -134,26 +152,28 @@ int HTTP_SetupRedirect(int port,
}
if(! retval)
{
+#ifdef HTTPD_DEBUG
CCTK_INFO("No Redirect**************\n");
+#endif
httpredirect=0;
}
- return retval;
+ return retval;
}
/*@@
@routine HTTP_Master
@date Friday April 20 11:24:40 2001
@author John Shalf
- @desc
+ @desc
Reports the hostname of the node the HTTP server is listening on.
The returns the hostname of the master as a string.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
@@*/
const char *HTTP_Master(void)
{
@@ -164,14 +184,14 @@ const char *HTTP_Master(void)
@routine HTTP_IsServer
@date Friday April 20 11:24:40 2001
@author John Shalf
- @desc
- True if this node has a server socket open.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
+ @desc
+ True if this node has a server socket open.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
@@*/
int HTTP_IsServer(void)
{
@@ -182,16 +202,16 @@ int HTTP_IsServer(void)
@routine HTTP_IsRedirect
@date Friday April 20 11:24:40 2001
@author John Shalf
- @desc
- True only if this node has a server open and that server
- is exclusively used to redirect web traffic back to the root
+ @desc
+ True only if this node has a server open and that server
+ is exclusively used to redirect web traffic back to the root
node.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
@@*/
int HTTP_IsRedirect(void)
{
@@ -200,15 +220,15 @@ int HTTP_IsRedirect(void)
#if 0 /* this would be more efficient, but PUGH doesn't define
- a datatype for 8-byte integers. So instead,
- setupRedirect will use the actual hostname. */
+ a datatype for 8-byte integers. So instead,
+ setupRedirect will use the actual hostname. */
CCTK_INT8 Util_GetHostAddr(char *hostname)
{
hostent *he;
char hostname[1025];
int addrlen;
CCTK_INT8 addr;
-
+
Util_GetHostName(hostname, 1024);
he=gethostbyname(hostname);
addrlen=he->h_length;
@@ -229,14 +249,14 @@ CCTK_INT8 Util_GetHostAddr(char *hostname)
@routine RegisterRedirect
@date Fri April 20 23:47:43 2001
@author John Shalf
- @desc
+ @desc
Redirection Page Registration.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
@@*/
static void RegisterRedirect(void)
@@ -251,17 +271,17 @@ static void RegisterRedirect(void)
@routine RedirectPage
@date Fri April 20 23:47:43 2001
@author John Shalf
- @desc
+ @desc
Redirects the webbrowser to the main server page
- @enddesc
- @calls
- @calledby
- @history
+ @enddesc
+ @calls
+ @calledby
+ @history
@hdate Thu Sep 14 10:54:22 2000 @hauthor John Shalf
- @hdesc For clusters where its difficult to know which node is going to
+ @hdesc For clusters where its difficult to know which node is going to
have the webserver process, this opens a port on *all* distinct nodes
and redirects all web connection attempts to the root node for processing.
- @endhistory
+ @endhistory
@@*/
@@ -274,8 +294,8 @@ static int RedirectPage(cGH *cctkGH, httpRequest *request, void *data)
data = data;
/* Status message */
- strcpy(message,"HTTP/1.0 200 OK\r\n");
-
+ strcpy(message,"HTTP/1.0 200 OK\r\n");
+
HTTP_Write(request, message, strlen(message));
/* Content-Type */
@@ -288,11 +308,11 @@ static int RedirectPage(cGH *cctkGH, httpRequest *request, void *data)
/* Write out the main header part */
HTTP_Write(request, message, strlen(message));
sprintf(message,"<META http-equiv=\"refresh\" content=\"1; URL=http://%s:%u\"></HEAD><body>\n",
- HTTP_Master(), (unsigned int) HTTP_Port());
- HTTP_Write(request,message,strlen(message));
+ HTTP_Master(), (unsigned int) HTTP_Port());
+ HTTP_Write(request,message,strlen(message));
/* ********** Server Redirect To Master ************* */
sprintf(message,"<p><h1>Redirect to master host=%s:%u</h1><p>\n",
- HTTP_Master(), (unsigned int) HTTP_Port());
+ HTTP_Master(), (unsigned int) HTTP_Port());
HTTP_Write(request,message,strlen(message));
HTTP_ContentFooter(cctkGH, 0, sizeof (message), message);
@@ -300,7 +320,3 @@ static int RedirectPage(cGH *cctkGH, httpRequest *request, void *data)
return retval;
}
-
-
-
-