diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-12-08 20:00:24 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-12-08 20:00:24 +0000 |
commit | 080117b061278ea0a89628a0630f4bd00a1dbdda (patch) | |
tree | 3369cfb5d20b167df755c1515c82f39563a5fb18 /usr.bin | |
parent | 798a48ded0c60f155bc123fa7483a0b254d8bb62 (diff) |
simplify the handler for Created, Updated, Update-existing and Merged
and close the Entries file handle when we are done modifying it.
this fixes a leak and syncs the contents on disk so the revisions
and dates get updated properly
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/resp.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/usr.bin/cvs/resp.c b/usr.bin/cvs/resp.c index fdce6119785..cdf5774f32c 100644 --- a/usr.bin/cvs/resp.c +++ b/usr.bin/cvs/resp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resp.c,v 1.14 2004/12/08 19:28:10 jfb Exp $ */ +/* $OpenBSD: resp.c,v 1.15 2004/12/08 20:00:23 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -146,6 +146,7 @@ extern u_int cvs_version_sent; int cvs_resp_handle(struct cvsroot *root, char *line) { + int ret; char *cp, *cmd; struct cvs_resp *resp; @@ -163,7 +164,12 @@ cvs_resp_handle(struct cvsroot *root, char *line) return (-1); } - return (*cvs_resp_swtab[resp->resp_id].hdlr)(root, resp->resp_id, cp); + ret = (*cvs_resp_swtab[resp->resp_id].hdlr)(root, resp->resp_id, cp); + + if (ret == -1) + cvs_log(LP_ERR, "error in handling of `%s' response", cmd); + + return (ret); } @@ -535,20 +541,12 @@ cvs_resp_updated(struct cvsroot *root, int type, char *line) mode_t fmode; char path[MAXPATHLEN], cksum_buf[CVS_CKSUM_LEN]; BUF *fbuf; - CVSFILE *cf; CVSENTRIES *entfile; struct cvs_ent *ep; struct timeval tv[2]; STRIP_SLASH(line); - /* find parent directory of file */ - cf = cvs_file_find(cvs_files, line); - if (cf == NULL) { - cvs_log(LP_ERR, "failed to find directory %s", line); - return (-1); - } - /* read the remote path of the file */ if (cvs_getln(root, path, sizeof(path)) < 0) return (-1); @@ -567,19 +565,27 @@ cvs_resp_updated(struct cvsroot *root, int type, char *line) return (-1); } - if (type == CVS_RESP_CREATED) { - /* set the timestamp as the last one received from Mod-time */ + if (cvs_modtime != CVS_DATE_DMSEC) { ep->ce_mtime = cvs_modtime; - cvs_ent_add(entfile, ep); - } else if ((type == CVS_RESP_UPDEXIST) || (type == CVS_RESP_UPDATED)) { + cvs_modtime = CVS_DATE_DMSEC; /* invalidate */ + } else + ep->ce_mtime = time(&(ep->ce_mtime)); + + if ((type == CVS_RESP_UPDEXIST) || (type == CVS_RESP_UPDATED) || + (type == CVS_RESP_MERGED)) { if (cvs_ent_remove(entfile, ep->ce_name) < 0) cvs_log(LP_WARN, "failed to remove entry for `%s'", ep->ce_name); + } - cvs_ent_add(entfile, ep); - } else if (type == CVS_RESP_MERGED) { + if (cvs_ent_add(entfile, ep) < 0) { + cvs_ent_free(ep); + cvs_ent_close(entfile); + return (-1); } + cvs_ent_close(entfile); + fbuf = cvs_recvfile(root, &fmode); if (fbuf == NULL) return (-1); |