summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2007-09-22 15:57:25 +0000
committerJoris Vink <joris@cvs.openbsd.org>2007-09-22 15:57:25 +0000
commita634a04dd7e99d9335ce37798fb7b6335c3495f5 (patch)
tree0dee1c3902b0e46c97ef57a410b6a9fb3abbf645
parentbb8e3dc5f95efbf282454fe0d1433c4fe85bb7db (diff)
we no longer create a 0 sized file in our /tmp/cvs-serv<pid> server
directory when a client sends us info about a file that is up to date. instead, remember the file is up to date in our CVS/Entries. Saves us a lot of headaches on very big trees like src/
-rw-r--r--usr.bin/cvs/entries.c11
-rw-r--r--usr.bin/cvs/file.c18
-rw-r--r--usr.bin/cvs/remote.h5
-rw-r--r--usr.bin/cvs/server.c27
4 files changed, 38 insertions, 23 deletions
diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c
index 12b8bf92365..d1824b04e09 100644
--- a/usr.bin/cvs/entries.c
+++ b/usr.bin/cvs/entries.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entries.c,v 1.80 2007/09/04 19:07:04 tobias Exp $ */
+/* $OpenBSD: entries.c,v 1.81 2007/09/22 15:57:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -20,6 +20,7 @@
#include <unistd.h>
#include "cvs.h"
+#include "remote.h"
#define CVS_ENTRIES_NFIELDS 6
#define CVS_ENTRIES_DELIM '/'
@@ -154,9 +155,13 @@ cvs_ent_parse(const char *entry)
if (fields[3][0] == '\0' ||
strncmp(fields[3], CVS_DATE_DUMMY, sizeof(CVS_DATE_DUMMY) - 1) == 0 ||
strncmp(fields[3], "Initial ", 8) == 0 ||
- strncmp(fields[3], "Result of merge", 15) == 0)
+ strncmp(fields[3], "Result of merge", 15) == 0) {
ent->ce_mtime = CVS_DATE_DMSEC;
- else {
+ } else if (cvs_server_active == 1 &&
+ strncmp(fields[3], CVS_SERVER_UNCHANGED,
+ strlen(CVS_SERVER_UNCHANGED)) == 0) {
+ ent->ce_mtime = CVS_SERVER_UPTODATE;
+ } else {
/* Date field can be a '+=' with remote to indicate
* conflict. In this case do nothing. */
if (strptime(fields[3], "%a %b %d %T %Y", &t) != NULL) {
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index 57d88664fa7..3e4948728c2 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.197 2007/09/17 10:07:21 tobias Exp $ */
+/* $OpenBSD: file.c,v 1.198 2007/09/22 15:57:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -38,6 +38,7 @@
#include "atomicio.h"
#include "cvs.h"
+#include "remote.h"
#define CVS_IGN_STATIC 0x01 /* pattern is static, no need to glob */
@@ -559,13 +560,15 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
size_t len;
struct stat st;
BUF *b1, *b2;
+ int server_has_file;
int rflags, ismodified, rcsdead;
CVSENTRIES *entlist = NULL;
const char *state;
char repo[MAXPATHLEN], rcsfile[MAXPATHLEN];
char r1[CVS_REV_BUFSZ], r2[CVS_REV_BUFSZ];
- cvs_log(LP_TRACE, "cvs_file_classify(%s)", cf->file_path);
+ cvs_log(LP_TRACE, "cvs_file_classify(%s, %s)", cf->file_path,
+ (tag != NULL) ? tag : "none");
if (!strcmp(cf->file_path, ".")) {
cf->file_status = FILE_UPTODATE;
@@ -679,6 +682,13 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
ismodified = 1;
}
+ server_has_file = 0;
+ if (cvs_server_active == 1 && cf->file_ent != NULL &&
+ cf->file_ent->ce_mtime == CVS_SERVER_UPTODATE) {
+ server_has_file = 1;
+ ismodified = 0;
+ }
+
if (ismodified == 1 && cf->fd != -1 && cf->file_rcs != NULL) {
b1 = rcs_rev_getbuf(cf->file_rcs, cf->file_rcsrev, 0);
if (b1 == NULL)
@@ -768,7 +778,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
} else if (cf->file_ent->ce_status == CVS_ENT_REG) {
if (cf->file_rcs == NULL || rcsdead == 1 ||
(reset_stickies == 1 && cf->in_attic == 1)) {
- if (cf->fd == -1) {
+ if (cf->fd == -1 && server_has_file == 0) {
cvs_log(LP_NOTICE,
"warning: %s's entry exists but"
" there is no longer a file"
@@ -794,7 +804,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
}
}
} else {
- if (cf->fd == -1) {
+ if (cf->fd == -1 && server_has_file == 0) {
if (cvs_cmdop != CVS_OP_REMOVE) {
cvs_log(LP_NOTICE,
"warning: %s was lost",
diff --git a/usr.bin/cvs/remote.h b/usr.bin/cvs/remote.h
index 8be6ecd185b..fc48b615b0b 100644
--- a/usr.bin/cvs/remote.h
+++ b/usr.bin/cvs/remote.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: remote.h,v 1.25 2007/08/30 11:07:18 joris Exp $ */
+/* $OpenBSD: remote.h,v 1.26 2007/09/22 15:57:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -44,6 +44,9 @@ extern int server_response;
#define SERVER_OK 0
#define SERVER_ERROR 1
+#define CVS_SERVER_UNCHANGED "d[o.o]b"
+#define CVS_SERVER_UPTODATE (time_t)-2
+
void cvs_client_connect_to_server(void);
void cvs_client_disconnect(void);
void cvs_client_send_logmsg(char *);
diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c
index 0d856057d07..90a13ca4372 100644
--- a/usr.bin/cvs/server.c
+++ b/usr.bin/cvs/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.70 2007/09/07 19:18:41 tobias Exp $ */
+/* $OpenBSD: server.c,v 1.71 2007/09/22 15:57:24 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -417,37 +417,34 @@ cvs_server_useunchanged(char *data)
void
cvs_server_unchanged(char *data)
{
- int fd;
char fpath[MAXPATHLEN];
CVSENTRIES *entlist;
struct cvs_ent *ent;
- struct timeval tv[2];
+ char sticky[CVS_ENT_MAXLINELEN];
+ char rev[CVS_REV_BUFSZ], entry[CVS_ENT_MAXLINELEN];
if (data == NULL)
fatal("Missing argument for Unchanged");
(void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, data);
- if ((fd = open(fpath, O_RDWR | O_CREAT | O_TRUNC)) == -1)
- fatal("cvs_server_unchanged: %s: %s", fpath, strerror(errno));
-
entlist = cvs_ent_open(server_currentdir);
ent = cvs_ent_get(entlist, data);
if (ent == NULL)
fatal("received Unchanged request for non-existing file");
- cvs_ent_close(entlist, ENT_NOSYNC);
- tv[0].tv_sec = ent->ce_mtime;
- tv[0].tv_usec = 0;
- tv[1] = tv[0];
- if (futimes(fd, tv) == -1)
- fatal("cvs_server_unchanged: failed to set modified time");
+ sticky[0] = '\0';
+ if (ent->ce_tag != NULL)
+ (void)xsnprintf(sticky, sizeof(sticky), "T%s", ent->ce_tag);
- if (fchmod(fd, 0600) == -1)
- fatal("cvs_server_unchanged: failed to set mode");
+ rcsnum_tostr(ent->ce_rev, rev, sizeof(rev));
+ (void)xsnprintf(entry, sizeof(entry), "/%s/%s/%s/%s/%s",
+ ent->ce_name, rev, CVS_SERVER_UNCHANGED, ent->ce_opts ?
+ ent->ce_opts : "", sticky);
cvs_ent_free(ent);
- (void)close(fd);
+ cvs_ent_add(entlist, entry);
+ cvs_ent_close(entlist, ENT_SYNC);
}
void