chiark
/
gitweb
/
~ian
/
chiark-utils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
71eaa17
)
cgi-fcgi-interp: wip check_garbage
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Wed, 23 Mar 2016 18:22:53 +0000
(18:22 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Wed, 23 Mar 2016 18:23:16 +0000
(18:23 +0000)
cprogs/cgi-fcgi-interp.c
patch
|
blob
|
history
diff --git
a/cprogs/cgi-fcgi-interp.c
b/cprogs/cgi-fcgi-interp.c
index 9df31034aa8da607297ea67dff618b86c5c5e755..c08ba9da457d0e153bf52c2c04c1121487c2235e 100644
(file)
--- a/
cprogs/cgi-fcgi-interp.c
+++ b/
cprogs/cgi-fcgi-interp.c
@@
-87,8
+87,8
@@
* - check for and maybe create <base>
* - stat and lstat the <script>
* - stat the socket and check its timestamp
* - check for and maybe create <base>
* - stat and lstat the <script>
* - stat the socket and check its timestamp
- * if it is too
hold, rename it to g<inum
> (where
- * <inum>
is
in decimal)
+ * if it is too
old, rename it to g<inum>.<pid
> (where
+ * <inum>
and <pid> are
in decimal)
* and run garbage collection
* - run cgi-fcgi -connect SOCKET SCRIPT
*/
* and run garbage collection
* - run cgi-fcgi -connect SOCKET SCRIPT
*/
@@
-264,10
+264,17
@@
static void find_socket_path(void) {
socket_path = m_asprintf("%s/g%s",run_base,ident);
}
socket_path = m_asprintf("%s/g%s",run_base,ident);
}
+static bool stab_isnewer(const struct stat *a, const struct stat *b) {
+ return 0;
+}
+
static bool check_garbage(void) {
static bool check_garbage(void) {
- struct stat sock_stab,
cmd
_stab;
+ struct stat sock_stab,
script
_stab;
int r;
int r;
+ r = lstat(script, &script_stab);
+ if (r) err(127,"lstat script (%s)",script);
+
r = lstat(socket_path, &sock_stab);
if (r) {
if ((errno == ENOENT))
r = lstat(socket_path, &sock_stab);
if (r) {
if ((errno == ENOENT))
@@
-275,8
+282,16
@@
static bool check_garbage(void) {
err(127,"stat socket (%s)",socket_path);
}
err(127,"stat socket (%s)",socket_path);
}
- r = lstat(script, &cmd_stab);
- if (r) err(127,"lstat script (%s)",script);
+ if (stab_isnewer(&script_stab, &sock_stab))
+ return 1;
+
+ if (S_ISLNK(script_stab.st_mode)) {
+ r = stat(script, &script_stab);
+ if (r) err(127,"stat script (%s0",script);
+
+ if (stab_isnewer(&script_stab, &sock_stab))
+ return 1;
+ }
return 0;
}
return 0;
}