Skip to content

Commit

Permalink
Version 2.35
Browse files Browse the repository at this point in the history
  Moved back the LispSocket and UnsafeLispSocket variables as global variables 
  instead of config struct variables. The struct is reset at each new request
  so the sockets were lost instead of reused.
  (Found and fixed by Edi Weitz)


git-svn-id: http://www.fractalconcept.com:8000/public/open-source/mod_lisp@56 9d29c65d-f3d6-0310-ab0c-b43ff62e96ec
  • Loading branch information
marc committed Jul 18, 2004
1 parent 0b1838a commit 6c37804
Showing 1 changed file with 25 additions and 40 deletions.
65 changes: 25 additions & 40 deletions mod_lisp.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#define MOD_LISP_VERSION "2.34"
#define MOD_LISP_VERSION "2.35"
#define HEADER_STR_LEN 500

/*
Version 2.35
Moved back the LispSocket and UnsafeLispSocket variables as global variables
instead of config struct variables. The struct is reset at each new request
so the sockets were lost instead of reused.
(Found and fixed by Edi Weitz)
Version 2.34
Send the SCRIPT_FILENAME variable to Lisp when it is there.
Expand Down Expand Up @@ -192,10 +198,11 @@ typedef struct excfg {
char LispServerIP[20];
long LispServerPort;
char LispServerId[100];
long LispSocket;
long UnsafeLispSocket;
} excfg;

static long LispSocket = 0;
static long UnsafeLispSocket = 0;

pool *SocketPool = NULL;

/*
Expand Down Expand Up @@ -374,13 +381,6 @@ static void setup_module_cells()
if (lisp_pool == NULL) {
lisp_pool = ap_make_sub_pool(NULL);
};
/*
* Likewise for the table of routine/environment pairs we visit outside of
* request context.
*/
if (static_calls_made == NULL) {
static_calls_made = ap_make_table(lisp_pool, 16);
};
}
#endif

Expand Down Expand Up @@ -424,21 +424,19 @@ int OpenLispSocket(excfg *cfg)
int ret;

#ifndef WIN32
if (cfg->LispSocket)
if (cfg->UnsafeLispSocket)
if (LispSocket)
if (UnsafeLispSocket)
{
ap_pclosesocket(SocketPool, cfg->LispSocket);
cfg->LispSocket = 0;
cfg->UnsafeLispSocket = 0;
ap_pclosesocket(SocketPool, LispSocket);
LispSocket = 0;
UnsafeLispSocket = 0;
}
else
{
return cfg->LispSocket;
}
return LispSocket;
#endif

cfg->LispSocket = 0;
cfg->UnsafeLispSocket = 0;
LispSocket = 0;
UnsafeLispSocket = 0;
addr.sin_addr.s_addr = inet_addr(cfg->LispServerIP);
addr.sin_port = htons((unsigned short) cfg->LispServerPort);
addr.sin_family = AF_INET;
Expand All @@ -462,7 +460,7 @@ int OpenLispSocket(excfg *cfg)
if (ret == -1)
return -1;

cfg->LispSocket = sock;
LispSocket = sock;

return sock;
}
Expand Down Expand Up @@ -501,13 +499,13 @@ void CloseLispSocket(excfg *cfg, int Socket) // socket for WIN32
if (Socket != -1)
ap_pclosesocket(SocketPool, Socket);
#else
if (!cfg->LispSocket)
if (!LispSocket)
return;

ap_pclosesocket(SocketPool, cfg->LispSocket);
ap_pclosesocket(SocketPool, LispSocket);

cfg->LispSocket = 0;
cfg->UnsafeLispSocket = 0;
LispSocket = 0;
UnsafeLispSocket = 0;
#endif
}

Expand Down Expand Up @@ -608,7 +606,7 @@ static int lisp_handler(request_rec *r)
}
ap_reset_timeout(r);

dcfg->UnsafeLispSocket = 1;
UnsafeLispSocket = 1;

if (r->subprocess_env)
{
Expand Down Expand Up @@ -757,10 +755,6 @@ static int lisp_handler(request_rec *r)
r->status = atoi(Value);
r->status_line = ap_pstrdup(r->pool, Value);
}
else if (!strcmp(Header, "Location"))
{
ap_table_set(r->headers_out, Header, Value);
}
else if (!strcmp(Header, "Content-Length"))
{
ap_table_set(r->headers_out, Header, Value);
Expand Down Expand Up @@ -821,10 +815,6 @@ static int lisp_handler(request_rec *r)
ap_table_setn(r->notes, ap_pstrdup(r->pool, Value), ap_pstrdup(r->pool, pv));
}
}
else if (!strcmp(Header, "Set-Cookie"))
{
ap_table_add(r->headers_out, Header, Value);
}
else
ap_table_set(r->headers_out, Header, Value);
}
Expand Down Expand Up @@ -865,7 +855,7 @@ static int lisp_handler(request_rec *r)
ap_bpushfd(BuffSocket, -1, -1); /* unlink buffer to keep socket */
BuffSocket->flags &= ~B_SOCKET;
}
dcfg->UnsafeLispSocket = 0;
UnsafeLispSocket = 0;
return OK;
}

Expand Down Expand Up @@ -990,7 +980,6 @@ static void *lisp_create_dir_config(pool *p, char *dirspec)
strcpy(cfg->LispServerId, "apache");
cfg->LispServerPort = 3000;
cfg->DefaultLispServer = 1;
cfg->LispSocket = 0;

cfg->cmode = CONFIG_MODE_DIRECTORY;
dname = (dname != NULL) ? dname : "";
Expand Down Expand Up @@ -1064,7 +1053,6 @@ static void *lisp_merge_dir_config(pool *p, void *parent_conf,
merged_config->DefaultLispServer = 1;
}

merged_config->LispSocket = 0;
return (void *) merged_config;
}

Expand Down Expand Up @@ -1092,7 +1080,6 @@ static void *lisp_create_server_config(pool *p, server_rec *s)
strcpy(cfg->LispServerIP, "127.0.0.1");
strcpy(cfg->LispServerId, "apache");
cfg->LispServerPort = 3000;
cfg->LispSocket = 0;
cfg->DefaultLispServer = 1;
sname = (sname != NULL) ? sname : "";
cfg->loc = ap_pstrcat(p, "SVR(", sname, ")", NULL);
Expand Down Expand Up @@ -1153,7 +1140,6 @@ static void *lisp_merge_server_config(pool *p, void *server1_conf,
merged_config->DefaultLispServer = 1;
}

merged_config->LispSocket = 0;
return (void *) merged_config;
}

Expand Down Expand Up @@ -1314,7 +1300,6 @@ static const char *SetLispServer(cmd_parms *cmd, void *mconfig, char *serverIp,
cfg->LispServerId[99] = 0;
cfg->LispServerPort = atoi(port);
cfg->DefaultLispServer = 0;
cfg->LispSocket = 0;

return NULL;
}
Expand Down

0 comments on commit 6c37804

Please sign in to comment.