* - 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
*/
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) {
- struct stat sock_stab, cmd_stab;
+ struct stat sock_stab, script_stab;
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))
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;
}