Commit 64370e2f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Use closefd() throughout

parent 0a105cdd
......@@ -305,7 +305,7 @@ vca_make_session(struct worker *wrk, void *arg)
CAST_OBJ_NOTNULL(wa, arg, WRK_ACCEPT_MAGIC);
if (VTCP_blocking(wa->acceptsock)) {
AZ(close(wa->acceptsock));
closefd(&wa->acceptsock);
wrk->stats->sess_drop++; // XXX Better counter ?
WS_Release(wrk->aws, 0);
return;
......@@ -322,7 +322,7 @@ vca_make_session(struct worker *wrk, void *arg)
*/
vca_pace_bad();
(void)VTCP_nonblocking(wa->acceptsock);
AZ(close(wa->acceptsock));
closefd(&wa->acceptsock);
wrk->stats->sess_drop++;
WS_Release(wrk->aws, 0);
return;
......
......@@ -86,7 +86,7 @@ vrt_vmod_backup_copy(VRT_CTX, const char *nm, const char *fm, const char *to)
VSB_printf(ctx->msg, "Opening vmod %s from %s: %s\n",
nm, fm, strerror(errno));
AZ(unlink(to));
AZ(close(fo));
closefd(&fo);
return (1);
}
while (1) {
......@@ -101,8 +101,8 @@ vrt_vmod_backup_copy(VRT_CTX, const char *nm, const char *fm, const char *to)
break;
}
}
AZ(close(fi));
AZ(close(fo));
closefd(&fi);
closefd(&fo);
return(ret);
}
......
......@@ -59,7 +59,7 @@ mac_opensocket(struct listen_sock *ls)
CHECK_OBJ_NOTNULL(ls, LISTEN_SOCK_MAGIC);
if (ls->sock > 0) {
MCH_Fd_Inherit(ls->sock, NULL);
AZ(close(ls->sock));
closefd(&ls->sock);
}
ls->sock = VTCP_bind(ls->addr, NULL);
fail = errno;
......
......@@ -282,7 +282,7 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv)
VJ_master(JAIL_MASTER_LOW);
MCH_TrackHighFd(fd);
VCLI_AuthResponse(fd, cli->challenge, buf);
AZ(close(fd));
closefd(&fd);
if (strcasecmp(buf, av[2])) {
MGT_Complain(C_SECURITY,
"CLI Authentication failure from %s", cli->ident);
......@@ -518,7 +518,7 @@ mgt_cli_secret(const char *S_arg)
fprintf(stderr, "Can not read secret-file \"%s\"\n", S_arg);
exit(2);
}
AZ(close(fd));
closefd(&fd);
secret_file = S_arg;
}
......
......@@ -156,7 +156,7 @@ VJ_make_workdir(const char *dname)
ARGV_ERR("Cannot create test-file in %s (%s)\n"
"Check permissions (or delete old directory)\n",
dname, strerror(errno));
AZ(close(fd));
closefd(&fd);
AZ(unlink("_.testfile"));
VJ_master(JAIL_MASTER_LOW);
return (0);
......
......@@ -219,7 +219,7 @@ make_secret(const char *dirname)
AZ(VRND_RandomCrypto(&b, 1));
assert(1 == write(fdo, &b, 1));
}
AZ(close(fdo));
closefd(&fdo);
VJ_master(JAIL_MASTER_LOW);
AZ(atexit(mgt_secret_atexit));
return (fn);
......@@ -361,7 +361,7 @@ mgt_eric(void)
fprintf(stderr, "Fork() failed: %s\n", strerror(errno));
exit(-1);
case 0:
AZ(close(eric_pipes[0]));
closefd(&eric_pipes[0]);
assert(setsid() > 1);
VFIL_null_fd(STDIN_FILENO);
......@@ -369,7 +369,7 @@ mgt_eric(void)
default:
break;
}
AZ(close(eric_pipes[1]));
closefd(&eric_pipes[1]);
sz = read(eric_pipes[0], &u, sizeof u);
if (sz == sizeof u && u == ERIC_MAGIC)
exit(0);
......@@ -391,7 +391,7 @@ mgt_eric_im_done(int eric_fd, unsigned u)
VFIL_null_fd(STDERR_FILENO);
assert(write(eric_fd, &u, sizeof u) == sizeof u);
AZ(close(eric_fd));
closefd(&eric_fd);
}
/*--------------------------------------------------------------------*/
......@@ -681,7 +681,7 @@ main(int argc, char * const *argv)
if (o < 0)
ARGV_ERR("Cannot open -S file (%s): %s\n",
S_arg, strerror(errno));
AZ(close(o));
closefd(&o);
VJ_master(JAIL_MASTER_LOW);
}
......
......@@ -75,7 +75,7 @@ tcp_keep_probes(void)
tcp_probe(s, TCP_KEEPIDLE, "tcp_keepalive_time", 600);
tcp_probe(s, TCP_KEEPCNT, "tcp_keepalive_probes", 5);
tcp_probe(s, TCP_KEEPINTVL, "tcp_keepalive_intvl", 5);
AZ(close(s));
closefd(&s);
}
#endif
......
......@@ -218,7 +218,7 @@ mgt_SHM_Create(void)
MAP_HASSEMAPHORE | MAP_NOSYNC | MAP_SHARED,
vsm_fd, 0);
AZ(close(vsm_fd));
closefd(&vsm_fd);
if (p == MAP_FAILED) {
MGT_Complain(C_ERR, "Mmap error %s: %s",
......
......@@ -125,7 +125,7 @@ run_vcc(void *priv)
fprintf(stderr, "VCC cannot write %s", vp->csrcfile);
exit(2);
}
AZ(close(fd));
closefd(&fd);
VSB_destroy(&csrc);
exit(0);
}
......@@ -216,7 +216,7 @@ mgt_vcc_touchfile(const char *fn, struct vsb *sb)
if (geteuid() == 0)
VSB_printf(sb, "Failed to change owner on %s: %s\n",
fn, strerror(errno));
AZ(close(i));
closefd(&i);
return (0);
}
......
......@@ -146,9 +146,9 @@ vwe_thread(void *priv)
if (vwe->nwaited == 0 && vwe->die)
break;
}
AZ(close(vwe->pipe[0]));
AZ(close(vwe->pipe[1]));
AZ(close(vwe->epfd));
closefd(&vwe->pipe[0]);
closefd(&vwe->pipe[1]);
closefd(&vwe->epfd);
return (NULL);
}
......
......@@ -128,9 +128,9 @@ vwk_thread(void *priv)
if (vwk->nwaited == 0 && vwk->die)
break;
}
AZ(close(vwk->pipe[0]));
AZ(close(vwk->pipe[1]));
AZ(close(vwk->kq));
closefd(&vwk->pipe[0]);
closefd(&vwk->pipe[1]);
closefd(&vwk->kq);
return(NULL);
}
......
......@@ -262,8 +262,8 @@ vwp_fini(struct waiter *w)
// XXX: set write pipe blocking
assert(write(vwp->pipes[1], &vp, sizeof vp) == sizeof vp);
AZ(pthread_join(vwp->thread, &vp));
AZ(close(vwp->pipes[0]));
AZ(close(vwp->pipes[1]));
closefd(&vwp->pipes[0]);
closefd(&vwp->pipes[1]);
free(vwp->pollfd);
free(vwp->idx);
}
......
......@@ -256,7 +256,7 @@ vws_fini(struct waiter *w)
CAST_OBJ_NOTNULL(vws, w->priv, VWS_MAGIC);
vws->die = 1;
AZ(close(vws->dport));
closefd(&vws->dport);
AZ(pthread_join(vws->thread, &vp));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment