
From shap@eros-os.org Thu Oct 11 13:38:11 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id f9BHcBv09157
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 11 Oct 2001 13:38:11 -0400
Received: from snipe.mail.pas.earthlink.net (snipe.mail.pas.earthlink.net [207.217.120.62])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id NAA00874
	for <dcms-cvs@eros-os.org>; Thu, 11 Oct 2001 13:26:54 -0400
Received: from vmware (dialup-63.208.187.108.Dial1.Baltimore1.Level3.net [63.208.187.108])
	by snipe.mail.pas.earthlink.net (8.11.5/8.9.3) with SMTP id f9BHdL512191
	for <dcms-cvs@eros-os.org>; Thu, 11 Oct 2001 10:39:27 -0700 (PDT)
Message-ID: <003101c1527c$8397cab0$021010ac@vmware>
From: "Jonathan S. Shapiro" <shap@eros-os.org>
To: <dcms-cvs@eros-os.org>
Date: Thu, 11 Oct 2001 13:44:56 -0400
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4807.1700
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700
Subject: [dcms-cvs] Initial message to create the archive
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

Please ignore this.


From bastille@snocrash.cs.jhu.edu Fri Oct 19 13:59:33 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id f9JHxXv01319
	for <dcms-cvs@eros.cs.jhu.edu>; Fri, 19 Oct 2001 13:59:33 -0400
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id NAA00875;
	Fri, 19 Oct 2001 13:47:09 -0400
Received: (from bastille@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id f9JHxrO21237;
	Fri, 19 Oct 2001 13:59:53 -0400
Date: Fri, 19 Oct 2001 13:59:53 -0400
From: Raphael Schweber-Koren <bastille@snocrash.cs.jhu.edu>
Message-Id: <200110191759.f9JHxrO21237@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/tests testvars.sh
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

bastille    01/10/19 13:59:53

  Modified:    src      .cvsignore Makefile.in
               src/client Makefile.in
               src/server Makefile.in
               tests    testvars.sh
  Removed:     src      pcms.c
  Log:
  Modified make to leave pcms client in src/client and pcms server in src/server.
  
  Removed src/pcms.c -> don't know how that one escaped the last commit.

Revision  Changes    Path
1.5       +0 -2      pcms/src/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/.cvsignore,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- .cvsignore	2001/10/19 03:44:10	1.4
+++ .cvsignore	2001/10/19 17:59:52	1.5
@@ -1,4 +1,2 @@
 Makefile
-pcms
-pcmsserver
 .*.m



1.20      +2 -2      pcms/src/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/Makefile.in,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Makefile.in	2001/10/19 03:44:10	1.19
+++ Makefile.in	2001/10/19 17:59:53	1.20
@@ -19,9 +19,9 @@
 PCMSLIBS=$(PCMSCOMMONLIB) \
 	 $(PCMSREPOSLIB)
 
-PCMSCLIENT=pcms
+PCMSCLIENT=client/pcms
 
-PCMSSERVER=pcmsserver
+PCMSSERVER=server/pcmsserver
 
 default: all
 



1.2       +1 -16     pcms/src/client/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/Makefile.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile.in	2001/10/19 03:44:10	1.1
+++ Makefile.in	2001/10/19 17:59:53	1.2
@@ -37,30 +37,15 @@
 
 all: $(BIN_DEPS) DEPEND
 
-install: all
-	@$(NORMAL_INSTALL)
-	$(mkinstalldirs) $(DESTDIR)$(bindir)
-	@list='$(BIN_DEPS)'; \
-	for file in $$list; do \
-	  d=$(srcdir); \
-	  for ifile in `cd $$d && echo $$file $$file-[0-9] $$file-[0-9][0-9]`; do \
-	    if test -f $$d/$$ifile; then \
-	      echo " $(INSTALL_PROGRAM) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile"; \
-	      $(INSTALL_PROGRAM) $$d/$$ifile $(DESTDIR)$(infodir)/$$ifile; \
-	    else : ; fi; \
-	  done; \
-	done
-
 clean:
 	-rm -f *.pyc *~ *.o .*.m
-	-rm -f pcms ../pcms
+	-rm -f pcms 
 
 distclean: clean
 	-rm -f Makefile
 
 pcms: $(OBJECTS)
 	$(CC) -o $@ $(CFLAGS) $(OBJECTS) $(CLIENTLIBS) $(PCMSLIBS)
-	cp pcms ../
 
 nodepend:
 	-find . -name '.*.m' -exec rm {} \;



1.3       +1 -2      pcms/src/server/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/Makefile.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Makefile.in	2001/10/19 03:44:11	1.2
+++ Makefile.in	2001/10/19 17:59:53	1.3
@@ -19,14 +19,13 @@
 
 clean:
 	-rm -f *~ *.o .*.m
-	-rm -f pcmsserver ../pcmsserver
+	-rm -f pcmsserver
 
 distclean: clean
 	-rm -f Makefile
 
 pcmsserver: $(OBJECTS)
 	$(CC) -o $@ $(CFLAGS) $(OBJECTS) $(PCMSLIBS)
-	cp pcmsserver ../pcmsserver
 
 nodepend:
 	-find . -name '.*.m' -exec rm {}



1.4       +1 -1      pcms/tests/testvars.sh

Index: testvars.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/testvars.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- testvars.sh	2000/10/06 18:57:45	1.3
+++ testvars.sh	2001/10/19 17:59:53	1.4
@@ -2,7 +2,7 @@
 
 TEST_DIR=$PWD
 
-PCMS="$PWD/../src/pcms --flush-io"
+PCMS="$PWD/../src/client/pcms --flush-io"
 
 # Use this for directory comparison:
 DIRDIFF="diff -q -P -r"




From bastille@snocrash.cs.jhu.edu Tue Oct 23 19:07:23 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id f9NN7Nv14537
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 23 Oct 2001 19:07:23 -0400
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA00791;
	Tue, 23 Oct 2001 18:54:27 -0400
Received: (from bastille@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id f9NN7Lx28963;
	Tue, 23 Oct 2001 19:07:21 -0400
Date: Tue, 23 Oct 2001 19:07:21 -0400
From: Raphael Schweber-Koren <bastille@snocrash.cs.jhu.edu>
Message-Id: <200110232307.f9NN7Lx28963@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/tests testvars.sh
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

bastille    01/10/23 19:07:21

  Modified:    .        configure.in
               src      .cvsignore Makefile.in
               src/client .cvsignore Makefile.in
               src/common .cvsignore Makefile.in os.c
               src/repos .cvsignore Makefile.in
               src/server Makefile.in
               tests    testvars.sh
  Added:       src      pcmsrules.mk.in
               src/repos/common .cvsignore Makefile.in
               src/repos/fs .cvsignore Makefile.in
               src/repos/net .cvsignore Makefile.in
  Log:
  Changed to a single Makefile, its temporary but it works.
  "make" in subdirectorys of src/ is a make all.
  
  Issues: Dependencies are stored in non-hidden filenames.... I'd like to fix this
  . Could some makefile genius attempt to fix this? Also I don't think those depen
  d files work in the context of the single file at the top of the tree. If someon
  e could fix this that'd work too.
  
  Of course, sometime we'll move to a recursive make structure and these issues ar
  e easy in that structure.

Revision  Changes    Path
1.9       +1 -1      pcms/configure.in

Index: configure.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/configure.in,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- configure.in	2001/10/19 03:44:10	1.8
+++ configure.in	2001/10/23 23:07:20	1.9
@@ -42,4 +42,4 @@
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS(getcwd gethostname mkdir strerror strtoul)
 
-AC_OUTPUT(Makefile src/Makefile src/common/Makefile src/client/Makefile src/server/Makefile src/repos/Makefile libdiff/Makefile doc/Makefile tests/Makefile)
+AC_OUTPUT(Makefile src/pcmsrules.mk src/Makefile src/common/Makefile src/client/Makefile src/server/Makefile src/repos/Makefile src/repos/net/Makefile src/repos/fs/Makefile src/repos/common/Makefile libdiff/Makefile doc/Makefile tests/Makefile)



1.6       +2 -1      pcms/src/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/.cvsignore,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- .cvsignore	2001/10/19 17:59:52	1.5
+++ .cvsignore	2001/10/23 23:07:20	1.6
@@ -1,2 +1,3 @@
 Makefile
-.*.m
+pcmsrules.mk
+.depend



1.21      +2 -66     pcms/src/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/Makefile.in,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- Makefile.in	2001/10/19 17:59:53	1.20
+++ Makefile.in	2001/10/23 23:07:20	1.21
@@ -1,67 +1,3 @@
-# Copyright (C) 2000, The EROS Group, LLC.
-
-CFLAGS=-g	# may be overridden from top.
-
-INCLUDE=-I$(shell pwd)
-
-LIBINCLUDE=-L$(shell pwd)/common -L$(shell pwd)/repos
-
-XCFLAGS=-Wmissing-prototypes -Werror -Wreturn-type $(INCLUDE)
-
-DIRS=common \
-     repos \
-     server \
-     client
-
-
-PCMSCOMMONLIB=common/libpcms.a 
-PCMSREPOSLIB=repos/libpcmsrepos.a
-PCMSLIBS=$(PCMSCOMMONLIB) \
-	 $(PCMSREPOSLIB)
-
-PCMSCLIENT=client/pcms
-
-PCMSSERVER=server/pcmsserver
-
-default: all
-
-all: $(PCMSLIBS) $(PCMSCLIENT) $(PCMSSERVER)
-
-libs: $(PCMSLIBS)
-
-clean:
-	-rm -f *.pyc *~ *.o .*.m
-	-rm -f $(PCMSCLIENT) $(PCMSSERVER) $(PCMSLIBS)
-	@for dir in $(DIRS); do \
-	   ( cd $$dir && $(MAKE) $(FLAGS_TO_PASS) clean ) || exit 1; \
-	done;
-
-distclean: clean
-	-rm -f Makefile
-	@for dir in $(DIRS); do \
-		( cd $$dir && $(MAKE) $(FLAGS_TO_PASS) distclean ) || exit 1; \
-	done;
-
-$(PCMSCLIENT): $(PCMSLIBS)
-	( cd client && $(MAKE) $(FLAGS_TO_PASS) INCLUDE='$(INCLUDE)' LIBINCLUDE='$(LIBINCLUDE)' all ) || exit 1
-
-
-$(PCMSSERVER): $(PCMSLIBS)
-	( cd server && $(MAKE) $(FLAGS_TO_PASS) INCLUDE='$(INCLUDE)' LIBINCLUDE='$(LIBINCLUDE)' all ) || exit 1
-
-$(PCMSCOMMONLIB):
-	( cd common && $(MAKE) $(FLAGS_TO_PASS) INCLUDE='$(INCLUDE)' libpcms.a ) || exit 1
-
-$(PCMSREPOSLIB): $(PCMSCOMMONLIB)
-	( cd repos && $(MAKE) $(FLAGS_TO_PASS) INCLUDE='$(INCLUDE)' libpcmsrepos.a ) || exit 1
-
-nodepend:
-	-find . -name '.*.m' -exec rm {} \;
-
-
-
-
-
-
-
+TOPDIR=.
+-include pcmsrules.mk
 



1.1                  pcms/src/pcmsrules.mk.in

Index: pcmsrules.mk.in
===================================================================


INCLUDE=-I$(TOPDIR)/
LIBINCLUDE=-L$(TOPDIR)/lib

LIBREADLINE=-lreadline -ltermcap
COMREADLINE=-DUSE_READLINE -I/usr/include/readline
LIBDIFF=$(LIBINCLUDE)/../../libdiff -ldiff

CFLAGS=-g #may be overridden from above
XCFLAGS=-Wmissing-prototypes -Werror -Wreturn-type

COMMONOBJECTS=\
	$(TOPDIR)/common/SDR.o \
	$(TOPDIR)/common/path.o \
	$(TOPDIR)/common/util.o \
	$(TOPDIR)/common/sha1.o \
	$(TOPDIR)/common/TrueName.o \
	$(TOPDIR)/common/PtrArray.o \
	$(TOPDIR)/common/EntityBits.o \
	$(TOPDIR)/common/Entity.o \
	$(TOPDIR)/common/EntitySet.o \
	$(TOPDIR)/common/Change.o \
	$(TOPDIR)/common/CommitInfo.o \
	$(TOPDIR)/common/Branch.o \
	$(TOPDIR)/common/Project.o \
	$(TOPDIR)/common/Serializable.o \
	$(TOPDIR)/common/xmalloc.o \
	$(TOPDIR)/common/os.o

REPOSOBJECTS=\
	$(TOPDIR)/repos/fs/CachedFileRepos.o \
	$(TOPDIR)/repos/fs/FileRepos.o \
	$(TOPDIR)/repos/net/NetRepository.o \
	$(TOPDIR)/repos/common/Repository.o \
	$(TOPDIR)/repos/common/EntityCache.o \
	$(TOPDIR)/repos/common/URI.o

LIBDIR=$(TOPDIR)/lib

COMMONLIB=$(LIBDIR)/libpcms.a

REPOSLIB=$(LIBDIR)/libpcmsrepos.a

PCMSLIBS=-lpcms -lpcmsrepos

CLIENTOBJECTS=\
	$(TOPDIR)/client/pcms.o \
	$(TOPDIR)/client/glob.o \
	$(TOPDIR)/client/nmlist.o \
	$(TOPDIR)/client/command.o \
	$(TOPDIR)/client/message.o \
	$(TOPDIR)/client/verify.o \
	$(TOPDIR)/client/SubProcess.o \
	$(TOPDIR)/client/WsEntity.o \
	$(TOPDIR)/client/FilterSet.o \
	$(TOPDIR)/client/PendingChange.o \
	$(TOPDIR)/client/WorkSpace.o \
	$(TOPDIR)/client/Options.o \
	$(TOPDIR)/client/Merge.o

CLIENT=$(TOPDIR)/pcms

SERVEROBJECTS=\
	$(TOPDIR)/server/pcmsserver.o

SERVER=$(TOPDIR)/pcmsserver

SEDHACK=sed 's,'$*'\.o[ :]*,'$@' &,g'

OBJECTS=\
	$(COMMONOBJECTS) \
	$(REPOSOBJECTS) \
	$(CLIENTOBJECTS) \
	$(SERVEROBJECTS)

DEPINCLUDE=\
	$(shell find $(TOPDIR) -name '*.m')

#BEGIN RULES

default: all

all: $(COMMONLIB) $(REPOSLIB) $(SERVER) $(CLIENT) DEPEND

clean:
	rm -f $(OBJECTS)
	rm -f $(COMMONLIB)
	rm -f $(REPOSLIB)
	rm -f $(CLIENT)
	rm -f $(SERVER)
	rm -Rf $(LIBDIR)

distclean: clean nodepend
	find $(TOPDIR) -name 'Makefile' -exec rm {} \;
	rm -f pcmsrules.mk \;

nodepend:
	find $(TOPDIR) -name '*.m' -exec rm {} \;

$(LIBDIR):
	mkdir -p $(LIBDIR)

$(COMMONLIB): $(COMMONOBJECTS) $(LIBDIR)
	rm -f $(COMMONLIB)
	$(AR) rc $(COMMONLIB) $(COMMONOBJECTS)

$(REPOSLIB): $(REPOSOBJECTS) $(LIBDIR)
	rm -f $(REPOSLIB)
	$(AR) rc $(REPOSLIB) $(REPOSOBJECTS)

$(SERVER): $(COMMONLIB) $(REPOSLIB) $(SERVEROBJECTS)
	$(CC) -o $(SERVER) $(CFLAGS) $(SERVEROBJECTS) $(LIBINCLUDE) $(PCMSLIBS)

$(CLIENT): $(COMMONLIB) $(REPOSLIB) $(CLIENTOBJECTS)
	$(CC) -o $(CLIENT) $(CFLAGS) $(CLIENTOBJECTS) $(LIBREADLINE) $(LIBDIFF) $(LIBINCLUDE) $(PCMSLIBS)

DEPEND: $(patsubst %.o,%.m,$(OBJECTS))

%.o: %.c
	$(CC) $(CFLAGS) $(XCFLAGS) $(INCLUDE) $(COMREADLINE) -o $@ -c $<

%.m: %.c
	@$(CC) $(CFLAGS) $(XCFLAGS) $(COMREADLINE) $(INCLUDE) -E -M $< | $(SEDHACK) > $@

-include $(DEPINCLUDE)
	



1.2       +0 -2      pcms/src/client/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	2001/10/19 03:44:10	1.1
+++ .cvsignore	2001/10/23 23:07:20	1.2
@@ -1,5 +1,3 @@
 Makefile
-pcms
-.*.m
 *.o
 



1.3       +2 -74     pcms/src/client/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/Makefile.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Makefile.in	2001/10/19 17:59:53	1.2
+++ Makefile.in	2001/10/23 23:07:20	1.3
@@ -1,75 +1,3 @@
-# Copyright (C) 2000, The EROS Group, LLC.
-
-.SUFFIXES: .m
-
-
-# Comment out the following if your system does not have readline:
-LIBREADLINE=-lreadline -ltermcap
-READLINE=-DUSE_READLINE -I/usr/include/readline
-LIBDIFF=-L../../libdiff -ldiff
-LIBMALLOC=
-PCMSLIBS=$(LIBINCLUDE) -lpcms -lpcmsrepos
-INCLUDE=-I$(shell pwd)/.. #may be overridden from top
-LIBINCLUDE=-L$(shell pwd)/../common -L$(shell pwd)/../repos
-
-CFLAGS=-g	# may be overridden from top.
-XCFLAGS= $(READLINE) -Wmissing-prototypes -Werror -Wreturn-type $(INCLUDE) 
-
-OBJECTS=\
-	pcms.o \
-	glob.o \
-	nmlist.o \
-	command.o \
-	message.o \
-	verify.o \
-	SubProcess.o \
-	WsEntity.o \
-	FilterSet.o \
-	PendingChange.o \
-	WorkSpace.o \
-	Options.o \
-	Merge.o \
-
-CLIENTLIBS=$(LIBREADLINE) $(LIBDIFF) $(LIBMALLOC) 
-BIN_DEPS=pcms
-
-default: $(BIN_DEPS)
-
-all: $(BIN_DEPS) DEPEND
-
-clean:
-	-rm -f *.pyc *~ *.o .*.m
-	-rm -f pcms 
-
-distclean: clean
-	-rm -f Makefile
-
-pcms: $(OBJECTS)
-	$(CC) -o $@ $(CFLAGS) $(OBJECTS) $(CLIENTLIBS) $(PCMSLIBS)
-
-nodepend:
-	-find . -name '.*.m' -exec rm {} \;
-
-SEDHACK=sed 's,'$*'\.o[ :]*,'$@' &,g'
-
-# The following hack fixes up directory dependencies, and ALSO ensures
-# that the .m files will be rebuilt when appropriate:
-
-DEPEND: $(patsubst %.o,.%.m,$(OBJECTS))
-
-.%.m: %.c
-	@$(CC) $(CFLAGS) $(XCFLAGS) -E -M $< | $(SEDHACK) > $@
-
-%.o: %.c
-	$(CC) $(CFLAGS) $(XCFLAGS) -c $<
-
--include .*.m
-
-
-
-
-
-
-
-
+default:
+	make -C ../ $@
 



1.2       +0 -2      pcms/src/common/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	2001/10/19 03:44:10	1.1
+++ .cvsignore	2001/10/23 23:07:20	1.2
@@ -1,4 +1,2 @@
 Makefile
-libpcms.a
 *.o
-.*.m



1.2       +2 -71     pcms/src/common/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/Makefile.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile.in	2001/10/19 03:44:10	1.1
+++ Makefile.in	2001/10/23 23:07:20	1.2
@@ -1,72 +1,3 @@
-# Copyright (C) 2000, The EROS Group, LLC.
-
-.SUFFIXES: .m
-
-
-# Comment out the following if your system does not have readline:
-READLINE=-DUSE_READLINE -I/usr/include/readline
-INCLUDE=-I$(shell pwd)/..    #may be overridden from top.
-
-CFLAGS=-g	# may be overridden from top.
-XCFLAGS=-Wmissing-prototypes -Werror -Wreturn-type $(READLINE) $(INCLUDE)
-
-OBJECTS=\
-	SDR.o \
-	path.o \
-	util.o \
-	sha1.o \
-	TrueName.o \
-	PtrArray.o \
-	EntityBits.o \
-	Entity.o \
-	EntitySet.o \
-	Change.o \
-	CommitInfo.o \
-	Branch.o \
-	Project.o \
-	Serializable.o \
-	xmalloc.o \
-	os.o
-
-default: all
-
-all-recursive: all
-
-all: libpcms.a  DEPEND
-
-clean:
-	-rm -f *.pyc *~ *.o .*.m
-	-rm -f libpcms.a
-
-distclean: clean
-	-rm -f Makefile
-
-libpcms.a: $(OBJECTS)
-	$(AR) rc libpcms.a $(OBJECTS) 	
-
-nodepend:
-	-find . -name '.*.m' -exec rm {} \;
-
-SEDHACK=sed 's,'$*'\.o[ :]*,'$@' &,g'
-
-# The following hack fixes up directory dependencies, and ALSO ensures
-# that the .m files will be rebuilt when appropriate:
-
-DEPEND: $(patsubst %.o,.%.m,$(OBJECTS))
-
-.%.m: %.c
-	@$(CC) $(CFLAGS) $(XCFLAGS) -E -M $< | $(SEDHACK) > $@
-
-%.o: %.c
-	$(CC) $(CFLAGS) $(XCFLAGS) -c $<
-
--include .*.m
-
-
-
-
-
-
-
-
+default:
+	make -C ../ $@
 



1.2       +1 -0      pcms/src/common/os.c

Index: os.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/os.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- os.c	2001/10/19 03:44:10	1.1
+++ os.c	2001/10/23 23:07:20	1.2
@@ -11,6 +11,7 @@
 char *
 os_GetUserName()
 {
+  
   struct passwd *pw;
 
   uid_t uid = getuid();



1.2       +0 -2      pcms/src/repos/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	2001/10/19 03:44:11	1.1
+++ .cvsignore	2001/10/23 23:07:20	1.2
@@ -1,3 +1 @@
 Makefile
-libpcmsrepos.a
-*.o



1.2       +2 -49     pcms/src/repos/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/Makefile.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile.in	2001/10/19 03:44:11	1.1
+++ Makefile.in	2001/10/23 23:07:20	1.2
@@ -1,50 +1,3 @@
-# Copyright (C) 2000, The EROS Group, LLC.
-
-INCLUDE=-I$(shell pwd)/../ #may be overridden from top
-
-DIRS=fs \
-     common \
-     net
-
-OBJECTS=fs/CachedFileRepos.o \
-	fs/FileRepos.o \
-	net/NetRepository.o \
-	common/Repository.o \
-	common/EntityCache.o \
-	common/URI.o
-
-CFLAGS=-g       # may be overridden from top.
-XCFLAGS= -Wmissing-prototypes -Werror -Wreturn-type $(INCLUDE) 
-
-default: all
-
-all: libpcmsrepos.a 
-
-clean:
-	-rm -f *.pyc *~ *.o .*.m
-	-rm -f libpcmsrepos.a
-
-distclean: clean
-	-rm -f Makefile
-
-libpcmsrepos.a: $(OBJECTS) 
-	$(AR) rc libpcmsrepos.a *.o
-
-depend:
-	-find . -name '.*.m' -exec rm {} \;
-
-SEDHACK=sed 's,'$*'\.o[ :]*,'$@' &,g'
-
-# The following hack fixes up directory dependencies, and ALSO ensures
-# that the .m files will be rebuilt when appropriate:
-
-DEPEND: $(patsubst %.o,.%.m,$(OBJECTS))
-
-.%.m: %.c
-	@$(CC) $(CFLAGS) $(XCFLAGS) -E -M $< | $(SEDHACK) > $@
-
-%.o: %.c
-	$(CC) $(CFLAGS) $(XCFLAGS) -c $<
-
--include .*.m
+default:
+	make -C ../ $@
 



1.1                  pcms/src/repos/common/.cvsignore

Index: .cvsignore
===================================================================
Makefile
*.o



1.1                  pcms/src/repos/common/Makefile.in

Index: Makefile.in
===================================================================
default:
	make -C ../../ $@





1.1                  pcms/src/repos/fs/.cvsignore

Index: .cvsignore
===================================================================
Makefile



1.1                  pcms/src/repos/fs/Makefile.in

Index: Makefile.in
===================================================================
default:
	make -C ../../ $@





1.1                  pcms/src/repos/net/.cvsignore

Index: .cvsignore
===================================================================
Makefile
*.o



1.1                  pcms/src/repos/net/Makefile.in

Index: Makefile.in
===================================================================
default:
	make -C ../../ $@





1.4       +2 -42     pcms/src/server/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/Makefile.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Makefile.in	2001/10/19 17:59:53	1.3
+++ Makefile.in	2001/10/23 23:07:21	1.4
@@ -1,43 +1,3 @@
-.SUFFIXES: .m
+default:
+	make -C ../ $@
 
-INCLUDE=-I$(shell pwd)/..    #may be overridden from top.
-LIBINCLUDE=-L$(shell pwd)/../common -L$(shell pwd)/../repos #may be overridden from top.
-
-CFLAGS=-g
-XCFLAGS=-Wmissing-prototypes -Werror -Wreturn-type $(INCLUDE)
-PCMSLIBS=$(LIBINCLUDE) -lpcms -lpcmsrepos
-
-OBJECTS=pcmsserver.o
-
-BIN_DEPS=pcmsserver
-
-default: $(BIN_DEPS)
-
-all: $(BIN_DEPS) DEPEND
-
-install: all
-
-clean:
-	-rm -f *~ *.o .*.m
-	-rm -f pcmsserver
-
-distclean: clean
-	-rm -f Makefile
-
-pcmsserver: $(OBJECTS)
-	$(CC) -o $@ $(CFLAGS) $(OBJECTS) $(PCMSLIBS)
-
-nodepend:
-	-find . -name '.*.m' -exec rm {}
-
-SEDHACK=sed 's,'$*'\.o[ :]*,'$@' &,g'
-
-DEPEND: $(patsubst %.o,.%.m,$(OBJECTS))
-
-.%.m: %.c
-	@$(CC) $(CFLAGS) $(XCFLAGS) -E -M $< | $(SEDHACK) > $@
-
-%.o: %.c
-	$(CC) $(CFLAGS) $(XCFLAGS) -c $<
-
--include .*.m



1.5       +1 -1      pcms/tests/testvars.sh

Index: testvars.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/testvars.sh,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- testvars.sh	2001/10/19 17:59:53	1.4
+++ testvars.sh	2001/10/23 23:07:21	1.5
@@ -2,7 +2,7 @@
 
 TEST_DIR=$PWD
 
-PCMS="$PWD/../src/client/pcms --flush-io"
+PCMS="$PWD/../src/pcms --flush-io"
 
 # Use this for directory comparison:
 DIRDIFF="diff -q -P -r"




From bastille@snocrash.cs.jhu.edu Wed Oct 24 21:03:19 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id f9P13Jv31126
	for <dcms-cvs@eros.cs.jhu.edu>; Wed, 24 Oct 2001 21:03:19 -0400
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id UAA00691;
	Wed, 24 Oct 2001 20:50:13 -0400
Received: (from bastille@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id f9P133405529;
	Wed, 24 Oct 2001 21:03:03 -0400
Date: Wed, 24 Oct 2001 21:03:03 -0400
From: Raphael Schweber-Koren <bastille@snocrash.cs.jhu.edu>
Message-Id: <200110250103.f9P133405529@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/repos/net NetRepository.h NetRepository.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

bastille    01/10/24 21:03:03

  Modified:    src/repos pcmsrepos.h
               src/repos/common Repository.c Repository.h URI.c
               src/repos/net NetRepository.c
  Added:       src/repos/net NetRepository.h
  Log:
  Connected pcms command line --server directive to the net repository, using the arbitrary "pcms" scheme as the indication of a remote repository.
  
  pcms://srl.cs.jhu.edu:3381://pcms
  -net repository (pcms)
  -host srl.cs.jhu.edu
  -port 3381
  -path /pcms
  
  Added hostname lookup support.
  
  modified NetRepository_connect to take its parameters from Repository->URI, instead of as the standalone test-program, and then go and establish the connection.
  
  At this point it then enters the type your message loop. Next step is to carve this part out and reimplement it as a generic "send this string" function, and save the connection file descriptor.

Revision  Changes    Path
1.2       +1 -0      pcms/src/repos/pcmsrepos.h

Index: pcmsrepos.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/pcmsrepos.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pcmsrepos.h	2001/10/19 03:44:11	1.1
+++ pcmsrepos.h	2001/10/25 01:03:02	1.2
@@ -9,4 +9,5 @@
 #include "repos/common/Repository.h"
 #include "repos/common/EntityCache.h"
 #include "repos/fs/FileRepos.h"
+#include "repos/net/NetRepository.h"
 



1.3       +6 -7      pcms/src/repos/common/Repository.c

Index: Repository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/Repository.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Repository.c	2001/10/19 03:44:11	1.2
+++ Repository.c	2001/10/25 01:03:02	1.3
@@ -89,16 +89,15 @@
   if (uri->relative)
     report_error(EX_NoServer, "Please use a non-relative URI\n");
 
-  if (strcmp(uri->scheme, "file") != 0)
-    unimplemented("Don't know how to open non-file repositories (yet)\n");
+  if ((strcmp(uri->scheme, "file") != 0) && (strcmp(uri->scheme, "pcms") != 0))
+    unimplemented("Don't know how to open non-file, non-net repositories (yet)\n");
   
-  /*if (strcmp(uri->scheme, "file") == 0)
-   *filerepository_init(r);
-   */
-  
   if (strcmp(uri->scheme, "file") == 0)
     cachedfilerepository_init(r);
-  
+
+  if (strcmp(uri->scheme, "pcms") == 0)
+	  netrepository_init(r);
+    
   if (repos_Connect(r) < 0)
     report_error(EX_NoServer, "Cannot connect to server\n");
 



1.3       +1 -0      pcms/src/repos/common/Repository.h

Index: Repository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/Repository.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Repository.h	2001/10/19 03:44:11	1.2
+++ Repository.h	2001/10/25 01:03:02	1.3
@@ -93,6 +93,7 @@
 /* KNOWN TYPES OF REPOSITORIES... */
 extern void filerepository_init(Repository *);
 extern void cachedfilerepository_init(Repository *);
+extern void netrepository_init(Repository *);
 
 /* COMMANDS ON REPOSITORIES */
 extern void pcms_create_repository(Repository *, int argc, char **argv);



1.2       +2 -0      pcms/src/repos/common/URI.c

Index: URI.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/URI.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- URI.c	2001/10/19 03:44:11	1.1
+++ URI.c	2001/10/25 01:03:02	1.2
@@ -102,5 +102,7 @@
   uri->path = xstrdup(s);
   uri->well_formed = 1;
 
+  fprintf(stderr, "\nScheme: %s\nPort: %d\nNetloc: %s\nUsername: %s\nPath: %s\n", uri->scheme, uri->port, uri->netloc, uri->username, uri->path);
+  
   return uri;
 }



1.2       +119 -20   pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NetRepository.c	2001/10/10 22:07:22	1.1
+++ NetRepository.c	2001/10/25 01:03:02	1.2
@@ -1,41 +1,56 @@
-#include "pcms.h"
+#include <pcms.h>
+#include <repos/pcmsrepos.h>
 
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <netdb.h>
 #include <errno.h>
 
 #define PCMSPORT 3399
 #define MAX_MESSAGE_LENGTH 4096
 
-int main(int argc, char** argv) {
+int netrepository_connect(Repository *r) {
+	
+	
 	struct sockaddr_in cliaddr;
 	int connfd;
 	int message_length, mess_sent;
 	char message[MAX_MESSAGE_LENGTH + sizeof(message_length)];	
 	char *input;
+	struct hostent *netlocaddr;
+	struct in_addr **hostptr;
+	int connsucceed;
 	
-	if (argc < 2) {
-		fprintf(stderr, "Usage: netclient <address of pcmsserver>\n");
-		exit(0);
-	}
-
-	if ((connfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-		fprintf(stderr, "Error Creating Socket\n");
-		exit(errno);
+	if ((netlocaddr = gethostbyname2(r->uri->netloc, AF_INET)) == NULL) {
+		printf("%s\n", hstrerror(h_errno));
 	}
+	
+	hostptr = (struct in_addr **) netlocaddr->h_addr_list;
 
+	connfd = socket(AF_INET, SOCK_STREAM, 0);
+	
+	for (connsucceed = 0 ; *hostptr != NULL; hostptr++) {
+	
+		bzero(&cliaddr,sizeof(cliaddr));
+		cliaddr.sin_family = AF_INET;
+		cliaddr.sin_port = htons((r->uri->port == 0) ? PCMSPORT : r->uri->port);
+		memcpy(&cliaddr.sin_addr, *hostptr, sizeof(struct in_addr));
+		
+		fprintf(stderr, "Connecting to %s: %s, port %d\n", r->uri->netloc, inet_ntoa(cliaddr.sin_addr), ntohs(cliaddr.sin_port)); 
 	
-	bzero(&cliaddr,sizeof(cliaddr));
-	cliaddr.sin_family = AF_INET;
-	cliaddr.sin_port = htons(PCMSPORT);
-	cliaddr.sin_addr.s_addr = inet_addr(argv[1]);
-	
-	if (connect(connfd, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
-		fprintf(stderr, "Connect Error\n");
-		exit(errno);
+		if (connect(connfd, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
+			fprintf(stderr, "Connect Error\n");
+		}
+		else {
+			connsucceed = 1;
+			break;
+		}
 	}
+	if (!connsucceed) {
+		exit(-1);
+	}
 
 	bzero(&message, MAX_MESSAGE_LENGTH + sizeof(message_length));
 	
@@ -53,5 +68,89 @@
 		}
 		
 	}
-}	
-	
+}
+
+const char *
+netrepository_GetVersion(Repository *r) {return NULL;}
+  
+  int
+netrepository_CreateProject(Repository *r, Project *p) {return 0;}
+
+  Project *
+netrepository_GetProject(Repository *r, const char *pName) {return NULL;}
+
+Project *
+netrepository_PetGetProject(Repository *r, const char *pName) {return NULL;}
+
+  int 
+netrepository_PetRenameProject(Repository *r,
+				const char *oldName, const char *newName) {return 0;}
+  StrVec * 
+netrepository_ListProjects(Repository *r) {return NULL;}
+
+  StrVec * 
+netrepository_ListProjPetNames(Repository *r, Project *p) {return NULL;}
+
+  StrVec * 
+netrepository_ListBranchPetNames(Repository *r, Branch *b) {return NULL;}
+
+  int 
+netrepository_CreateBranch(Repository *r, Project *p, Branch *b) {return 0;}
+
+  int
+netrepository_PetRenameBranch(Repository *r,
+			       Project *p,
+			       const char *oldName,
+			       const char *newName) {return 0;}
+  Branch *
+netrepository_GetBranch(Repository *r, Project *p,
+			 const char *bName) {return NULL;}
+  Branch *
+netrepository_PetGetBranch(Repository *r, Project *p, const char *bName) {return NULL;}
+
+  int 
+netrepository_ReviseBranch(Repository *r, Project *p, Branch *b) {return 0;}
+
+  StrVec *
+netrepository_ListBranches(Repository *r, Project *p) {return NULL;}
+
+  const char *
+netrepository_ReviseEntity(Repository *r,
+			    const char *tName, void *data) { return NULL; }
+  void *
+netrepository_GetEntity(Repository *r,
+			 const char *tName) {return NULL;}
+
+
+void netrepository_init(Repository * r) {
+  r->GetVersion = netrepository_GetVersion;
+  r->Connect = netrepository_connect;
+
+  r->CreateProject = netrepository_CreateProject;
+  r->GetProject = netrepository_GetProject;
+  r->PetGetProject = netrepository_PetGetProject;
+
+  r->PetRenameProject = netrepository_PetRenameProject;
+
+  /* This interface is wrong! */
+  r->ListProjects = netrepository_ListProjects;
+  r->ListProjPetNames = netrepository_ListProjPetNames;
+
+  /* Manipulation of branches: */
+  r->CreateBranch = netrepository_CreateBranch;
+  r->GetBranch = netrepository_GetBranch;
+  r->PetGetBranch = netrepository_PetGetBranch;
+  r->ReviseBranch = netrepository_ReviseBranch;
+  r->PetRenameBranch = netrepository_PetRenameBranch;
+
+  /* This interface is also wrong! */
+  r->ListBranches = netrepository_ListBranches;
+  r->ListBranchPetNames = netrepository_ListBranchPetNames;
+
+  /* Entity management: -- both 2nd args must be serializables */
+  r->ReviseEntity = netrepository_ReviseEntity;
+  r->GetEntity = netrepository_GetEntity;
+
+  r->cache = NULL;
+
+}



1.1                  pcms/src/repos/net/NetRepository.h

Index: NetRepository.h
===================================================================
/* Copyright (C) 2000, The EROS Group, LLC. */

  int
netrepository_connect(Repository *);

const char *
netrepository_GetVersion(Repository *);
  
  int
netrepository_CreateProject(Repository *, Project *);

  Project *
netrepository_GetProject(Repository *, const char *);

Project *
netrepository_PetGetProject(Repository *, const char *);

  int 
netrepository_PetRenameProject(Repository *,
				const char *, const char *);
  StrVec * 
netrepository_ListProjects(Repository *);

  StrVec * 
netrepository_ListProjPetNames(Repository *, Project *);

  StrVec * 
netrepository_ListBranchPetNames(Repository *, Branch *);

  int 
netrepository_CreateBranch(Repository *, Project *, Branch *);

  int
netrepository_PetRenameBranch(Repository *,
			       Project *,
			       const char *,
			       const char *);
  Branch *
netrepository_GetBranch(Repository *, Project *,
			 const char *);
  Branch *
netrepository_PetGetBranch(Repository *, Project *, const char *);

  int 
netrepository_ReviseBranch(Repository *, Project *, Branch *);

  StrVec *
netrepository_ListBranches(Repository *, Project *);

  const char *
netrepository_ReviseEntity(Repository *,
			    const char *, void *);
  void *
netrepository_GetEntity(Repository *,
			 const char *);
 void
netrepository_init(Repository *);















From bastille@snocrash.cs.jhu.edu Mon Oct 29 15:50:48 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id f9TKomv24482
	for <dcms-cvs@eros.cs.jhu.edu>; Mon, 29 Oct 2001 15:50:48 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id QAA00727;
	Mon, 29 Oct 2001 16:37:04 -0500
Received: (from bastille@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id f9TKo0T19138;
	Mon, 29 Oct 2001 15:50:00 -0500
Date: Mon, 29 Oct 2001 15:50:00 -0500
From: Raphael Schweber-Koren <bastille@snocrash.cs.jhu.edu>
Message-Id: <200110292050.f9TKo0T19138@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/repos/net NetRepository.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

bastille    01/10/29 15:49:59

  Modified:    src/repos/net NetRepository.c
  Log:
  Added 'sendMessage' to netRepository, allows for arbitrarily long message to be sent to server and prepends message length before sending.

Revision  Changes    Path
1.3       +21 -7     pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NetRepository.c	2001/10/25 01:03:02	1.2
+++ NetRepository.c	2001/10/29 20:49:59	1.3
@@ -11,6 +11,8 @@
 #define PCMSPORT 3399
 #define MAX_MESSAGE_LENGTH 4096
 
+void sendMessage(int, const char*);
+
 int netrepository_connect(Repository *r) {
 	
 	
@@ -57,17 +59,29 @@
 	for ( ; ; ) {
 		printf("Enter Message: ");
 
-		input = &message[sizeof(message_length)];
+		input = (char *)pcms_malloc(MAX_MESSAGE_LENGTH * sizeof(char));
 		scanf("%s", input);
 		
-		message_length = strlen(input) + sizeof(message_length);
-		memcpy(message, &message_length, sizeof(message_length));
+		sendMessage(connfd, input);
+	}
+}
+
+void sendMessage(int connfd, const char* messagebuf) {
 	
-		if (write(connfd, message, message_length) != message_length) {
-			fprintf(stderr, "Not All Data Sent\n");
-		}
-		
+	int message_length;
+	char* message;
+        
+	message_length = strlen(messagebuf) + sizeof(message_length);
+	message = (char *)pcms_malloc(message_length * sizeof(char));
+	
+	memcpy(message+sizeof(message_length), messagebuf, strlen(messagebuf));
+	memcpy(message, &message_length, sizeof(message_length));
+	
+	if (write(connfd, message, message_length) != message_length) {
+		fprintf(stderr, "Not All Data Sent\n");
 	}
+	
+	return;
 }
 
 const char *




From bastille@snocrash.cs.jhu.edu Mon Nov  5 14:30:49 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA5JUnv02115
	for <dcms-cvs@eros.cs.jhu.edu>; Mon, 5 Nov 2001 14:30:49 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id PAA01009;
	Mon, 5 Nov 2001 15:16:08 -0500
Received: (from bastille@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA5JT7K26924;
	Mon, 5 Nov 2001 14:29:07 -0500
Date: Mon, 5 Nov 2001 14:29:07 -0500
From: Raphael Schweber-Koren <bastille@snocrash.cs.jhu.edu>
Message-Id: <200111051929.fA5JT7K26924@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/repos/net NetRepository.c NetRepository.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

bastille    01/11/05 14:29:07

  Modified:    src      pcms.h
               src/repos/common Repository.h
               src/repos/fs CachedFileRepos.c FileRepos.c
               src/repos/net NetRepository.c NetRepository.h
  Log:
  Externalized the connection file descriptor so it's usable. Wrote the outbound portion of the Getversion and create project wrappers in Net Repository.

Revision  Changes    Path
1.11      +2 -0      pcms/src/pcms.h

Index: pcms.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/pcms.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- pcms.h	2001/10/19 03:44:10	1.10
+++ pcms.h	2001/11/05 19:29:06	1.11
@@ -49,6 +49,8 @@
 #include "common/os.h"
 #include "common/sha1.h"
 
+#include "common/pcms_opcode.h"
+
 #ifndef __unix__
 #define BROKEN_FS_ENTITIES
 #endif



1.4       +2 -1      pcms/src/repos/common/Repository.h

Index: Repository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/Repository.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Repository.h	2001/10/25 01:03:02	1.3
+++ Repository.h	2001/11/05 19:29:06	1.4
@@ -20,7 +20,8 @@
   AuthInfo    *auth;
   void        *info;		/* type specific info */
   EntityCache *cache;
-
+  int 	      *connfd;
+  
   const char *(*GetVersion)(Repository *r);
 
   // Establishing a connection to the repository:



1.3       +1 -0      pcms/src/repos/fs/CachedFileRepos.c

Index: CachedFileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/CachedFileRepos.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CachedFileRepos.c	2001/10/19 03:44:11	1.2
+++ CachedFileRepos.c	2001/11/05 19:29:06	1.3
@@ -245,6 +245,7 @@
   r->GetEntity = cachedfilerepository_GetEntity;
 
   r->cache = createEntityCache();
+  r->connfd = NULL;
 }
 
 



1.3       +1 -0      pcms/src/repos/fs/FileRepos.c

Index: FileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileRepos.c	2001/10/19 03:44:11	1.2
+++ FileRepos.c	2001/11/05 19:29:07	1.3
@@ -627,6 +627,7 @@
   r->GetEntity = filerepository_GetEntity;
 
   r->cache = NULL;
+  r->connfd = NULL;
 }
 
 



1.4       +64 -21    pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NetRepository.c	2001/10/29 20:49:59	1.3
+++ NetRepository.c	2001/11/05 19:29:07	1.4
@@ -9,29 +9,30 @@
 #include <errno.h>
 
 #define PCMSPORT 3399
-#define MAX_MESSAGE_LENGTH 4096
 
-void sendMessage(int, const char*);
+inline void sendStr(int connectfd, const char* messagebuf);
+inline void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen);
 
 int netrepository_connect(Repository *r) {
 	
 	
 	struct sockaddr_in cliaddr;
-	int connfd;
-	int message_length, mess_sent;
-	char message[MAX_MESSAGE_LENGTH + sizeof(message_length)];	
-	char *input;
+	/*int message_length, mess_sent;*/
+	/*char message[4096 + sizeof(message_length)];
+	char *input;*/
 	struct hostent *netlocaddr;
 	struct in_addr **hostptr;
 	int connsucceed;
 	
+	r->connfd = (int *)pcms_malloc(sizeof(int));
+	
 	if ((netlocaddr = gethostbyname2(r->uri->netloc, AF_INET)) == NULL) {
 		printf("%s\n", hstrerror(h_errno));
 	}
 	
 	hostptr = (struct in_addr **) netlocaddr->h_addr_list;
 
-	connfd = socket(AF_INET, SOCK_STREAM, 0);
+	*(r->connfd) = socket(AF_INET, SOCK_STREAM, 0);
 	
 	for (connsucceed = 0 ; *hostptr != NULL; hostptr++) {
 	
@@ -42,7 +43,7 @@
 		
 		fprintf(stderr, "Connecting to %s: %s, port %d\n", r->uri->netloc, inet_ntoa(cliaddr.sin_addr), ntohs(cliaddr.sin_port)); 
 	
-		if (connect(connfd, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
+		if (connect(*(r->connfd), (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
 			fprintf(stderr, "Connect Error\n");
 		}
 		else {
@@ -53,8 +54,10 @@
 	if (!connsucceed) {
 		exit(-1);
 	}
+
+	return 0;
 
-	bzero(&message, MAX_MESSAGE_LENGTH + sizeof(message_length));
+	/*bzero(&message, MAX_MESSAGE_LENGTH + sizeof(message_length));
 	
 	for ( ; ; ) {
 		printf("Enter Message: ");
@@ -62,22 +65,25 @@
 		input = (char *)pcms_malloc(MAX_MESSAGE_LENGTH * sizeof(char));
 		scanf("%s", input);
 		
-		sendMessage(connfd, input);
-	}
+		sendMessage(*(r->connfd), input);
+	}*/
+}
+
+void sendStr(int connectfd, const char* messagebuf) {
+	
+	sendBuff(connectfd, messagebuf, strlen(messagebuf));
 }
 
-void sendMessage(int connfd, const char* messagebuf) {
+void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen) {
 	
-	int message_length;
 	char* message;
-        
-	message_length = strlen(messagebuf) + sizeof(message_length);
-	message = (char *)pcms_malloc(message_length * sizeof(char));
+
+	message = (char *)pcms_malloc(msglen * sizeof(char));
 	
-	memcpy(message+sizeof(message_length), messagebuf, strlen(messagebuf));
-	memcpy(message, &message_length, sizeof(message_length));
+	memcpy(message+sizeof(msglen), messagebuf, msglen - sizeof(msglen));
+	memcpy(message, &msglen, sizeof(msglen));
 	
-	if (write(connfd, message, message_length) != message_length) {
+	if (write(connectfd, message, msglen) != msglen) {
 		fprintf(stderr, "Not All Data Sent\n");
 	}
 	
@@ -85,10 +91,46 @@
 }
 
 const char *
-netrepository_GetVersion(Repository *r) {return NULL;}
+netrepository_GetVersion(Repository *r) {
+	SDR_stream* net_stream;
+	int opcode;
+	char* net_buf;
+
+	net_stream = stream_openstring(STREAM_XML);
+	opcode = PCMS_OPCODE_GETVERSION;
+	
+	sdr_write("opcode name=\"getversion\"", net_stream, &opcode);
+	sdr_write("string name=\"Repository Path\"", net_stream, r->uri->path);
+
+	net_buf = (char *)net_stream->data;
+
+	sendBuff(*(r->connfd), net_buf, net_stream->len);
+
+	stream_close(net_stream);
+	return NULL;
+}
   
   int
-netrepository_CreateProject(Repository *r, Project *p) {return 0;}
+netrepository_CreateProject(Repository *r, Project *p) {
+	SDR_stream* net_stream;
+	int opcode;
+	char *net_buf;
+	
+	net_stream = stream_openstring(STREAM_XML);
+	opcode = PCMS_OPCODE_CREATEPROJECT;
+	
+	sdr_write("opcode name=\"createproject\"", net_stream, &opcode);
+	sdr_write("string name=\"Repository Path\"", net_stream, r->uri->path);
+	sdr_write("string name=\"Project\"", net_stream, p);
+
+	net_buf = (char *)net_stream->data;
+
+	sendBuff(*(r->connfd), net_buf, net_stream->len);
+
+	stream_close(net_stream);
+	return 0;
+	
+}
 
   Project *
 netrepository_GetProject(Repository *r, const char *pName) {return NULL;}
@@ -166,5 +208,6 @@
   r->GetEntity = netrepository_GetEntity;
 
   r->cache = NULL;
+  r->connfd = NULL;
 
 }



1.2       +6 -1      pcms/src/repos/net/NetRepository.h

Index: NetRepository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NetRepository.h	2001/10/25 01:03:02	1.1
+++ NetRepository.h	2001/11/05 19:29:07	1.2
@@ -5,7 +5,7 @@
 
 const char *
 netrepository_GetVersion(Repository *);
-  
+
   int
 netrepository_CreateProject(Repository *, Project *);
 
@@ -18,6 +18,7 @@
   int 
 netrepository_PetRenameProject(Repository *,
 				const char *, const char *);
+
   StrVec * 
 netrepository_ListProjects(Repository *);
 
@@ -35,9 +36,11 @@
 			       Project *,
 			       const char *,
 			       const char *);
+
   Branch *
 netrepository_GetBranch(Repository *, Project *,
 			 const char *);
+
   Branch *
 netrepository_PetGetBranch(Repository *, Project *, const char *);
 
@@ -50,9 +53,11 @@
   const char *
 netrepository_ReviseEntity(Repository *,
 			    const char *, void *);
+
   void *
 netrepository_GetEntity(Repository *,
 			 const char *);
+
  void
 netrepository_init(Repository *);
 




From bastille@snocrash.cs.jhu.edu Mon Nov  5 14:33:43 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA5JXhv02145
	for <dcms-cvs@eros.cs.jhu.edu>; Mon, 5 Nov 2001 14:33:43 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id PAA01030;
	Mon, 5 Nov 2001 15:19:02 -0500
Received: (from bastille@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA5JW1k27013;
	Mon, 5 Nov 2001 14:32:01 -0500
Date: Mon, 5 Nov 2001 14:32:01 -0500
From: Raphael Schweber-Koren <bastille@snocrash.cs.jhu.edu>
Message-Id: <200111051932.fA5JW1k27013@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server .cvsignore
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

bastille    01/11/05 14:32:01

  Modified:    .        .cvsignore
               src      .cvsignore
               src/client .cvsignore
               src/common .cvsignore
               src/repos .cvsignore
               src/repos/common .cvsignore
               src/repos/fs .cvsignore
               src/repos/net .cvsignore
               src/server .cvsignore
  Log:
  Added *.m to all source tree .cvsignores. Little minor fix.

Revision  Changes    Path
1.4       +1 -1      pcms/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/.cvsignore,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- .cvsignore	2000/09/25 19:01:24	1.3
+++ .cvsignore	2001/11/05 19:32:00	1.4
@@ -1,4 +1,4 @@
-.*.m
+*.m
 pcms
 .pcms
 config.cache



1.7       +1 -0      pcms/src/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/.cvsignore,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- .cvsignore	2001/10/23 23:07:20	1.6
+++ .cvsignore	2001/11/05 19:32:00	1.7
@@ -1,3 +1,4 @@
 Makefile
 pcmsrules.mk
 .depend
+*.m



1.3       +1 -0      pcms/src/client/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- .cvsignore	2001/10/23 23:07:20	1.2
+++ .cvsignore	2001/11/05 19:32:00	1.3
@@ -1,3 +1,4 @@
 Makefile
 *.o
 
+*.m



1.3       +1 -0      pcms/src/common/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- .cvsignore	2001/10/23 23:07:20	1.2
+++ .cvsignore	2001/11/05 19:32:00	1.3
@@ -1,2 +1,3 @@
 Makefile
 *.o
+*.m



1.3       +1 -0      pcms/src/repos/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- .cvsignore	2001/10/23 23:07:20	1.2
+++ .cvsignore	2001/11/05 19:32:00	1.3
@@ -1 +1,2 @@
 Makefile
+*.m



1.2       +1 -0      pcms/src/repos/common/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	2001/10/23 23:07:21	1.1
+++ .cvsignore	2001/11/05 19:32:00	1.2
@@ -1,2 +1,3 @@
 Makefile
 *.o
+*.m



1.2       +1 -0      pcms/src/repos/fs/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	2001/10/23 23:07:21	1.1
+++ .cvsignore	2001/11/05 19:32:00	1.2
@@ -1 +1,2 @@
 Makefile
+*.m



1.2       +1 -0      pcms/src/repos/net/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	2001/10/23 23:07:21	1.1
+++ .cvsignore	2001/11/05 19:32:00	1.2
@@ -1,2 +1,3 @@
 Makefile
 *.o
+*.m



1.2       +1 -0      pcms/src/server/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- .cvsignore	2001/10/19 03:44:11	1.1
+++ .cvsignore	2001/11/05 19:32:00	1.2
@@ -2,3 +2,4 @@
 Makefile
 *.o
 .*.m
+*.m




From bastille@snocrash.cs.jhu.edu Mon Nov  5 14:51:23 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA5JpNv02226
	for <dcms-cvs@eros.cs.jhu.edu>; Mon, 5 Nov 2001 14:51:23 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id PAA01069;
	Mon, 5 Nov 2001 15:36:41 -0500
Received: (from bastille@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA5Jnes27148;
	Mon, 5 Nov 2001 14:49:40 -0500
Date: Mon, 5 Nov 2001 14:49:40 -0500
From: Raphael Schweber-Koren <bastille@snocrash.cs.jhu.edu>
Message-Id: <200111051949.fA5Jnes27148@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common pcms_opcode.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

bastille    01/11/05 14:49:40

  Added:       src/common pcms_opcode.h
  Log:
  Opcodes for client/server ops.

Revision  Changes    Path
1.1                  pcms/src/common/pcms_opcode.h

Index: pcms_opcode.h
===================================================================
#ifndef __PCMS_OPCODE_H__
#define __PCMS_OPCODE_H__

#define PCMS_OPCODE_GETVERSION 500
#define PCMS_OPCODE_CREATEPROJECT 501
#define PCMS_OPCODE_GETPROJECT 502
#define PCMS_OPCODE_PETGETPROJECT 503
#define PCMS_OPCODE_PETRENAMEPROJECT 504
#define PCMS_OPCODE_LISTPROJECTS 505
#define PCMS_OPCODE_LISTPROJPETNAMES 506
#define PCMS_OPCODE_LISTBRANCHPETNAMES 507
#define PCMS_OPCODE_CREATEBRANCH 508
#define PCMS_OPCODE_PETRENAMEBRANCH 509
#define PCMS_OPCODE_GETBRANCH 510
#define PCMS_OPCODE_PETGETBRANCH 511
#define PCMS_OPCODE_REVISEBRANCH 512
#define PCMS_OPCODE_LISTBRANCHES 514
#define PCMS_OPCODE_REVISEENTITY 515
#define PCMS_OPCODE_GETENTITY 516

#endif





From shap@snocrash.cs.jhu.edu Tue Nov  6 17:27:49 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA6MRmv25931
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 6 Nov 2001 17:27:48 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA00783;
	Tue, 6 Nov 2001 18:12:59 -0500
Received: (from shap@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA6MPrl03365;
	Tue, 6 Nov 2001 17:25:53 -0500
Date: Tue, 6 Nov 2001 17:25:53 -0500
From: "Jonathan S. Shapiro" <shap@snocrash.cs.jhu.edu>
Message-Id: <200111062225.fA6MPrl03365@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common SDR.c SDR.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

shap        01/11/06 17:25:53

  Modified:    src/common SDR.c SDR.h
  Log:
  Add a fromstring deserializer

Revision  Changes    Path
1.3       +24 -0     pcms/src/common/SDR.c

Index: SDR.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/SDR.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SDR.c	2001/10/19 03:44:10	1.2
+++ SDR.c	2001/11/06 22:25:53	1.3
@@ -482,6 +482,30 @@
   return stream;
 }
 
+SDR_stream*
+stream_fromstring(unsigned format, const char *buffer,
+		  unsigned len)
+{
+  SDR_stream *stream = (SDR_stream *) pcms_malloc(sizeof(SDR_stream));
+
+  stream->mode   = RSTREAM;
+  stream->format = format;
+  stream->indent = 0;
+  stream->type   = STRING_STREAM;
+
+  stream->data = buffer;
+  stream->strm_getc = string_stream_getc;
+  stream->strm_putc = string_stream_putc;
+  stream->strm_close = string_stream_close;
+
+  stream->pos = 0;
+  stream->len = len;
+  stream->bound = len;
+  stream->have_pushback = FALSE;
+
+  return stream;
+}
+
 
 struct serializer {
   void           (*w_ulong)(const char *, SDR_stream *, unsigned long);



1.2       +2 -0      pcms/src/common/SDR.h

Index: SDR.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/SDR.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SDR.h	2001/10/10 22:07:21	1.1
+++ SDR.h	2001/11/06 22:25:53	1.2
@@ -35,6 +35,8 @@
 SDR_stream*    stream_openfile(const char *fileName, unsigned mode,
 			       unsigned format);
 SDR_stream*    stream_openstring(unsigned format);
+SDR_stream*    stream_fromstring(unsigned format, const char *buffer,
+				 unsigned len);
 
 void           stream_close(SDR_stream*);
 




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:13:59 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8NDxv02298
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:13:59 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA01158;
	Thu, 8 Nov 2001 18:58:53 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8NBqL19442;
	Thu, 8 Nov 2001 18:11:52 -0500
Date: Thu, 8 Nov 2001 18:11:52 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082311.fA8NBqL19442@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common util.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:11:52

  Modified:    src/common util.c
  Log:
  Moved xstr* functions from client code to here, since server now needs them.

Revision  Changes    Path
1.3       +67 -0     pcms/src/common/util.c

Index: util.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/util.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- util.c	2001/10/19 03:44:10	1.2
+++ util.c	2001/11/08 23:11:52	1.3
@@ -1,5 +1,72 @@
 #include <pcms.h>
 
+char *ServerURI = 0;
+
+int
+validate_pet_name(const char *s)
+{
+  if (s == 0)
+    return 0;
+  if (strlen(s) == 0)
+    return 0;
+
+  if (s[0] == '-' || s[0] == '.')
+    return 0;
+      
+  while (*s) {
+    char c = *s++;
+    if (isalnum(c) == 0 &&
+	c != '_' &&
+	c != '.' &&
+	c != '-')
+      return 0;
+  }
+
+  return 1;  
+}
+
+char *
+xstrcat(const char *s1, const char *s2)
+{
+  char *news =
+    (char *) pcms_malloc (sizeof(char) * (strlen(s1) + strlen(s2) + 1));
+  if (news == 0)
+    report_error(EX_NoMemory, "Out of memory\n");
+
+  strcpy(news, s1);
+  strcat(news, s2);
+  return news;
+}
+
+char *
+xstrdup(const char *s)
+{
+  char *news =
+    (char *) pcms_malloc(sizeof(char) * (strlen(s) + 1));
+  if (news == 0)
+    report_error(EX_NoMemory, "Out of memory\n");
+
+  strcpy(news, s);
+  return news;
+}
+
+char *
+xstrndup(const char *s, int len)
+{
+  char *news;
+  
+  if (strlen(s) < len)
+    return xstrdup(s);
+
+  news = (char *) pcms_malloc(sizeof(char) * (len + 1));
+  if (news == 0)
+    report_error(EX_NoMemory, "Out of memory\n");
+
+  strncpy(news, s, len);
+  news[len] = 0;
+  return news;
+}
+
 int
 nmequal(const char *s1, const char *s2)
 {




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:14:28 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8NESv02356
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:14:28 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA01181;
	Thu, 8 Nov 2001 18:59:22 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8NCLO19482;
	Thu, 8 Nov 2001 18:12:21 -0500
Date: Thu, 8 Nov 2001 18:12:21 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082312.fA8NCLO19482@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/client pcms.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:12:21

  Modified:    src/client pcms.c
  Log:
  Moved some code needed by server to the 'util.c' file.

Revision  Changes    Path
1.3       +6 -1      pcms/src/client/pcms.c

Index: pcms.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/pcms.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pcms.c	2001/10/19 03:44:10	1.2
+++ pcms.c	2001/11/08 23:12:21	1.3
@@ -6,8 +6,11 @@
 #include <repos/pcmsrepos.h>
 #include "pcmsclient.h"
 
-char *ServerURI = 0;
+/***
+ char *ServerURI = 0;
+ ****/
 
+/****
 int
 validate_pet_name(const char *s)
 {
@@ -72,6 +75,8 @@
   news[len] = 0;
   return news;
 }
+*****/
+
 
 void
 pcms_rename_branch(Repository *r, int argc, char **argv)




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:13:06 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8ND6v02278
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:13:06 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA01126;
	Thu, 8 Nov 2001 18:57:59 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8NAxQ19407;
	Thu, 8 Nov 2001 18:10:59 -0500
Date: Thu, 8 Nov 2001 18:10:59 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082310.fA8NAxQ19407@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common Serializable.h Serializable.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:10:59

  Modified:    src/common Serializable.h Serializable.c
  Log:
  Added support for new Serializable objects:  ServerRequest and ServerReply

Revision  Changes    Path
1.2       +2 -0      pcms/src/common/Serializable.h

Index: Serializable.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/Serializable.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Serializable.h	2001/10/10 22:07:21	1.1
+++ Serializable.h	2001/11/08 23:10:59	1.2
@@ -17,6 +17,8 @@
   TY_COMMITINFOv0,
 
   /* Add new entries here... */
+  TY_SERVERREQUESTv0,
+  TY_SERVERREPLYv0,
   
   TY_ntypes
 };



1.3       +7 -0      pcms/src/common/Serializable.c

Index: Serializable.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/Serializable.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Serializable.c	2001/10/19 03:44:10	1.2
+++ Serializable.c	2001/11/08 23:10:59	1.3
@@ -41,6 +41,10 @@
 extern SerialType StrVec_SerType;
 extern SerialType WsEntity_SerType;
 
+extern SerialType CommitInfo_SerType;
+extern SerialType ServerRequest_SerType;
+extern SerialType ServerReply_SerType;
+
 SerialType *serTypes[TY_ntypes] = {
   &Null_SerType,
   &Project_SerType,
@@ -53,6 +57,9 @@
   &ObVec_SerType,
   &StrVec_SerType,
   &WsEntity_SerType,
+  &CommitInfo_SerType,
+  &ServerRequest_SerType,
+  &ServerReply_SerType
 } ;
 
 SerialType *




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:13:29 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8NDTv02291
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:13:29 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA01147;
	Thu, 8 Nov 2001 18:58:22 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8NBMx19426;
	Thu, 8 Nov 2001 18:11:22 -0500
Date: Thu, 8 Nov 2001 18:11:22 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082311.fA8NBMx19426@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common pcms_opcode.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:11:22

  Modified:    src/common pcms_opcode.h
  Log:
  Misc changes.

Revision  Changes    Path
1.2       +17 -0     pcms/src/common/pcms_opcode.h

Index: pcms_opcode.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/pcms_opcode.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pcms_opcode.h	2001/11/05 19:49:40	1.1
+++ pcms_opcode.h	2001/11/08 23:11:22	1.2
@@ -18,5 +18,22 @@
 #define PCMS_OPCODE_REVISEENTITY 515
 #define PCMS_OPCODE_GETENTITY 516
 
+/* Need some commonly defined XML element names: */
+#define SERVERREQUEST "Request"
+#define SERVERREPLY "Reply"
+#define GETVERSION "version"
+#define CREATEPROJECT "createProject"
+#define GETPROJECT "getProject"
+#define PETGETPROJECT "getPetProject"
+#define PETRENAMEPROJECT "renamePetProject"
+#define LISTPROJECTS "listProjects"
+#define LISTPROJPETNAMES "listProjectPetNames"
+#define LISTBRANCHPETNAMES "listBranchPetNames"
+#define CREATEBRANCH "createBranch"
+#define PETRENAMEBRANCH "renamePetBranch"
+#define GETBRANCH "getBranch"
+#define PETGETBRANCH "getPetBranch"
+#define REVISEBRANCH "reviseBranch"
+
 #endif
 




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:10:37 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8NAbv02194
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:10:37 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA01066;
	Thu, 8 Nov 2001 18:55:31 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8N8UH19322;
	Thu, 8 Nov 2001 18:08:30 -0500
Date: Thu, 8 Nov 2001 18:08:30 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082308.fA8N8UH19322@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server pcmsserver.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:08:30

  Modified:    src/server pcmsserver.c
  Log:
  Added support for queueing and processing client requests.

Revision  Changes    Path
1.4       +191 -43   pcms/src/server/pcmsserver.c

Index: pcmsserver.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/pcmsserver.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- pcmsserver.c	2001/10/19 03:44:11	1.3
+++ pcmsserver.c	2001/11/08 23:08:30	1.4
@@ -1,27 +1,76 @@
 #include <pcms.h>
 #include "pcmsserver.h"
 
-#define MAX_CLIENTS 10
+#include <fcntl.h>
+#include "../../junk/MsgQueue.h"
+#include <./repos/pcmsrepos.h>
+#include <./common/ServerRequest.h>
+#include <./common/ServerReply.h>
+
+#define MAX_CLIENTS 100
 #define MESSAGE_LENGTH 4096
 
+#define SIZEOFREQUESTQUEUE 100
+
 void quitter(int);
 
 int quit;
 
+/****************************************************
+* M A I N   processing loop.
+*
+* This is just a classic TCP socket server loop
+* using the select() call to determine when sockets
+* of interest have activiy.  General logic is:
+* - listen for incoming connection requests
+* - accept a connection and add new socket to list
+* - for each socket in connection list
+*   -- read from socket and create a "server request"
+*   -- add that "server request" object to a Q
+* - for any queued replies, dequeue them and write
+*   replies to sockets
+*
+* - while request queue is not empty
+*   -- dequeue, parse, and execute
+*   -- add result to reply queue
+****************************************************/
 int main() {
 	struct sockaddr_in servaddr, cliaddr;
 	int servfd;
-	fd_set fullset, tempset, dummyset;
-	int sockactive[MAX_CLIENTS];
+	fd_set fullset, incomingset, outgoingset;
 	int clients[MAX_CLIENTS];
-	int top_client_id;
-	int select_res;
+	int index;
+	int select_ready;
 	char message[MESSAGE_LENGTH];
 	int lmess, trmess;
 	int i, clidx, readres,clientlen;
 	struct sigaction quit_action;
 	struct timeval tv;
 	
+int val;
+int numread;
+ServerRequest *nextRequest;
+ServerRequest *thisRequest;
+ServerReply *thisReply;
+MsgQueue *readq = CreateMsgQueue(SIZEOFREQUESTQUEUE, sizeof(ServerRequest));
+MsgQueue *writeq = CreateMsgQueue(SIZEOFREQUESTQUEUE, sizeof(ServerReply));
+SDR_stream *strm;
+char *repos;
+int x;
+unsigned int code;
+Repository *localRepos;
+URI *localURI;
+char *localURIstr;
+const char *retVersion;
+ServerReply *reply;
+SDR_stream *reply_strm;
+unsigned int len;
+int client_socket;
+int sockfd;
+int max_index_into_clients;
+int max_sockfd_so_far;
+char *tooManyClients = "Connection refused... too many clients.";
+
 	quit_action.sa_handler = (&quitter);
 	
 	quit = 0;
@@ -29,13 +78,16 @@
 	sigaction(SIGINT, &quit_action, NULL);
 	
 	for (i = 0; i < MAX_CLIENTS; i++) {
-		sockactive[i] = clients[i] = 0;
+	    clients[i] = -1;
 	}
 
 	if ((servfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
 		fprintf(stderr, "Socket Creation Error\n");
 		exit(errno);
 	}
+/* try non-blocking I/O: */
+val = fcntl(servfd, F_GETFL, 0);
+fcntl(servfd, F_SETFL, val | O_NONBLOCK);
 
 	bzero(&servaddr, sizeof(servaddr));
 	bzero(&cliaddr, sizeof(cliaddr));
@@ -54,54 +106,150 @@
 		exit(errno);
 	}
 
-	top_client_id = 0;
 	FD_ZERO(&fullset);
-	FD_ZERO(&dummyset);
+	FD_ZERO(&outgoingset);
 	FD_SET(servfd, &fullset);
-	
+	max_sockfd_so_far = servfd;
+	max_index_into_clients = -1;
 	
 	while(!quit) {
-		tempset = fullset;
+		incomingset = fullset;
 	
 		tv.tv_sec = 0;
 		tv.tv_usec = 500;
 		
-		select_res = select(FD_SETSIZE, &tempset, &dummyset, &dummyset, &tv);
+		select_ready = select(max_sockfd_so_far + 1, &incomingset, &outgoingset, NULL, &tv);
 
-		if (select_res > 0) {
-			if (FD_ISSET(servfd, &tempset)) {
+		if (select_ready > 0) {
+			if (FD_ISSET(servfd, &incomingset)) {
+				printf ("*** servfd is ready.\n");
 				clientlen = sizeof(cliaddr);
-				clients[top_client_id] = accept(servfd, (struct sockaddr *) &cliaddr, &clientlen);
+				client_socket = accept(servfd, (struct sockaddr *) &cliaddr, &clientlen);
 				fprintf(stderr, "Got Connection From %s\n", inet_ntoa(cliaddr.sin_addr));
-				FD_SET(clients[top_client_id], &fullset);
-				sockactive[top_client_id] = 1;
-				top_client_id++;
-			}
-			for (clidx = 0; clidx < top_client_id; clidx++) {
-				if (sockactive[clidx]) {
-					if ( FD_ISSET(clients[clidx], &tempset)) {
-						if ( (readres = read(clients[clidx], &lmess, sizeof(lmess))) > 0) {
-							trmess = lmess - sizeof(lmess);
-							read(clients[clidx], message, trmess);
-							message[trmess] = '\0';
-							
-							fprintf(stdout, "Reading from socket: %d\n", clidx);
-							fprintf(stdout, "Message: %s\n", message);
-						}
-						else if ((readres < 0) && (errno == EAGAIN)) {
-								
-						}
-						else {
-							fprintf(stdout, "Closing Connection #%d\n", clidx);
-							FD_CLR(clients[clidx], &fullset);
-							close(clients[clidx]);
-							sockactive[clidx] = 0;
-						}
-					}
-				}
-			}
-		}
-	}
+
+				/* Save the client socket file descriptor in an "active" list: */
+				for (index = 0; index < MAX_CLIENTS; index++) {
+				    if (clients[index] < 0) {
+					clients[index] = client_socket;
+					break;
+				    } /* end if */
+				} /* end for loop */
+
+				/* Check for too many clients connected right now: */
+				if (index == MAX_CLIENTS) {
+				    write (client_socket, tooManyClients, strlen(tooManyClients));
+				    close(client_socket);
+				} /* end if too many clients */
+
+				/* Add this new socket to the fd_set: */
+				FD_SET(client_socket, &fullset);
+				if (client_socket > max_sockfd_so_far)
+				    max_sockfd_so_far = client_socket;
+
+				if (index > max_index_into_clients)
+				    max_index_into_clients = index;
+
+/*				select_ready--;   */
+
+			} /* end if FD_ISSET servfd  */   
+
+			/* After accepting a client's connect, check if there's still other pending events: */
+			if (select_ready > 0) {  
+			    for (i = 0; i <= max_index_into_clients; i++) {
+				if ( (sockfd = clients[i]) > 0) {
+				    if (FD_ISSET(sockfd, &incomingset)) {
+					if ( (readres = read(sockfd, &lmess, sizeof(lmess))) == 0) { 
+					    close(sockfd);
+					    FD_CLR(sockfd, &fullset);
+					    clients[i] = -1;
+					} else {
+					    numread = read(clients[clidx], message, lmess);
+					    assert (numread > 0);
+
+					    /* Read the request: */
+					    strm = stream_fromstring(STREAM_XML, message, strlen(message));
+					    nextRequest = sdr_read(SERVERREQUEST, strm);
+
+					    /* Be sure to store the specific socket for this request: */
+					    nextRequest->sockfd = sockfd;
+
+					    /* Now add it to the queue: */
+					    AddToMsgQueue(readq, nextRequest);  
+					    stream_close(strm);
+					} /* end if-else socket still active */
+
+				    } /* end if FD_ISSET on sockfd */
+				} /* end if checking if valid sockfd in list  */
+			    } /* end for-loop into all active clients  */
+
+			}  /* end if select_ready > 0 */
+
+			/********************************************
+		 	 * Now process outgoing replies:
+			 ********************************************/ 
+			while (!IsEmptyMsgQueue(writeq)) {
+			    thisReply = (ServerReply *)GetFromMsgQueue(writeq);
+			    if (FD_ISSET(thisReply->sockfd, &outgoingset)) {
+				reply_strm = stream_openstring(STREAM_XML);
+				sdr_write(SERVERREPLY, reply_strm, thisReply);
+				retVersion = (char *)reply_strm->data;
+				len = strlen(retVersion);
+				write (thisReply->sockfd, &len, sizeof(len));  
+				write (thisReply->sockfd, retVersion, len);
+				stream_close(reply_strm);
+				FD_CLR(thisReply->sockfd, &outgoingset);
+			    } /* end if FD_ISSET */
+
+			} /* end while not IsEmptyMsgQueue(writeq) */
+
+		    } /* end if select_ready > 0 */
+
+		    /***********************************************
+		     * Now process incoming requests:
+		     ***********************************************/
+		    while (!IsEmptyMsgQueue(readq)) {
+			thisRequest = (ServerRequest *)GetFromMsgQueue(readq);
+			switch (thisRequest->opcode) {
+
+			    case PCMS_OPCODE_GETVERSION:
+
+				/* Idea is that repos should be a file repository on this
+				*  server, so instantiate a FileRepos object for this command:
+				*/
+				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
+				strncpy(localURIstr, "file:",5);
+				strcat(localURIstr, nextRequest->repos_path);
+				localRepos = repository_open(localURIstr, 0);
+				
+				/* Now use the local file repository to get the version
+				*  and write that back to the client via its socket:
+				*/
+				reply = reply_create(filerepository_GetVersion(localRepos), thisRequest->sockfd);
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &outgoingset);
+
+				break;
+			    case PCMS_OPCODE_CREATEPROJECT:
+				break;
+			    case PCMS_OPCODE_GETPROJECT:
+				break;
+			    case PCMS_OPCODE_PETGETPROJECT:
+				break;
+			    case PCMS_OPCODE_PETRENAMEPROJECT:
+				break;
+			    case PCMS_OPCODE_LISTPROJECTS:
+				break;
+			    case PCMS_OPCODE_LISTPROJPETNAMES:
+				break;
+			    default:
+				break;
+			} /* end switch block */
+
+		    } /* end while not IsEmptyMsgQueue */
+
+	}  /* end while !quit */
 
 	close(servfd);
 	printf("Closing...\n");




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:11:24 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8NBOv02230
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:11:24 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA01091;
	Thu, 8 Nov 2001 18:56:18 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8N9Hi19356;
	Thu, 8 Nov 2001 18:09:17 -0500
Date: Thu, 8 Nov 2001 18:09:17 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082309.fA8N9Hi19356@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server MsgQueue.h MsgQueue.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:09:17

  Added:       src/server MsgQueue.h MsgQueue.c
  Log:
  New generic queue code for server.

Revision  Changes    Path
1.1                  pcms/src/server/MsgQueue.h

Index: MsgQueue.h
===================================================================
#ifndef __MSGQUEUE_H__
#define __MSGQUEUE_H__

/* Copyright (C) 2000, The EROS Group, LLC. */
#include <pcms.h>

/*
*  Represents a queue of generic objects:
*/
typedef struct {
	unsigned int count;
	unsigned int maxnumber;
	unsigned int incoming;
	unsigned int outgoing;
	void *contents[1]; 
} MsgQueue ; /* end struct MsgQueue */

MsgQueue *CreateMsgQueue(unsigned int numOfElements, unsigned int sizeOfElement);

void AddToMsgQueue(MsgQueue *, void *);

void *GetFromMsgQueue(MsgQueue *);

bool IsEmptyMsgQueue(MsgQueue *);

void DestroyMsgQueue(MsgQueue *);

void DumpMsgQueue(MsgQueue *);

#endif /* __MSGQUEUE_H__ */



1.1                  pcms/src/server/MsgQueue.c

Index: MsgQueue.c
===================================================================

/* Copyright (C) 2000, The EROS Group, LLC. */

#include "MsgQueue.h"
#include <stdio.h>

MsgQueue *CreateMsgQueue(unsigned int numOfElements, unsigned int sizeOfElement) {
	MsgQueue *tmp;
	int x;

	/* Allocate memory for the Q itself AND the elements: */
	tmp = (MsgQueue *) malloc (numOfElements * sizeOfElement + sizeof(MsgQueue));

	if (!tmp) return NULL;
	tmp->count = 0;
	tmp->incoming = 0;
	tmp->outgoing = 0;
	tmp->maxnumber = numOfElements;

	return tmp;

} /* end InitMsgQueue */

bool IsEmptyMsgQueue(MsgQueue *q) {
	return (q->count == 0);
} /* end IsEmpty */

/*
* AddToMsgQueue:  Add an item (Request object) to the queue.  This
* queue is a FIFO queue.
*/
void AddToMsgQueue(MsgQueue *q, void *r) {
	void *tmp;
	if (!q || !r) return;

	/* for wraparound, start overwriting cells: */
	while (q->count > q->maxnumber - 1)
	{
		printf (".. doing wraparound with count = %d\n", q->count);
		tmp = GetFromMsgQueue(q);
	} /* end while */

	q->contents[q->incoming++] = r;
	/* check for end of queue: */
	if (q->incoming >= q->maxnumber) 
		q->incoming = 0;
	q->count++;
} /* end PutMsgQueue */

void *GetFromMsgQueue(MsgQueue *q) {
	void *tmp;
	if (!q || !q->count) return NULL;

	tmp = q->contents[q->outgoing++];

	if (q->outgoing >= q->maxnumber)
		q->outgoing = 0;
	q->count--;

	return tmp;
} /* end PopValueMsgQueue */

void DestroyMsgQueue(MsgQueue *q) {
	void *tmp;
	/***
	while (q->count)
	{
		tmp = GetFromMsgQueue(q);
	} 
	***/
	free (q);
} /* end DestroyMsgQueue */

void DumpMsgQueue(MsgQueue *q) {
	int x;

	printf ("Count => %d\n", q->count);
	printf ("Incoming => %d\n", q->incoming);
	printf ("Outgoing  => %d\n", q->outgoing);
	
} /* end DumpMsgQueue */





From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:08:23 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8N8Mv02118
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:08:22 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA01016;
	Thu, 8 Nov 2001 18:53:16 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8N6Ga19259;
	Thu, 8 Nov 2001 18:06:16 -0500
Date: Thu, 8 Nov 2001 18:06:16 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082306.fA8N6Ga19259@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common SDR.c SDR.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:06:16

  Modified:    src/common SDR.c SDR.h
  Log:
  Added support for new Serializable objects:  ServerRequest and ServerReply

Revision  Changes    Path
1.4       +2 -2      pcms/src/common/SDR.c

Index: SDR.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/SDR.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SDR.c	2001/11/06 22:25:53	1.3
+++ SDR.c	2001/11/08 23:06:15	1.4
@@ -483,7 +483,7 @@
 }
 
 SDR_stream*
-stream_fromstring(unsigned format, const char *buffer,
+stream_fromstring(unsigned format, char *buffer,
 		  unsigned len)
 {
   SDR_stream *stream = (SDR_stream *) pcms_malloc(sizeof(SDR_stream));
@@ -1031,7 +1031,7 @@
   st = ser_find_type(tyConst);
   s = st->deserialize(strm);
 
-  assert((s == 0) || (s->ser_type == st));
+  assert((s == 0) || (s->ser_type == st));  
 
   xml_skip_end_tag(elem, strm);
 



1.3       +3 -1      pcms/src/common/SDR.h

Index: SDR.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/SDR.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SDR.h	2001/11/06 22:25:53	1.2
+++ SDR.h	2001/11/08 23:06:15	1.3
@@ -35,7 +35,9 @@
 SDR_stream*    stream_openfile(const char *fileName, unsigned mode,
 			       unsigned format);
 SDR_stream*    stream_openstring(unsigned format);
-SDR_stream*    stream_fromstring(unsigned format, const char *buffer,
+/****   SDR_stream*    stream_fromstring(unsigned format, const char *buffer,
+				 unsigned len);  ****/
+SDR_stream*    stream_fromstring(unsigned format, char *buffer,
 				 unsigned len);
 
 void           stream_close(SDR_stream*);




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:09:07 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8N97v02154
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:09:07 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA01041;
	Thu, 8 Nov 2001 18:54:01 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8N70l19287;
	Thu, 8 Nov 2001 18:07:00 -0500
Date: Thu, 8 Nov 2001 18:07:00 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082307.fA8N70l19287@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/repos/net NetRepository.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:07:00

  Modified:    src/repos/net NetRepository.c
  Log:
  Added support for sending repository requests to remote server.

Revision  Changes    Path
1.5       +61 -14    pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- NetRepository.c	2001/11/05 19:29:07	1.4
+++ NetRepository.c	2001/11/08 23:07:00	1.5
@@ -1,5 +1,7 @@
 #include <pcms.h>
 #include <repos/pcmsrepos.h>
+#include <common/ServerRequest.h>
+#include <common/ServerReply.h>
 
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -11,7 +13,8 @@
 #define PCMSPORT 3399
 
 inline void sendStr(int connectfd, const char* messagebuf);
-inline void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen);
+/**  OLD:   inline void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen); */
+inline void sendBuff(int connectfd, const void* messagebuf);
 
 int netrepository_connect(Repository *r) {
 	
@@ -71,19 +74,26 @@
 
 void sendStr(int connectfd, const char* messagebuf) {
 	
-	sendBuff(connectfd, messagebuf, strlen(messagebuf));
+	/** OLD:   sendBuff(connectfd, messagebuf, strlen(messagebuf));  */
+	sendBuff(connectfd, messagebuf);
 }
 
-void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen) {
+/** OLD:   void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen) {  */
+void sendBuff(int connectfd, const void* messagebuf) {
 	
 	char* message;
+	unsigned int msglen = strlen((char *)messagebuf);
+	unsigned int finalsize;
 
-	message = (char *)pcms_malloc(msglen * sizeof(char));
+	finalsize = sizeof(msglen) + strlen((char *)messagebuf);
+	message = (char *)pcms_malloc(finalsize);
 	
-	memcpy(message+sizeof(msglen), messagebuf, msglen - sizeof(msglen));
+	/*  OLD:   memcpy(message+sizeof(msglen), messagebuf, msglen - sizeof(msglen));  */
+	memcpy(message+sizeof(msglen), messagebuf, msglen);
 	memcpy(message, &msglen, sizeof(msglen));
 	
-	if (write(connectfd, message, msglen) != msglen) {
+	/*  OLD:  if (write(connectfd, message, msglen) != msglen) { */
+	if (write(connectfd, message, finalsize) != finalsize) {
 		fprintf(stderr, "Not All Data Sent\n");
 	}
 	
@@ -95,19 +105,48 @@
 	SDR_stream* net_stream;
 	int opcode;
 	char* net_buf;
+	char* rawReply;
+	unsigned int incoming;
 
+	const char *testing = "Under construction.";
+
+	ServerRequest *sr;
+	ServerReply *sreply;
+
 	net_stream = stream_openstring(STREAM_XML);
 	opcode = PCMS_OPCODE_GETVERSION;
 	
-	sdr_write("opcode name=\"getversion\"", net_stream, &opcode);
-	sdr_write("string name=\"Repository Path\"", net_stream, r->uri->path);
+	sr = request_create(GETVERSION, r->uri->path, r->uri->username, opcode);  
+        sdr_write (SERVERREQUEST, net_stream, sr);
+
+	/*  sdr_write("opcode name=\"getversion\"", net_stream, &opcode); */
+	/*  sdr_write("string name=\"Repository Path\"", net_stream, r->uri->path);  */
+	/* sdr_w_ulong("opcode", net_stream, opcode);  */
+	/*  sdr_w_string("repos", net_stream, r->uri->path); */
 
 	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
 
-	sendBuff(*(r->connfd), net_buf, net_stream->len);
+	/* Send the request to the remote repository: */
+	sendBuff(*(r->connfd), net_buf);
 
-	stream_close(net_stream);
-	return NULL;
+	/* Read the length of the server's reply: */
+	read(*(r->connfd), &incoming, sizeof(incoming));  
+	
+	/* If not null then process accordingly: */
+	if (incoming > 0) {   
+	    /* Allocate just enough space for server's reply: */
+	    rawReply = (char *)pcms_malloc(incoming);
+	    read(*(r->connfd), rawReply, incoming);
+
+	    /* Create SDR stream to allow easy deserialization of reply: */
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY,net_stream);
+
+	    /* Return just the part we're interested in: */
+	    return sreply->data;  
+	} else
+	    return "No response from repository"; 
 }
   
   int
@@ -125,7 +164,8 @@
 
 	net_buf = (char *)net_stream->data;
 
-	sendBuff(*(r->connfd), net_buf, net_stream->len);
+	/** OLD:    sendBuff(*(r->connfd), net_buf, net_stream->len);  */
+	sendBuff(*(r->connfd), net_buf);
 
 	stream_close(net_stream);
 	return 0;
@@ -133,7 +173,10 @@
 }
 
   Project *
-netrepository_GetProject(Repository *r, const char *pName) {return NULL;}
+netrepository_GetProject(Repository *r, const char *pName) {
+    
+    printf ("*** Trying to find net repos project = %s\n", pName);
+    return NULL;}
 
 Project *
 netrepository_PetGetProject(Repository *r, const char *pName) {return NULL;}
@@ -160,7 +203,11 @@
 			       const char *newName) {return 0;}
   Branch *
 netrepository_GetBranch(Repository *r, Project *p,
-			 const char *bName) {return NULL;}
+			 const char *bName) {
+    
+    printf("*** Trying to get net repos branch %s\n",bName);
+    return NULL;}
+
   Branch *
 netrepository_PetGetBranch(Repository *r, Project *p, const char *bName) {return NULL;}
 




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:06:35 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8N6Zv02046
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:06:35 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA00966;
	Thu, 8 Nov 2001 18:51:28 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8N4S319201;
	Thu, 8 Nov 2001 18:04:28 -0500
Date: Thu, 8 Nov 2001 18:04:28 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082304.fA8N4S319201@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common ServerReply.h ServerReply.c ServerRequest.h ServerRequest.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:04:28

  Added:       src/common ServerReply.h ServerReply.c ServerRequest.h
                        ServerRequest.c
  Log:
  New files for processing server requests and replies.

Revision  Changes    Path
1.1                  pcms/src/common/ServerReply.h

Index: ServerReply.h
===================================================================
/* Copyright (C) 2000, The EROS Group, LLC. */
#include "pcms_opcode.h"

typedef struct ServerReply {
  Serializable ser;
  
  const char *data;
  int sockfd;

} ServerReply;

ServerReply *reply_create (const char *reply, int socket);




1.1                  pcms/src/common/ServerReply.c

Index: ServerReply.c
===================================================================
/* Copyright (C) 2000, The EROS Group, LLC. */

#include <pcms.h>
#include "ServerReply.h"

extern struct SerialType ServerReply_SerType;

static void
reply_serialize(SDR_stream *strm, const void *ob)
{
  const ServerReply *p = ob;
  
  sdr_w_string("serTrueName", strm, p->serTrueName);
  sdr_w_string("data", strm, p->data);
  sdr_w_ulong("sock", strm, p->sockfd);
  
} /* end reply_serialize */

static void *
reply_deserialize(SDR_stream *strm)
{
  ServerReply *p = (ServerReply *) pcms_malloc(sizeof(ServerReply));

  p->serType	    = &ServerReply_SerType;
  p->serTrueName    = sdr_r_string("serTrueName", strm);
  p->data           = sdr_r_string("data", strm);
  p->sockfd	    = sdr_r_ulong("sock", strm);

  return p;
}

ServerReply *
reply_create(const char *reply, int socket)
{
  ServerReply *p = (ServerReply *) pcms_malloc(sizeof(ServerReply));

  p->serType = &ServerReply_SerType;
  p->serTrueName = 0;

  p->data = reply;
  p->sockfd = socket;

  return p;
} /* end reply_create */

static void
reply_show(const void *ob)
{
  const ServerReply *p = ob;
  
  xprintf("SerTrueName:     %s\n", p->serTrueName);
  xprintf("Data       :     %s\n", p->data);
  xprintf("Socket     :     %d\n", p->sockfd);
}

struct SerialType ServerReply_SerType = {
  TY_SERVERREPLYv0,
  "Reply",
  reply_deserialize,
  reply_serialize,
  reply_show
};



1.1                  pcms/src/common/ServerRequest.h

Index: ServerRequest.h
===================================================================
/* Copyright (C) 2000, The EROS Group, LLC. */
#include "pcms_opcode.h"

typedef struct ServerRequest {
  Serializable ser;
  
  const char *command;
  unsigned int opcode;
  char *repos_path;
  char *username;
  int sockfd;

} ServerRequest;

ServerRequest *request_create (const char *aName, char *path, char *user, unsigned int ocode);




1.1                  pcms/src/common/ServerRequest.c

Index: ServerRequest.c
===================================================================
/* Copyright (C) 2000, The EROS Group, LLC. */

#include <pcms.h>
#include "ServerRequest.h"

extern struct SerialType ServerRequest_SerType;

static void
request_serialize(SDR_stream *strm, const void *ob)
{
  const ServerRequest *p = ob;
  
  sdr_w_string("serTrueName", strm, p->serTrueName);
  sdr_w_string("command", strm, p->command);
  sdr_w_ulong("opcode", strm, p->opcode);
  sdr_w_string("path", strm, p->repos_path);
  sdr_w_string("user", strm, p->username);
  sdr_w_ulong("sock", strm, p->sockfd);
  
} /* end request_serialize */

static void *
request_deserialize(SDR_stream *strm)
{
  ServerRequest *p = (ServerRequest *) pcms_malloc(sizeof(ServerRequest));

  p->serType	    = &ServerRequest_SerType;
  p->serTrueName    = sdr_r_string("serTrueName", strm);
  p->command        = sdr_r_string("command", strm);
  p->opcode         = sdr_r_ulong("opcode", strm);
  p->repos_path     = sdr_r_string("path", strm);
  p->username       = sdr_r_string("user", strm);
  p->sockfd         = sdr_r_ulong("sock", strm);

  return p;
}

ServerRequest *
request_create(const char *aName, char *path, char *user, unsigned int ocode)
{
  ServerRequest *p = (ServerRequest *) pcms_malloc(sizeof(ServerRequest));

  p->serType = &ServerRequest_SerType;
  p->serTrueName = 0;

  p->command = aName;
  p->opcode = ocode;
  p->repos_path = path;
  p->username = user;
  p->sockfd = 0;  /* will be assigned by server */

  return p;
} /* end request_create */

static void
request_show(const void *ob)
{
  const ServerRequest *p = ob;
  
  xprintf("Request command: %s\n", p->command);
  xprintf("Opcode:          %d\n", p->opcode);
  xprintf("SerTrueName:     %s\n", p->serTrueName);
  xprintf("Repos Path:      %s\n", p->repos_path);
  xprintf("Username:        %s\n", p->username);
  xprintf("Socket:          %d\n", p->sockfd);
}

struct SerialType ServerRequest_SerType = {
  TY_SERVERREQUESTv0,
  "Request",
  request_deserialize,
  request_serialize,
  request_show
};




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:07:40 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8N7dv02082
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:07:39 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA00991;
	Thu, 8 Nov 2001 18:52:33 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8N5Xs19230;
	Thu, 8 Nov 2001 18:05:33 -0500
Date: Thu, 8 Nov 2001 18:05:33 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082305.fA8N5Xs19230@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/client Merge.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:05:33

  Modified:    src/client Merge.c
  Log:
  Changed order of arguments to the 'diff3' command.

Revision  Changes    Path
1.3       +14 -1     pcms/src/client/Merge.c

Index: Merge.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/Merge.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Merge.c	2001/10/19 03:44:10	1.2
+++ Merge.c	2001/11/08 23:05:33	1.3
@@ -1221,6 +1221,9 @@
 #define argc 6
     char *argv[argc];
 
+    /* diff3 manpage specifies order of args is:  diff3 <mine> <older> <yours>
+    * It looks to me like <mine> should be <base>, <older> should be <common>, and <yours>
+    * should be <merge>.  So, need to fix the order here:   Vanderburgh (11/05/2001):
     argv[0] = "diff3";
     argv[1] = "-E";
     argv[2] = "-am";
@@ -1228,12 +1231,22 @@
     argv[4] = (char *) mt->mergeInputName;
     argv[5] = (char *) mt->commonInputName;
     argv[6] = 0;
+    */
+
+    argv[0] = "diff3";
+    argv[1] = "-E";
+    argv[2] = "-am";
+    argv[3] = (char *) mt->base->fsName;
+    argv[4] = (char *) mt->commonInputName;
+    argv[5] = (char *) mt->mergeInputName;
+    argv[6] = 0;
     
     xprintf("Calling");
     for (i = 0; i < argc; i++)
       xprintf(" %s", argv[i]);
 
-    xprintf(" %s %s %s\n", mt->base->fsName, mt->mergeInputName, mt->commonInputName);
+    xprintf("\n");
+/* -> extraneous? JCV    xprintf(" %s %s %s\n", mt->base->fsName, mt->mergeInputName, mt->commonInputName);  */
     
     conflicts =
       diff3_run(argc, argv, (char *) mt->mergeOutputName, 0);




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:05:35 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8N5Zv02020
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:05:35 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA00951;
	Thu, 8 Nov 2001 18:50:27 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8N3QK19166;
	Thu, 8 Nov 2001 18:03:26 -0500
Date: Thu, 8 Nov 2001 18:03:26 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082303.fA8N3QK19166@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src pcmsrules.mk.in
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:03:26

  Modified:    src      pcmsrules.mk.in
  Log:
  Added references to new files.
  
  CLIENTLIB is a new library of "client objects" that the server code now needs to compile correctly.

Revision  Changes    Path
1.2       +28 -6     pcms/src/pcmsrules.mk.in

Index: pcmsrules.mk.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/pcmsrules.mk.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- pcmsrules.mk.in	2001/10/23 23:07:20	1.1
+++ pcmsrules.mk.in	2001/11/08 23:03:26	1.2
@@ -6,6 +6,7 @@
 LIBREADLINE=-lreadline -ltermcap
 COMREADLINE=-DUSE_READLINE -I/usr/include/readline
 LIBDIFF=$(LIBINCLUDE)/../../libdiff -ldiff
+MISCSERVERLIBS=$(LIBREADLINE) $(LIBDIFF)
 
 CFLAGS=-g #may be overridden from above
 XCFLAGS=-Wmissing-prototypes -Werror -Wreturn-type
@@ -26,7 +27,9 @@
 	$(TOPDIR)/common/Project.o \
 	$(TOPDIR)/common/Serializable.o \
 	$(TOPDIR)/common/xmalloc.o \
-	$(TOPDIR)/common/os.o
+	$(TOPDIR)/common/os.o \
+	$(TOPDIR)/common/ServerRequest.o \
+	$(TOPDIR)/common/ServerReply.o
 
 REPOSOBJECTS=\
 	$(TOPDIR)/repos/fs/CachedFileRepos.o \
@@ -36,13 +39,27 @@
 	$(TOPDIR)/repos/common/EntityCache.o \
 	$(TOPDIR)/repos/common/URI.o
 
+CLIENTLIBOBJECTS=\
+	$(TOPDIR)/client/glob.o \
+	$(TOPDIR)/client/nmlist.o \
+	$(TOPDIR)/client/message.o \
+	$(TOPDIR)/client/SubProcess.o \
+	$(TOPDIR)/client/WsEntity.o \
+	$(TOPDIR)/client/FilterSet.o \
+	$(TOPDIR)/client/PendingChange.o \
+	$(TOPDIR)/client/WorkSpace.o \
+	$(TOPDIR)/client/Options.o \
+	$(TOPDIR)/client/Merge.o 
+
 LIBDIR=$(TOPDIR)/lib
 
 COMMONLIB=$(LIBDIR)/libpcms.a
 
 REPOSLIB=$(LIBDIR)/libpcmsrepos.a
+
+CLIENTLIB=$(LIBDIR)/libpcmsclient.a
 
-PCMSLIBS=-lpcms -lpcmsrepos
+PCMSLIBS=-lpcms -lpcmsclient -lpcmsrepos
 
 CLIENTOBJECTS=\
 	$(TOPDIR)/client/pcms.o \
@@ -62,7 +79,7 @@
 CLIENT=$(TOPDIR)/pcms
 
 SERVEROBJECTS=\
-	$(TOPDIR)/server/pcmsserver.o
+	$(TOPDIR)/server/pcmsserver.o $(TOPDIR)/server/MsgQueue.o
 
 SERVER=$(TOPDIR)/pcmsserver
 
@@ -81,11 +98,12 @@
 
 default: all
 
-all: $(COMMONLIB) $(REPOSLIB) $(SERVER) $(CLIENT) DEPEND
+all: $(COMMONLIB) $(REPOSLIB) $(CLIENTLIB) $(SERVER) $(CLIENT) DEPEND
 
 clean:
 	rm -f $(OBJECTS)
 	rm -f $(COMMONLIB)
+	rm -f $(CLIENTLIB)
 	rm -f $(REPOSLIB)
 	rm -f $(CLIENT)
 	rm -f $(SERVER)
@@ -108,9 +126,13 @@
 $(REPOSLIB): $(REPOSOBJECTS) $(LIBDIR)
 	rm -f $(REPOSLIB)
 	$(AR) rc $(REPOSLIB) $(REPOSOBJECTS)
+
+$(CLIENTLIB): $(CLIENTLIBOBJECTS) $(LIBDIR)
+	rm -f $(CLIENTLIB)
+	$(AR) rc $(CLIENTLIB) $(CLIENTLIBOBJECTS)
 
-$(SERVER): $(COMMONLIB) $(REPOSLIB) $(SERVEROBJECTS)
-	$(CC) -o $(SERVER) $(CFLAGS) $(SERVEROBJECTS) $(LIBINCLUDE) $(PCMSLIBS)
+$(SERVER): $(COMMONLIB) $(REPOSLIB) $(CLIENTLIB) $(SERVEROBJECTS)
+	$(CC) -o $(SERVER) $(CFLAGS) $(SERVEROBJECTS) $(LIBINCLUDE) $(PCMSLIBS) $(MISCSERVERLIBS)
 
 $(CLIENT): $(COMMONLIB) $(REPOSLIB) $(CLIENTOBJECTS)
 	$(CC) -o $(CLIENT) $(CFLAGS) $(CLIENTOBJECTS) $(LIBREADLINE) $(LIBDIFF) $(LIBINCLUDE) $(PCMSLIBS)




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:19:40 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8NJdv02444
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:19:39 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id TAA01249;
	Thu, 8 Nov 2001 19:04:25 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8NHNE19534;
	Thu, 8 Nov 2001 18:17:23 -0500
Date: Thu, 8 Nov 2001 18:17:23 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082317.fA8NHNE19534@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server pcmsserver.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:17:23

  Modified:    src/server pcmsserver.c
  Log:
  Misc change.

Revision  Changes    Path
1.5       +1 -1      pcms/src/server/pcmsserver.c

Index: pcmsserver.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/pcmsserver.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- pcmsserver.c	2001/11/08 23:08:30	1.4
+++ pcmsserver.c	2001/11/08 23:17:23	1.5
@@ -2,7 +2,7 @@
 #include "pcmsserver.h"
 
 #include <fcntl.h>
-#include "../../junk/MsgQueue.h"
+#include "MsgQueue.h"
 #include <./repos/pcmsrepos.h>
 #include <./common/ServerRequest.h>
 #include <./common/ServerReply.h>




From vandy@snocrash.cs.jhu.edu Thu Nov  8 18:27:39 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fA8NRdv02671
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 8 Nov 2001 18:27:39 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id TAA01409;
	Thu, 8 Nov 2001 19:12:32 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fA8NPWa19678;
	Thu, 8 Nov 2001 18:25:32 -0500
Date: Thu, 8 Nov 2001 18:25:32 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111082325.fA8NPWa19678@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src pcms.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/08 18:25:32

  Modified:    src      pcms.h
  Log:
  added #ifndef __PCMS_H__ line.

Revision  Changes    Path
1.12      +6 -0      pcms/src/pcms.h

Index: pcms.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/pcms.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- pcms.h	2001/11/05 19:29:06	1.11
+++ pcms.h	2001/11/08 23:25:32	1.12
@@ -1,5 +1,8 @@
 /* Copyright (C) 2000, The EROS Group, LLC. */
 
+#ifndef __PCMS_H__
+#define __PCMS_H__
+
 #include <sys/stat.h>
 
 #include <ctype.h>
@@ -54,3 +57,6 @@
 #ifndef __unix__
 #define BROKEN_FS_ENTITIES
 #endif
+
+#endif
+




From bastille@snocrash.cs.jhu.edu Mon Nov 12 12:30:58 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fACHUwv26398
	for <dcms-cvs@eros.cs.jhu.edu>; Mon, 12 Nov 2001 12:30:58 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id NAA00775;
	Mon, 12 Nov 2001 13:15:20 -0500
Received: (from bastille@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fACHSK221276;
	Mon, 12 Nov 2001 12:28:20 -0500
Date: Mon, 12 Nov 2001 12:28:20 -0500
From: Raphael Schweber-Koren <bastille@snocrash.cs.jhu.edu>
Message-Id: <200111121728.fACHSK221276@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/tests repossel.sh .cvsignore 02cre_repos01.sh 03cre_repos02.sh 04import.sh 05import-commit.sh 06modify.sh 07modcommit.sh 08modcheckout.sh 09import-checkout.sh 10twomods.sh 11entrename.sh 12mvupdate.sh Makefile.in runtest.sh
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

bastille    01/11/12 12:28:20

  Modified:    tests    .cvsignore 02cre_repos01.sh 03cre_repos02.sh
                        04import.sh 05import-commit.sh 06modify.sh
                        07modcommit.sh 08modcheckout.sh
                        09import-checkout.sh 10twomods.sh 11entrename.sh
                        12mvupdate.sh Makefile.in runtest.sh
  Added:       tests    repossel.sh
  Log:
  Added Net test suite addition to the standard set. It runs the standard suite against a net repository, option "make nettest" in the tests directory. This is easily extensible to the creation of a suite of net-only tests as well.
  
  The tests are run agains a pcms server created before all tests are run. The ser
  ver uses a repository path tests/netrepos.

Revision  Changes    Path
1.4       +1 -0      pcms/tests/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/.cvsignore,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- .cvsignore	2000/10/01 01:55:49	1.3
+++ .cvsignore	2001/11/12 17:28:19	1.4
@@ -2,3 +2,4 @@
 input
 output
 repos
+pcmstest.dbg



1.4       +20 -5     pcms/tests/02cre_repos01.sh

Index: 02cre_repos01.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/02cre_repos01.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- 02cre_repos01.sh	2001/08/07 15:28:27	1.3
+++ 02cre_repos01.sh	2001/11/12 17:28:19	1.4
@@ -5,11 +5,26 @@
 
 . testvars.sh
 
-mkdir repos
-
-REPOS=file:${PWD}/repos
-
-echo $PCMS
+. repossel.sh
+#ARGS=`getopt -o nf -- "$@"`
+#eval set -- "$ARGS"
+#net_opt=0
+#
+#while true; do
+#	case "$1" in
+#		-n) net_opt=1; break;;
+#		-f) net_opt=0; break;;
+#	esac
+#done
+#
+#if [ ${net_opt} != 0 ]
+#then
+#	echo "Selected Net Repository"
+#	REPOS=pcms://localhost/${PWD}/repos
+#else
+#	echo "Selected File Repository"
+#	REPOS=file:${PWD}/repos
+#fi
 
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.3       +3 -2      pcms/tests/03cre_repos02.sh

Index: 03cre_repos02.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/03cre_repos02.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- 03cre_repos02.sh	2000/10/06 15:02:13	1.2
+++ 03cre_repos02.sh	2001/11/12 17:28:19	1.3
@@ -4,9 +4,10 @@
 
 . testvars.sh
 
-mkdir repos
+. repossel.sh
+#kdir repos
 
-REPOS=file:${PWD}/repos
+#EPOS=file:${PWD}/repos
 
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.5       +3 -3      pcms/tests/04import.sh

Index: 04import.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/04import.sh,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- 04import.sh	2000/10/06 15:02:13	1.4
+++ 04import.sh	2001/11/12 17:28:19	1.5
@@ -3,10 +3,10 @@
 # Test re-creation of an existing repository.
 
 . testvars.sh
+. repossel.sh
+#mkdir repos
 
-mkdir repos
-
-REPOS=file:${PWD}/repos
+#REPOS=file:${PWD}/repos
 
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.8       +3 -3      pcms/tests/05import-commit.sh

Index: 05import-commit.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/05import-commit.sh,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- 05import-commit.sh	2000/10/06 21:56:22	1.7
+++ 05import-commit.sh	2001/11/12 17:28:19	1.8
@@ -3,10 +3,10 @@
 # Test re-creation of an existing repository.
 
 . testvars.sh
+. repossel.sh
+#mkdir repos
 
-mkdir repos
-
-REPOS=file:${PWD}/repos
+#REPOS=file:${PWD}/repos
 
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.3       +3 -3      pcms/tests/06modify.sh

Index: 06modify.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/06modify.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- 06modify.sh	2000/10/06 15:02:13	1.2
+++ 06modify.sh	2001/11/12 17:28:19	1.3
@@ -3,10 +3,10 @@
 # Test re-creation of an existing repository.
 
 . testvars.sh
+. repossel.sh
+#mkdir repos
 
-mkdir repos
-
-REPOS=file:${PWD}/repos
+#REPOS=file:${PWD}/repos
 
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.3       +3 -3      pcms/tests/07modcommit.sh

Index: 07modcommit.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/07modcommit.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- 07modcommit.sh	2000/10/06 15:02:13	1.2
+++ 07modcommit.sh	2001/11/12 17:28:19	1.3
@@ -3,10 +3,10 @@
 # Test re-creation of an existing repository.
 
 . testvars.sh
+. repossel.sh
+#mkdir repos
 
-mkdir repos
-
-REPOS=file:${PWD}/repos
+#REPOS=file:${PWD}/repos
 
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.4       +3 -4      pcms/tests/08modcheckout.sh

Index: 08modcheckout.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/08modcheckout.sh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- 08modcheckout.sh	2001/08/07 15:28:27	1.3
+++ 08modcheckout.sh	2001/11/12 17:28:19	1.4
@@ -3,11 +3,10 @@
 # Test re-creation of an existing repository.
 
 . testvars.sh
+. repossel.sh
 
-echo Making REPOS
-mkdir repos
-echo SETTING REPOS
-REPOS=file:${PWD}/repos
+#mkdir repos
+#REPOS=file:${PWD}/repos
 echo CREATE REPOSITORY
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.3       +3 -3      pcms/tests/09import-checkout.sh

Index: 09import-checkout.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/09import-checkout.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- 09import-checkout.sh	2000/10/06 15:02:13	1.2
+++ 09import-checkout.sh	2001/11/12 17:28:19	1.3
@@ -3,10 +3,10 @@
 # Test re-creation of an existing repository.
 
 . testvars.sh
+. repossel.sh
+#mkdir repos
 
-mkdir repos
-
-REPOS=file:${PWD}/repos
+#REPOS=file:${PWD}/repos
 
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.3       +3 -3      pcms/tests/10twomods.sh

Index: 10twomods.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/10twomods.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- 10twomods.sh	2000/10/06 15:02:13	1.2
+++ 10twomods.sh	2001/11/12 17:28:19	1.3
@@ -3,10 +3,10 @@
 # Test re-creation of an existing repository.
 
 . testvars.sh
+. repossel.sh
+#mkdir repos
 
-mkdir repos
-
-REPOS=file:${PWD}/repos
+#REPOS=file:${PWD}/repos
 
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.2       +3 -3      pcms/tests/11entrename.sh

Index: 11entrename.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/11entrename.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 11entrename.sh	2000/10/23 16:19:02	1.1
+++ 11entrename.sh	2001/11/12 17:28:19	1.2
@@ -3,10 +3,10 @@
 # Test re-creation of an existing repository.
 
 . testvars.sh
+. repossel.sh
+#mkdir repos
 
-mkdir repos
-
-REPOS=file:${PWD}/repos
+#REPOS=file:${PWD}/repos
 
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.3       +3 -3      pcms/tests/12mvupdate.sh

Index: 12mvupdate.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/12mvupdate.sh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- 12mvupdate.sh	2000/12/10 13:45:24	1.2
+++ 12mvupdate.sh	2001/11/12 17:28:19	1.3
@@ -3,10 +3,10 @@
 # Test re-creation of an existing repository.
 
 . testvars.sh
+. repossel.sh
+#mkdir repos
 
-mkdir repos
-
-REPOS=file:${PWD}/repos
+#REPOS=file:${PWD}/repos
 
 $PCMS create repository --server ${REPOS} > /dev/null 2>&1
 status=$?



1.8       +10 -0     pcms/tests/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/Makefile.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Makefile.in	2001/08/08 18:10:46	1.7
+++ Makefile.in	2001/11/12 17:28:19	1.8
@@ -1,3 +1,5 @@
+PCMSSERVER=../src/pcmsserver
+
 TESTS=\
 	01check_scripts.sh \
 	02cre_repos01.sh \
@@ -24,6 +26,14 @@
 	  ./runtest.sh $$test || exit 1; \
 	done
 
+nettest:
+	rm -f pcmstest.dbg
+	touch pcmstest.dbg
+	${PCMSSERVER} &
+	@for test in $(TESTS); do \
+		./runtest.sh -n $$test || exit 1; \
+	done
+	killall pcmsserver -s INT
 
 distclean: clean
 	-rm -f Makefile



1.6       +5 -3      pcms/tests/runtest.sh

Index: runtest.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/runtest.sh,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- runtest.sh	2001/08/07 15:28:27	1.5
+++ runtest.sh	2001/11/12 17:28:19	1.6
@@ -2,7 +2,7 @@
 
 test=$1
 
-ARGS=`getopt -o xqvm -- "$@"`
+ARGS=`getopt -o xqvmn -- "$@"`
 
 if [ $? != 0 ]
 then
@@ -15,6 +15,7 @@
 verbose_opt=0
 memdbg_opt=0
 quiet_opt=0
+net_opt="-f"
 
 while true; do
     case "$1" in
@@ -22,6 +23,7 @@
 	-m) memdbg_opt=1; shift;;
 	-v) sh_args="${sh_args} -x"; verbose_opt=1; shift;;
 	-q) quiet_opt=1; shift;;
+	-n) net_opt="-n"; shift;;
 	--) shift; break;;
 	*) echo "Internal argument processing error!" >&2; exit 1;;
     esac
@@ -34,12 +36,12 @@
     NJAMD_CHK_FREE=segv export NJAMD_CHK_FREE
 fi
 
-
 make clean > /dev/null 2>&1
 
 for test in $*
 do
-    output=`/bin/sh ${sh_args} ${test} 2>&1`
+    echo "/bin/sh ${sh_args} ${test} ${net_opt}"
+    output=`/bin/sh ${sh_args} ${test} ${net_opt}  2>&1`
     status=$?
 
     echo "$output" >> pcmstest.dbg



1.1                  pcms/tests/repossel.sh

Index: repossel.sh
===================================================================
#!/bin/sh

ARGS=`getopt -o nf -- "$@"`
eval set -- "$ARGS"
net_opt=0

while true; do
	case "$1" in
		-n) net_opt=1; break;;
		-f) net_opt=0; break;;
	esac
done

if [ ${net_opt} != 0 ]
then
	echo "Selected Net Repository"
	REPOS=pcms://localhost/${PWD}/netrepos
else
	echo "Selected File Repository"
	mkdir repos
	REPOS=file:${PWD}/repos
fi





From vandy@snocrash.cs.jhu.edu Tue Nov 13 12:00:35 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fADH0Zv13949
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 13 Nov 2001 12:00:35 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id MAA00694;
	Tue, 13 Nov 2001 12:44:49 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fADGvdQ28748;
	Tue, 13 Nov 2001 11:57:39 -0500
Date: Tue, 13 Nov 2001 11:57:39 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111131657.fADGvdQ28748@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/client Merge.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/13 11:57:39

  Modified:    src/client Merge.c
  Log:
  Added code to clean up scratch directory before making assertion checks. (Multiple
  updates would dump core because scratch dir was not getting cleaned up.)

Revision  Changes    Path
1.4       +14 -0     pcms/src/client/Merge.c

Index: Merge.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/Merge.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Merge.c	2001/11/08 23:05:33	1.3
+++ Merge.c	2001/11/13 16:57:39	1.4
@@ -327,6 +327,17 @@
   sprintf(tmpname, ".pcms/scratch/common-%u", tup->ndx);
   tup->commonInputName = tmpname;
 
+  /* Here's a graceful way of ensuring scratch directory
+   * is cleanup up before continuing: */
+  if (path_exists(tup->mergeOutputName))
+      path_remove(tup->mergeOutputName);
+  if (path_exists(tup->delScratchName))
+      path_remove(tup->delScratchName);
+  if (path_exists(tup->commonInputName))
+      path_remove(tup->commonInputName);
+  if (path_exists(tup->mergeInputName))
+      path_remove(tup->mergeInputName);
+
   assert(!path_exists(tup->mergeOutputName));
   assert(!path_exists(tup->delScratchName));
   assert(!path_exists(tup->commonInputName));
@@ -1030,6 +1041,9 @@
     
     assert(mt->result);
     
+    if (path_exists(mt->finalName))
+	path_remove(mt->finalName);
+
     assert(!path_exists(mt->finalName));
     xprintf("Renaming \"%s\" => \"%s\"\n",
 	    mt->mergeOutputName, mt->finalName);




From vandy@snocrash.cs.jhu.edu Tue Nov 13 12:01:28 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fADH1Sv13981
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 13 Nov 2001 12:01:28 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id MAA00715;
	Tue, 13 Nov 2001 12:45:43 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fADGwiR28775;
	Tue, 13 Nov 2001 11:58:44 -0500
Date: Tue, 13 Nov 2001 11:58:44 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111131658.fADGwiR28775@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/client PendingChange.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/13 11:58:44

  Modified:    src/client PendingChange.c
  Log:
  Fixed "update" bug:  "update" was not modifying the Workspace "topChange"
  and "baseChangeName" elements after updating.  Thus, every subsequent attempt
  to "commit" after and "update" failed.

Revision  Changes    Path
1.3       +6 -0      pcms/src/client/PendingChange.c

Index: PendingChange.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/PendingChange.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PendingChange.c	2001/10/19 03:44:10	1.2
+++ PendingChange.c	2001/11/13 16:58:43	1.3
@@ -485,6 +485,12 @@
     unimplemented("PCMS update with collisions is incomplete!\n");
   
   pendingchange_RecomputeStatus(ws_nextChange);
+
+  /* Fix up the PendingChange to reflect the new state:
+   */
+  pc->topChange = branch_TopChangeNdx(b);
+  pc->baseChangeName = topChangeName;
+  
 }
 
 static void




From vandy@snocrash.cs.jhu.edu Tue Nov 13 12:01:48 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fADH1mv13989
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 13 Nov 2001 12:01:48 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id MAA00726;
	Tue, 13 Nov 2001 12:46:04 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fADGx4T28794;
	Tue, 13 Nov 2001 11:59:04 -0500
Date: Tue, 13 Nov 2001 11:59:04 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111131659.fADGx4T28794@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/client pcms.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/13 11:59:04

  Modified:    src/client pcms.c
  Log:
  Added misc comments.

Revision  Changes    Path
1.4       +5 -0      pcms/src/client/pcms.c

Index: pcms.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/pcms.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- pcms.c	2001/11/08 23:12:21	1.3
+++ pcms.c	2001/11/13 16:59:04	1.4
@@ -97,6 +97,11 @@
 }
 
 void
+pcms_create_repository(Repository *r, int argc, char **argv) {
+    repos_CreateRepository(r);
+} /* end create_repository */
+
+void
 pcms_create_project(Repository *r, int argc, char **argv)
 {
   Project *p;




From vandy@snocrash.cs.jhu.edu Tue Nov 13 12:05:18 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fADH5Hv14041
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 13 Nov 2001 12:05:17 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id MAA00759;
	Tue, 13 Nov 2001 12:49:33 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fADH2X528917;
	Tue, 13 Nov 2001 12:02:33 -0500
Date: Tue, 13 Nov 2001 12:02:33 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111131702.fADH2X528917@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common ServerStringArgument.h ServerStringArgument.c Serializable.h Serializable.c ServerReply.c ServerReply.h ServerRequest.c ServerRequest.h pcms_opcode.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/13 12:02:33

  Modified:    src/common Serializable.h Serializable.c ServerReply.c
                        ServerReply.h ServerRequest.c ServerRequest.h
                        pcms_opcode.h
  Added:       src/common ServerStringArgument.h ServerStringArgument.c
  Log:
  Added changes for a Serializable "string argument" that can get passed to
  server (via ServerRequest).  Added misc changed to pcms_opcodes to handle
  more server commands.

Revision  Changes    Path
1.3       +1 -0      pcms/src/common/Serializable.h

Index: Serializable.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/Serializable.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Serializable.h	2001/11/08 23:10:59	1.2
+++ Serializable.h	2001/11/13 17:02:33	1.3
@@ -19,6 +19,7 @@
   /* Add new entries here... */
   TY_SERVERREQUESTv0,
   TY_SERVERREPLYv0,
+  TY_SERVERARGUMENTv0,
   
   TY_ntypes
 };



1.4       +3 -1      pcms/src/common/Serializable.c

Index: Serializable.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/Serializable.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Serializable.c	2001/11/08 23:10:59	1.3
+++ Serializable.c	2001/11/13 17:02:33	1.4
@@ -44,6 +44,7 @@
 extern SerialType CommitInfo_SerType;
 extern SerialType ServerRequest_SerType;
 extern SerialType ServerReply_SerType;
+extern SerialType ServerStringArgument_SerType;
 
 SerialType *serTypes[TY_ntypes] = {
   &Null_SerType,
@@ -59,7 +60,8 @@
   &WsEntity_SerType,
   &CommitInfo_SerType,
   &ServerRequest_SerType,
-  &ServerReply_SerType
+  &ServerReply_SerType,
+  &ServerStringArgument_SerType
 } ;
 
 SerialType *



1.2       +11 -0     pcms/src/common/ServerReply.c

Index: ServerReply.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerReply.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServerReply.c	2001/11/08 23:04:28	1.1
+++ ServerReply.c	2001/11/13 17:02:33	1.2
@@ -13,6 +13,7 @@
   sdr_w_string("serTrueName", strm, p->serTrueName);
   sdr_w_string("data", strm, p->data);
   sdr_w_ulong("sock", strm, p->sockfd);
+  sdr_write("args", strm, p->return_objs);
   
 } /* end reply_serialize */
 
@@ -25,6 +26,7 @@
   p->serTrueName    = sdr_r_string("serTrueName", strm);
   p->data           = sdr_r_string("data", strm);
   p->sockfd	    = sdr_r_ulong("sock", strm);
+  p->return_objs    = sdr_read("args", strm);
 
   return p;
 }
@@ -39,6 +41,7 @@
 
   p->data = reply;
   p->sockfd = socket;
+  p->return_objs = obvec_create();
 
   return p;
 } /* end reply_create */
@@ -47,11 +50,19 @@
 reply_show(const void *ob)
 {
   const ServerReply *p = ob;
+  unsigned int u;
   
   xprintf("SerTrueName:     %s\n", p->serTrueName);
   xprintf("Data       :     %s\n", p->data);
   xprintf("Socket     :     %d\n", p->sockfd);
+
+  for (u = 0; u < vec_size(p->return_objs); u++)
+      sdr_show(vec_fetch(p->return_objs, u));
 }
+
+void serverreply_AddArgument(ServerReply *sr, void *obj) {
+    obvec_append(sr->return_objs, obj);
+} /* end serverreply_AddArgument */
 
 struct SerialType ServerReply_SerType = {
   TY_SERVERREPLYv0,



1.2       +6 -0      pcms/src/common/ServerReply.h

Index: ServerReply.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerReply.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServerReply.h	2001/11/08 23:04:28	1.1
+++ ServerReply.h	2001/11/13 17:02:33	1.2
@@ -6,8 +6,14 @@
   
   const char *data;
   int sockfd;
+  ObVec *return_objs;
 
 } ServerReply;
 
 ServerReply *reply_create (const char *reply, int socket);
+
+/*
+ * Need method to add return objects:
+ */
+void serverreply_AddArgument(ServerReply*, void*);
 



1.2       +16 -0     pcms/src/common/ServerRequest.c

Index: ServerRequest.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerRequest.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServerRequest.c	2001/11/08 23:04:28	1.1
+++ ServerRequest.c	2001/11/13 17:02:33	1.2
@@ -16,6 +16,7 @@
   sdr_w_string("path", strm, p->repos_path);
   sdr_w_string("user", strm, p->username);
   sdr_w_ulong("sock", strm, p->sockfd);
+  sdr_write("args", strm, p->args);
   
 } /* end request_serialize */
 
@@ -31,6 +32,7 @@
   p->repos_path     = sdr_r_string("path", strm);
   p->username       = sdr_r_string("user", strm);
   p->sockfd         = sdr_r_ulong("sock", strm);
+  p->args	    = sdr_read("args", strm);
 
   return p;
 }
@@ -49,12 +51,15 @@
   p->username = user;
   p->sockfd = 0;  /* will be assigned by server */
 
+  p->args = obvec_create();
+
   return p;
 } /* end request_create */
 
 static void
 request_show(const void *ob)
 {
+  unsigned int u;
   const ServerRequest *p = ob;
   
   xprintf("Request command: %s\n", p->command);
@@ -63,7 +68,18 @@
   xprintf("Repos Path:      %s\n", p->repos_path);
   xprintf("Username:        %s\n", p->username);
   xprintf("Socket:          %d\n", p->sockfd);
+
+  for (u = 0; u < vec_size(p->args); u++)
+      sdr_show(vec_fetch(p->args, u));
 }
+
+/*
+* Method for adding an argument to this request object.  Note that
+* all arguments must be Serializable.
+*/
+void serverrequest_AddArgument(ServerRequest *sr, void *obj) {
+    obvec_append(sr->args, obj);
+} /* end serverrequest_AddArgument */
 
 struct SerialType ServerRequest_SerType = {
   TY_SERVERREQUESTv0,



1.2       +10 -0     pcms/src/common/ServerRequest.h

Index: ServerRequest.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerRequest.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServerRequest.h	2001/11/08 23:04:28	1.1
+++ ServerRequest.h	2001/11/13 17:02:33	1.2
@@ -10,7 +10,17 @@
   char *username;
   int sockfd;
 
+  /* Some commands take arguments.  Store
+   * any such arguments here:
+   */
+  ObVec *args;
+
 } ServerRequest;
 
 ServerRequest *request_create (const char *aName, char *path, char *user, unsigned int ocode);
+
+/* 
+ * Need methods to add command arguments:
+ */
+void serverrequest_AddArgument(ServerRequest*, void*);
 



1.3       +3 -0      pcms/src/common/pcms_opcode.h

Index: pcms_opcode.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/pcms_opcode.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pcms_opcode.h	2001/11/08 23:11:22	1.2
+++ pcms_opcode.h	2001/11/13 17:02:33	1.3
@@ -17,12 +17,14 @@
 #define PCMS_OPCODE_LISTBRANCHES 514
 #define PCMS_OPCODE_REVISEENTITY 515
 #define PCMS_OPCODE_GETENTITY 516
+#define PCMS_OPCODE_CREATEREPOSITORY 517
 
 /* Need some commonly defined XML element names: */
 #define SERVERREQUEST "Request"
 #define SERVERREPLY "Reply"
 #define GETVERSION "version"
 #define CREATEPROJECT "createProject"
+#define CREATEREPOSITORY "createRepos"
 #define GETPROJECT "getProject"
 #define PETGETPROJECT "getPetProject"
 #define PETRENAMEPROJECT "renamePetProject"
@@ -34,6 +36,7 @@
 #define GETBRANCH "getBranch"
 #define PETGETBRANCH "getPetBranch"
 #define REVISEBRANCH "reviseBranch"
+#define REVISEENTITY "reviseEntity"
 
 #endif
 



1.1                  pcms/src/common/ServerStringArgument.h

Index: ServerStringArgument.h
===================================================================
/* Copyright (C) 2000, The EROS Group, LLC. */

typedef struct ServerStringArgument {
  Serializable ser;
  
  const char *data;

} ServerStringArgument;

ServerStringArgument *serverarg_create (const char *argument);




1.1                  pcms/src/common/ServerStringArgument.c

Index: ServerStringArgument.c
===================================================================
/* Copyright (C) 2000, The EROS Group, LLC. */

#include <pcms.h>
#include "ServerStringArgument.h"

extern struct SerialType ServerStringArgument_SerType;

static void
serverarg_serialize(SDR_stream *strm, const void *ob)
{
  const ServerStringArgument *p = ob;
  
  sdr_w_string("serTrueName", strm, p->serTrueName);
  sdr_w_string("data", strm, p->data);
  
} /* end serverarg_serialize */

static void *
serverarg_deserialize(SDR_stream *strm)
{
  ServerStringArgument *p = (ServerStringArgument *) pcms_malloc(sizeof(ServerStringArgument));

  p->serType	    = &ServerStringArgument_SerType;
  p->serTrueName    = sdr_r_string("serTrueName", strm);
  p->data           = sdr_r_string("data", strm);

  return p;
} /* end serverarg_deserialize */

ServerStringArgument *
serverarg_create(const char *argument)
{
  ServerStringArgument *p = (ServerStringArgument *) pcms_malloc(sizeof(ServerStringArgument));

  p->serType = &ServerStringArgument_SerType;
  p->serTrueName = 0;

  p->data = argument;

  return p;
} /* end stringarg_create */

static void
serverarg_show(const void *ob)
{
  const ServerStringArgument *p = ob;
  
  xprintf("SerTrueName:     %s\n", p->serTrueName);
  xprintf("Data       :     %s\n", p->data);

}

struct SerialType ServerStringArgument_SerType = {
  TY_SERVERARGUMENTv0,
  "ServerArg",
  serverarg_deserialize,
  serverarg_serialize,
  serverarg_show
};




From vandy@snocrash.cs.jhu.edu Tue Nov 13 12:08:11 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fADH8Bv14071
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 13 Nov 2001 12:08:11 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id MAA00792;
	Tue, 13 Nov 2001 12:52:19 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fADH5Jj28963;
	Tue, 13 Nov 2001 12:05:19 -0500
Date: Tue, 13 Nov 2001 12:05:19 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111131705.fADH5Jj28963@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/repos/net NetRepository.h NetRepository.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/13 12:05:19

  Modified:    src/repos/net NetRepository.h NetRepository.c
  Log:
  More changes for server-side commands.

Revision  Changes    Path
1.3       +2 -0      pcms/src/repos/net/NetRepository.h

Index: NetRepository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NetRepository.h	2001/11/05 19:29:07	1.2
+++ NetRepository.h	2001/11/13 17:05:19	1.3
@@ -1,4 +1,6 @@
 /* Copyright (C) 2000, The EROS Group, LLC. */
+int
+netrepository_CreateRepository(Repository *);
 
   int
 netrepository_connect(Repository *);



1.6       +423 -36   pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NetRepository.c	2001/11/08 23:07:00	1.5
+++ NetRepository.c	2001/11/13 17:05:19	1.6
@@ -2,6 +2,7 @@
 #include <repos/pcmsrepos.h>
 #include <common/ServerRequest.h>
 #include <common/ServerReply.h>
+#include <common/ServerStringArgument.h>
 
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -16,6 +17,46 @@
 /**  OLD:   inline void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen); */
 inline void sendBuff(int connectfd, const void* messagebuf);
 
+int netrepository_CreateRepository(Repository *r) {
+	SDR_stream* net_stream;
+	char *net_buf;
+	char *rawReply;
+	unsigned int incoming;
+	
+	ServerRequest *sr;
+	ServerReply *sreply;
+
+	net_stream = stream_openstring(STREAM_XML);
+
+	sr = request_create(CREATEREPOSITORY, r->uri->path, r->uri->username, PCMS_OPCODE_CREATEREPOSITORY);
+
+	/* Now serialize the request into an XML stream: */
+	sdr_write (SERVERREQUEST, net_stream, sr);
+	
+	/* Convert XML stream to char* to send over wire: */
+	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
+
+	/* Now send the data over the socket: */
+	sendBuff(*(r->connfd), net_buf);
+
+	/* Wait for the response: */
+	read (*(r->connfd), &incoming, sizeof(incoming));
+
+	if (incoming > 0) {
+	    rawReply = (char *)pcms_malloc(incoming);
+	    read(*(r->connfd), rawReply, incoming);
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY, net_stream);
+	    report (sreply->data);
+	    return 0;
+	} else {
+	    report (sreply->data);
+	    return -1;
+	} /* end if-else */
+
+} /* end netrepository_CreateRepository */
+
 int netrepository_connect(Repository *r) {
 	
 	
@@ -100,30 +141,25 @@
 	return;
 }
 
+/*
+*  Create a ServerRequest with the opcode for "get version",
+*  send it upstream and wait for the reply.
+*/
 const char *
 netrepository_GetVersion(Repository *r) {
 	SDR_stream* net_stream;
-	int opcode;
 	char* net_buf;
 	char* rawReply;
 	unsigned int incoming;
 
-	const char *testing = "Under construction.";
-
 	ServerRequest *sr;
 	ServerReply *sreply;
 
 	net_stream = stream_openstring(STREAM_XML);
-	opcode = PCMS_OPCODE_GETVERSION;
 	
-	sr = request_create(GETVERSION, r->uri->path, r->uri->username, opcode);  
+	sr = request_create(GETVERSION, r->uri->path, r->uri->username, PCMS_OPCODE_GETVERSION);  
         sdr_write (SERVERREQUEST, net_stream, sr);
 
-	/*  sdr_write("opcode name=\"getversion\"", net_stream, &opcode); */
-	/*  sdr_write("string name=\"Repository Path\"", net_stream, r->uri->path);  */
-	/* sdr_w_ulong("opcode", net_stream, opcode);  */
-	/*  sdr_w_string("repos", net_stream, r->uri->path); */
-
 	net_buf = (char *)net_stream->data;
 	stream_close(net_stream);
 
@@ -149,37 +185,132 @@
 	    return "No response from repository"; 
 }
   
-  int
-netrepository_CreateProject(Repository *r, Project *p) {
+/*
+* Create a ServerRequest object with the opcode for "create project"
+* and wait for the reply.
+*/
+int netrepository_CreateProject(Repository *r, Project *p) {
 	SDR_stream* net_stream;
-	int opcode;
 	char *net_buf;
+	char *rawReply;
+	unsigned int incoming;
+	Project *retProj;
 	
+	ServerRequest *sr;
+	ServerReply *sreply;
+
 	net_stream = stream_openstring(STREAM_XML);
-	opcode = PCMS_OPCODE_CREATEPROJECT;
-	
-	sdr_write("opcode name=\"createproject\"", net_stream, &opcode);
-	sdr_write("string name=\"Repository Path\"", net_stream, r->uri->path);
-	sdr_write("string name=\"Project\"", net_stream, p);
 
+	sr = request_create(CREATEPROJECT, r->uri->path, r->uri->username, PCMS_OPCODE_CREATEPROJECT);
+
+	/* Now add the Project argument to this request: */
+	serverrequest_AddArgument(sr, p);
+
+	/* Now serialize the request into an XML stream: */
+	sdr_write (SERVERREQUEST, net_stream, sr);
+	
+	/* Convert XML stream to char* to send over wire: */
 	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
 
-	/** OLD:    sendBuff(*(r->connfd), net_buf, net_stream->len);  */
+	/* Now send the data over the socket: */
 	sendBuff(*(r->connfd), net_buf);
 
-	stream_close(net_stream);
-	return 0;
-	
-}
+	/* Wait for the response: */
+	read (*(r->connfd), &incoming, sizeof(incoming));
 
-  Project *
+	if (incoming > 0) {
+	    rawReply = (char *)pcms_malloc(incoming);
+	    read(*(r->connfd), rawReply, incoming);
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY, net_stream);
+
+	    /* We need the Project to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    retProj = (Project *)(vec_fetch(sreply->return_objs,0)); 
+	    p->serTrueName = retProj->serTrueName;
+
+	    report(sreply->data);
+	    return 1;
+	} else {
+	    report("Invalid Server Reply.\n");
+	    return -1;
+	} /* end if-else */
+
+} /* end netrepository_CreateProject */
+
+/*
+ * Return a Project object given the true name as input.
+ * Return NULL if project not found.
+ */
+Project *
 netrepository_GetProject(Repository *r, const char *pName) {
     
-    printf ("*** Trying to find net repos project = %s\n", pName);
-    return NULL;}
+	SDR_stream* net_stream;
+	char *net_buf;
+	char *rawReply;
+	unsigned int incoming;
+	ServerStringArgument *ser_pName;
+	Project *retProj;
+	
+	ServerRequest *sr;
+	ServerReply *sreply;
+
+	/* Paranoia checks: */
+	if (r == NULL)
+	    return NULL;
+
+	if (r->uri->netloc == NULL)
+	    return NULL;
+
+	if (pName == NULL)
+	    return NULL;
 
+	net_stream = stream_openstring(STREAM_XML);
+
+	sr = request_create(GETPROJECT, r->uri->path, r->uri->username, PCMS_OPCODE_GETPROJECT);
+	ser_pName = serverarg_create(pName);
+
+	/* Now add the true name of the Project as an argument to this request: */
+	serverrequest_AddArgument(sr, ser_pName);
+
+	/* Now serialize the request into an XML stream: */
+	sdr_write (SERVERREQUEST, net_stream, sr);
+	
+	/* Convert XML stream to char* to send over wire: */
+	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
+
+	/* Now send the data over the socket: */
+	sendBuff(*(r->connfd), net_buf);
+
+	/* Wait for the response: */
+	read (*(r->connfd), &incoming, sizeof(incoming));
+
+	if (incoming > 0) {
+	    /* Allocate just enough space for server's reply: */
+	    rawReply = (char *)pcms_malloc(incoming);
+	    read(*(r->connfd), rawReply, incoming);
+
+	    /* Create SDR stream to allow easy deserialization of reply: */
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY, net_stream);
+
+	    /* We need the Project to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    retProj = (Project *)(vec_fetch(sreply->return_objs,0)); 
+	    return retProj;
+
+	} /* end if incoming > 0 */
+
+    return NULL;
+} /* end netrepository_GetProject */
+
 Project *
-netrepository_PetGetProject(Repository *r, const char *pName) {return NULL;}
+netrepository_PetGetProject(Repository *r, const char *pName) {
+    
+    return NULL;
+} /* end netrepository_PetGetProject */
 
   int 
 netrepository_PetRenameProject(Repository *r,
@@ -193,39 +324,295 @@
   StrVec * 
 netrepository_ListBranchPetNames(Repository *r, Branch *b) {return NULL;}
 
-  int 
-netrepository_CreateBranch(Repository *r, Project *p, Branch *b) {return 0;}
+/*
+* Method to create a Branch for a remote Repository.  Basically, wrap
+* the necessary parameters in a Server Request object and send it up
+* the wire:
+*/
+int netrepository_CreateBranch(Repository *r, Project *p, Branch *b) {
+    
+    SDR_stream* net_stream;
+    char *net_buf;
+    char *rawReply;
+    unsigned int incoming;
+    Branch *retBranch;
+    
+    ServerRequest *sr;
+    ServerReply *sreply;
+
+    net_stream = stream_openstring(STREAM_XML);
+
+    sr = request_create(CREATEBRANCH, r->uri->path, r->uri->username, PCMS_OPCODE_CREATEBRANCH);
+
+    /* Now add the Project and Branch arguments to this request: */
+    serverrequest_AddArgument(sr, p);
+    serverrequest_AddArgument(sr, b);
 
+    /* Now serialize the request into an XML stream: */
+    sdr_write (SERVERREQUEST, net_stream, sr);
+    
+    /* Convert XML stream to char* to send over wire: */
+    net_buf = (char *)net_stream->data;
+    stream_close(net_stream);
+
+    /* Now send the data over the socket: */
+    sendBuff(*(r->connfd), net_buf);
+
+    /* Wait for the response: */
+    read (*(r->connfd), &incoming, sizeof(incoming));
+
+    if (incoming > 0) {
+	rawReply = (char *)pcms_malloc(incoming);
+	read(*(r->connfd), rawReply, incoming);
+	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	sreply = sdr_read(SERVERREPLY, net_stream);
+	
+	/* Retrieve Branch object from the reply in order to
+	   update the Branch serTrueName field */
+	retBranch = (Branch *)(vec_fetch(sreply->return_objs,0)); 
+	b->serTrueName = retBranch->serTrueName;
+
+	report(sreply->data);
+	return 1;
+    } else {
+	report("Invalid Server Reply.\n");
+	return -1;
+    } /* end if-else */
+
+} /* end netrepository_CreateBranch */
+
   int
 netrepository_PetRenameBranch(Repository *r,
 			       Project *p,
 			       const char *oldName,
-			       const char *newName) {return 0;}
-  Branch *
+			       const char *newName) {
+    return 0;
+} /* end netrepository_PetRenameBranch */
+
+/*
+ * Return a Branch object given the true name of
+ * the branch, the Project to which the Branch
+ * belongs, and the Repository as input.  
+ * Return NULL on any error.
+ */
+Branch *
 netrepository_GetBranch(Repository *r, Project *p,
 			 const char *bName) {
     
-    printf("*** Trying to get net repos branch %s\n",bName);
-    return NULL;}
+	SDR_stream* net_stream;
+	char *net_buf;
+	char *rawReply;
+	unsigned int incoming;
+	ServerStringArgument *ser_bName;
+	Branch *retBranch;
+	
+	ServerRequest *sr;
+	ServerReply *sreply;
+
+	/* Paranoia checks: */
+	if (r == NULL)
+	    return NULL;
 
+	if (r->uri->netloc == NULL)
+	    return NULL;
+
+	if (p == NULL)
+	    return NULL;
+
+	if (bName == NULL)
+	    return NULL;
+
+	net_stream = stream_openstring(STREAM_XML);
+
+	sr = request_create(GETBRANCH, r->uri->path, r->uri->username, PCMS_OPCODE_GETBRANCH);
+	ser_bName = serverarg_create(bName);
+
+	/* Now add the Project as an argument to this request: */
+	serverrequest_AddArgument(sr, p);
+
+	/* Now add the true name of the Branch as an argument to this request: */
+	serverrequest_AddArgument(sr, ser_bName);
+
+	/* Now serialize the request into an XML stream: */
+	sdr_write (SERVERREQUEST, net_stream, sr);
+	
+	/* Convert XML stream to char* to send over wire: */
+	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
+
+	/* Now send the data over the socket: */
+	sendBuff(*(r->connfd), net_buf);
+
+	/* Wait for the response: */
+	read (*(r->connfd), &incoming, sizeof(incoming));
+
+	if (incoming > 0) {
+	    /* Allocate just enough space for server's reply: */
+	    rawReply = (char *)pcms_malloc(incoming);
+	    read(*(r->connfd), rawReply, incoming);
+
+	    /* Create SDR stream to allow easy deserialization of reply: */
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY, net_stream);
+
+	    /* We need the Branch to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    retBranch = (Branch *)(vec_fetch(sreply->return_objs,0)); 
+	    return retBranch;
+	} /* end if incoming > 0 */
+
+    return NULL;
+} /* end netrepository_GetBranch */
+
   Branch *
 netrepository_PetGetBranch(Repository *r, Project *p, const char *bName) {return NULL;}
 
+/*
+ * Update the Branch object in support of a Commit operation.  The
+ * appropriate Repository and Project objects are passed as input, along
+ * with the representation of the updated Branch object.  This method
+ * simply serializes the input parameters and passes them to the server.
+ * (Note the Repository object is not Serializable, so we just pass the
+ * path field up the stream.)
+ */
   int 
-netrepository_ReviseBranch(Repository *r, Project *p, Branch *b) {return 0;}
+netrepository_ReviseBranch(Repository *r, Project *p, Branch *b) {
+    
+	SDR_stream* net_stream;
+	char *net_buf;
+	char *rawReply;
+	unsigned int incoming;
+	
+	ServerRequest *sr;
+	ServerReply *sreply;
+
+	/* Paranoia checks: */
+	if (r == NULL)
+	    return -1;
+
+	if (r->uri->netloc == NULL)
+	    return -1;
+
+	if (p == NULL)
+	    return -1;
+
+	if (b == NULL)
+	    return -1;
+
+	net_stream = stream_openstring(STREAM_XML);
+
+	sr = request_create(REVISEBRANCH, r->uri->path, r->uri->username, PCMS_OPCODE_REVISEBRANCH);
+
+	/* Now add the Project as an argument to this request: */
+	serverrequest_AddArgument(sr, p);
+
+	/* Now add the Branch as an argument to this request: */
+	serverrequest_AddArgument(sr, b);
+
+	/* Now serialize the request into an XML stream: */
+	sdr_write (SERVERREQUEST, net_stream, sr);
+	
+	/* Convert XML stream to char* to send over wire: */
+	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
+
+	/* Now send the data over the socket: */
+	sendBuff(*(r->connfd), net_buf);
+
+	/* Wait for the response: */
+	read (*(r->connfd), &incoming, sizeof(incoming));
+
+	if (incoming > 0) {
+	    /* Allocate just enough space for server's reply: */
+	    rawReply = (char *)pcms_malloc(incoming);
+	    read(*(r->connfd), rawReply, incoming);
 
+	    /* Create SDR stream to allow easy deserialization of reply: */
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY, net_stream);
+
+	    report(sreply->data);
+	    return 0;
+	} else {
+	    report ("Invalid Server Reply.\n");
+	    return -1;
+	} /* end if incoming > 0 */
+
+    return 0;
+} /* end netrepository_ReviseBranch */
+
   StrVec *
 netrepository_ListBranches(Repository *r, Project *p) {return NULL;}
 
-  const char *
+const char *
 netrepository_ReviseEntity(Repository *r,
-			    const char *tName, void *data) { return NULL; }
+			    const char *tName, void *serobject) { 
+    
+	SDR_stream* net_stream;
+	char *net_buf;
+	char *rawReply;
+	unsigned int incoming;
+	
+	ServerRequest *sr;
+	ServerReply *sreply;
+
+	/* Paranoia checks: */
+	if (r == NULL)
+	    return NULL;
+
+	if (r->uri->netloc == NULL)
+	    return NULL;
+
+	if (serobject == NULL)
+	    return NULL;
+
+	net_stream = stream_openstring(STREAM_XML);
+
+	sr = request_create(REVISEENTITY, r->uri->path, r->uri->username, PCMS_OPCODE_REVISEENTITY);
+ 
+	/* Now add the incoming Serializable object as an argument to this request: */
+	serverrequest_AddArgument(sr, serobject);
+
+	/* Now serialize the request into an XML stream: */
+	sdr_write (SERVERREQUEST, net_stream, sr);
+	
+	/* Convert XML stream to char* to send over wire: */
+	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
+
+	/* Now send the data over the socket: */
+	sendBuff(*(r->connfd), net_buf);
+
+	/* Wait for the response: */
+	read (*(r->connfd), &incoming, sizeof(incoming));
+
+	if (incoming > 0) {
+
+	    /* Allocate just enough space for server's reply: */
+	    rawReply = (char *)pcms_malloc(incoming);
+	    read(*(r->connfd), rawReply, incoming);
+
+	    /* Create SDR stream to allow easy deserialization of reply: */
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY, net_stream);
+
+	    /* We need the True Name to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    return sreply->data;
+
+	} /* end incoming > 0 */
+
+    return NULL; 
+
+} /* end netrepository_ReviseEntity */
+
   void *
 netrepository_GetEntity(Repository *r,
 			 const char *tName) {return NULL;}
 
 
 void netrepository_init(Repository * r) {
+  r->CreateRepository = netrepository_CreateRepository;
   r->GetVersion = netrepository_GetVersion;
   r->Connect = netrepository_connect;
 




From vandy@snocrash.cs.jhu.edu Tue Nov 13 12:08:58 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fADH8wv14079
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 13 Nov 2001 12:08:58 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id MAA00805;
	Tue, 13 Nov 2001 12:53:12 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fADH6C629002;
	Tue, 13 Nov 2001 12:06:12 -0500
Date: Tue, 13 Nov 2001 12:06:12 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111131706.fADH6C629002@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/repos/fs CachedFileRepos.c FileRepos.c FileRepos.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/13 12:06:12

  Modified:    src/repos/common Repository.c Repository.h
               src/repos/fs CachedFileRepos.c FileRepos.c FileRepos.h
  Log:
  More changes for server-side commands.

Revision  Changes    Path
1.4       +3 -3      pcms/src/repos/common/Repository.c

Index: Repository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/Repository.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Repository.c	2001/10/25 01:03:02	1.3
+++ Repository.c	2001/11/13 17:06:12	1.4
@@ -3,6 +3,7 @@
 #include <pcms.h>
 #include <repos/pcmsrepos.h>
 
+/*******
 void
 pcms_create_repository(Repository *r, int argc, char **argv)
 {
@@ -60,10 +61,9 @@
   if (path_mkdir(path_join(uri->path, "petnames")) < 0)
     report_error(errno, "Could not create petnames directory\n");
 
-  /* FIX: Need to do something about creating an initial ACL for the
-   * repository as a whole to determine who can create new projects.
-   */
 }
+****/
+
 
 #if 0
 Repository::Repository(const char *argURI, AuthInfo* ai = 0)



1.5       +3 -0      pcms/src/repos/common/Repository.h

Index: Repository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/Repository.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Repository.h	2001/11/05 19:29:06	1.4
+++ Repository.h	2001/11/13 17:06:12	1.5
@@ -27,6 +27,8 @@
   // Establishing a connection to the repository:
   int (*Connect)(Repository *r);
 
+  int (*CreateRepository)(Repository *r);
+
   /* Manipulation of projects: */
   int (*CreateProject)(Repository *r, Project *p);
   Project *(*GetProject)(Repository *r, const char *trueName);
@@ -56,6 +58,7 @@
   void *(*GetEntity)(Repository *r, const char *trueName);
 };
 
+#define repos_CreateRepository(r)  r->CreateRepository(r)
 #define repos_GetVersion(r)        r->GetVersion(r)
 /* Establishing a connection to the repository: */
 



1.4       +7 -0      pcms/src/repos/fs/CachedFileRepos.c

Index: CachedFileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/CachedFileRepos.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CachedFileRepos.c	2001/11/05 19:29:06	1.3
+++ CachedFileRepos.c	2001/11/13 17:06:12	1.4
@@ -22,6 +22,12 @@
  */
 
  static int
+cachedfilerepository_CreateRepository(Repository *r)
+{
+  return filerepository_CreateRepository(r);
+}
+
+ static int
 cachedfilerepository_CreateProject(Repository *r, Project *p)
 {
   return filerepository_CreateProject(r, p);
@@ -216,6 +222,7 @@
  void
 cachedfilerepository_init(Repository *r)
 {
+  r->CreateRepository = cachedfilerepository_CreateRepository;
   r->GetVersion = cachedfilerepository_GetVersion;
   r->Connect = cachedfilerepository_connect;
 



1.4       +77 -7     pcms/src/repos/fs/FileRepos.c

Index: FileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FileRepos.c	2001/11/05 19:29:07	1.3
+++ FileRepos.c	2001/11/13 17:06:12	1.4
@@ -3,7 +3,75 @@
 #include <pcms.h>
 #include <repos/pcmsrepos.h>
 
+int
+filerepository_CreateRepository(Repository *r) {
+  URI *uri;
+  const char *verfile;
+  FILE *f;
+  
+  /*****
+  if (opt_HaveServer == 0) {
+    report_error(EX_NoServer,
+		 "To reduce the chance of overwriting an existing\n"
+		 "      repository, the \"create repository\" command\n"
+		 "      requires that you give the repository URI on the\n"
+		 "      command line using the --server option.\n");
+  }
+ ****/
+
+  if (r == 0)
+      uri = uri_create(ServerURI);
+  else
+      uri = r->uri;
+
+  if (!uri->well_formed)
+    report_error(EX_NoServer, "Malformed server URI\n");
+
+  if (uri->relative)
+    report_error(EX_NoServer, "Please use a non-relative URI\n");
 
+  if (strcmp(uri->scheme, "file") != 0)
+    report_error(EX_NoServer, "URI for \"create repository\" must be a file URI\n");
+
+  debug(DBG_PATH, "Path to new repository is \"%s\"\n", uri->path);
+
+  if (path_exists(uri->path) && !path_isdir(uri->path))
+      report_error(EX_NoServer, "URI exists and is not a directory\n");
+
+  if (path_smkdir(uri->path) < 0)
+    report_error(errno, "Could not create repository directory\n");
+  
+  verfile = path_join(uri->path, "PCMS-VERSION");
+  if (path_exists(verfile))
+    report_error(EX_NoServer, "Repository already exists\n");
+
+  report("Creating version file \"%s\"\n", verfile);
+
+  f = fopen(verfile, "wt+");
+  if (f == NULL)
+    report_error(EX_NoServer, "Could not open file\n");
+  
+  fprintf(f, "PCMS version %u.%u.%u pl %u\n", MAJOR_VERSION,
+	  MINOR_VERSION, MICRO_VERSION, PATCH_VERSION);
+  fclose(f);
+
+  if (path_mkdir(path_join(uri->path, "entities")) < 0)
+    report_error(errno, "Could not create entities directory\n");
+  
+  if (path_mkdir(path_join(uri->path, "projects")) < 0)
+    report_error(errno, "Could not create projects directory\n");
+
+  if (path_mkdir(path_join(uri->path, "petnames")) < 0)
+    report_error(errno, "Could not create petnames directory\n");
+
+  /* FIX: Need to do something about creating an initial ACL for the
+   * repository as a whole to determine who can create new projects.
+   */
+
+  return 0;
+
+} /* end filerepository_CreateRepository */
+
  int
 filerepository_connect(Repository *r)
 {
@@ -88,8 +156,8 @@
   const char *path;
   SDR_stream *strm;
   
-  tn = truename_NewSequence();
-  p->serTrueName = tn;
+  p->serTrueName = truename_NewSequence();
+  tn = p->serTrueName;
   
   relpath = path_tn_fixup(tn);
   relpath = path_join("projects", tn);
@@ -111,7 +179,7 @@
   sdr_write("PROJECT", strm, p);
   stream_close(strm);
 
-  p->petName = BindPetName(r, 0, p->nickname, tn);
+  p->petName = BindPetName(r, 0, p->nickname, p->serTrueName);
 
   return 0;
 }
@@ -328,13 +396,14 @@
   const char *tn;
   SDR_stream *strm;
 
-  tn = truename_NewSequence();
-  b->serTrueName = tn;
+  b->serTrueName = truename_NewSequence();
+  tn = b->serTrueName;
   
   projpath = path_tn_fixup(p->serTrueName);
+
   projpath = path_join("projects", projpath);
 
-  relpath = path_tn_fixup(tn);
+  relpath = path_tn_fixup(b->serTrueName);
   relpath = path_join("branches", relpath);
 
   path = path_join(r->uri->path, projpath);
@@ -344,7 +413,7 @@
   sdr_write("BRANCH", strm, b);
   stream_close(strm);
 
-  b->petName = BindPetName(r, projpath, b->nickname, tn);
+  b->petName = BindPetName(r, projpath, b->nickname, b->serTrueName);
 
   return 0;
 }
@@ -598,6 +667,7 @@
  void
 filerepository_init(Repository *r)
 {
+  r->CreateRepository = filerepository_CreateRepository;
   r->GetVersion = filerepository_GetVersion;
   r->Connect = filerepository_connect;
 



1.2       +3 -0      pcms/src/repos/fs/FileRepos.h

Index: FileRepos.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FileRepos.h	2001/10/10 22:07:21	1.1
+++ FileRepos.h	2001/11/13 17:06:12	1.2
@@ -14,6 +14,9 @@
 const char *
 filerepository_GetVersion(Repository *);
   
+int
+filerepository_CreateRepository(Repository *);
+
   int
 filerepository_CreateProject(Repository *, Project *);
 




From vandy@snocrash.cs.jhu.edu Tue Nov 13 12:09:43 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fADH9hv14120
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 13 Nov 2001 12:09:43 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id MAA00836;
	Tue, 13 Nov 2001 12:53:59 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fADH6xk29039;
	Tue, 13 Nov 2001 12:06:59 -0500
Date: Tue, 13 Nov 2001 12:06:59 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111131706.fADH6xk29039@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server pcmsserver.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/13 12:06:59

  Modified:    src/server pcmsserver.c
  Log:
  More changes for server-side commands.

Revision  Changes    Path
1.6       +272 -0    pcms/src/server/pcmsserver.c

Index: pcmsserver.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/pcmsserver.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- pcmsserver.c	2001/11/08 23:17:23	1.5
+++ pcmsserver.c	2001/11/13 17:06:59	1.6
@@ -6,6 +6,7 @@
 #include <./repos/pcmsrepos.h>
 #include <./common/ServerRequest.h>
 #include <./common/ServerReply.h>
+#include <./common/ServerStringArgument.h>
 
 #define MAX_CLIENTS 100
 #define MESSAGE_LENGTH 4096
@@ -70,6 +71,10 @@
 int max_index_into_clients;
 int max_sockfd_so_far;
 char *tooManyClients = "Connection refused... too many clients.";
+Project *proj_arg;
+Branch *branch_arg;
+ServerStringArgument *string_arg;
+void *ser_arg;
 
 	quit_action.sa_handler = (&quitter);
 	
@@ -211,6 +216,37 @@
 			thisRequest = (ServerRequest *)GetFromMsgQueue(readq);
 			switch (thisRequest->opcode) {
 
+			    /*******************************************
+			     *   CREATE A REPOSITORY:
+			     *******************************************/
+			    case PCMS_OPCODE_CREATEREPOSITORY:
+
+				/* Idea is that repos should be a file repository on this
+				*  server, so instantiate a FileRepos object for this command:
+				*/
+				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
+				strncpy(localURIstr, "file:",5);
+				strcat(localURIstr, nextRequest->repos_path);
+				localRepos = (Repository *)pcms_malloc(sizeof(Repository));
+				localRepos->uri = uri_create(localURIstr);
+				localRepos->auth = 0;
+				localRepos->info = 0;
+				
+				/* Now create a repository just like the File Repository: */
+				if (filerepository_CreateRepository(localRepos) == 0)
+				    reply = reply_create("Success.\n", thisRequest->sockfd);
+				else
+				    reply = reply_create("Error.\n", thisRequest->sockfd);
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &outgoingset);
+
+				break;
+
+			    /*******************************************
+			     *   GET THE VERSION OF THIS SERVER:
+			     *******************************************/
 			    case PCMS_OPCODE_GETVERSION:
 
 				/* Idea is that repos should be a file repository on this
@@ -231,10 +267,246 @@
 				FD_SET(reply->sockfd, &outgoingset);
 
 				break;
+
+			    /*******************************************
+			     *   CREATE A BRANCH:
+			     *******************************************/
+			    case PCMS_OPCODE_CREATEBRANCH:
+
+				/* Idea is that repos should be a file repository on this
+				*  server, so instantiate a FileRepos object for this command:
+				*/
+				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
+				strncpy(localURIstr, "file:",5);
+				strcat(localURIstr, nextRequest->repos_path);
+				localRepos = repository_open(localURIstr, 0);
+				
+				/* This command requires a Project object and
+				   a Branch object as arguments.  */
+				if (vec_size(thisRequest->args) > 0) {
+				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
+
+				    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 1));
+
+				    /* Now just do what the File Repository object would do: */
+				    filerepository_CreateBranch(localRepos, proj_arg, branch_arg);
+
+				    reply = reply_create("Success: Branch Created.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, branch_arg);
+				} else {
+				    reply = reply_create("Error creating Branch.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, branch_arg);
+				} /* end if checking if arguments are present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &outgoingset);
+
+				thisRequest = NULL;
+				break;
+
+			    /*******************************************
+			     *   CREATE A PROJECT:
+			     *******************************************/
 			    case PCMS_OPCODE_CREATEPROJECT:
+
+				/* Idea is that repos should be a file repository on this
+				*  server, so instantiate a FileRepos object for this command:
+				*/
+				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
+				strncpy(localURIstr, "file:",5);
+				strcat(localURIstr, nextRequest->repos_path);
+				localRepos = repository_open(localURIstr, 0);
+				
+				/* This command requires a Project object as an argument.
+				*  Make sure the argument is available
+				*/
+				if (vec_size(thisRequest->args) > 0) {
+				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
+
+				    /* Now just do what the File Repository object would do: */
+				    filerepository_CreateProject(localRepos, proj_arg);
+
+				    reply = reply_create("Success: Project created.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, proj_arg);
+
+				} else {
+				    reply = reply_create("Error creating Project.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, proj_arg);
+				} /* end if checking if argument is present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &outgoingset);
+
+				thisRequest = NULL;
 				break;
+
+			    /**********************************************************
+			     *   GET A PROJECT BASED ON TRUE NAME PASSED AS PARAMETER:
+			     **********************************************************/
 			    case PCMS_OPCODE_GETPROJECT:
+
+				/* Idea is that repos should be a file repository on this
+				*  server, so instantiate a FileRepos object for this command:
+				*/
+				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
+				strncpy(localURIstr, "file:",5);
+				strcat(localURIstr, nextRequest->repos_path);
+				localRepos = repository_open(localURIstr, 0);
+				
+				/* This command requires a ServerStringArgument object as an argument.
+				*  Make sure the argument is available
+				*/
+				if (vec_size(thisRequest->args) > 0) {
+				    /* The ServerStringArgument that's part of this request contains
+				     * the trueName of the project that needs to be retrieved:
+				     */
+				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
+
+				    /* Now just do what the File Repository object would do: */
+				    proj_arg = filerepository_GetProject(localRepos, string_arg->data);
+
+				    reply = reply_create("Success: Project retrieved.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, proj_arg);
+
+				} else {
+				    reply = reply_create("Error retrieving Project.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, proj_arg);
+				} /* end if checking if argument is present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &outgoingset);
+
+				thisRequest = NULL;
+				break;
+
+			    /**********************************************************
+			     *   GET A BRANCH BASED ON TRUE NAME PASSED AS PARAMETER:
+			     **********************************************************/
+			    case PCMS_OPCODE_GETBRANCH:
+
+				/* Idea is that repos should be a file repository on this
+				*  server, so instantiate a FileRepos object for this command:
+				*/
+				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
+				strncpy(localURIstr, "file:",5);
+				strcat(localURIstr, nextRequest->repos_path);
+				localRepos = repository_open(localURIstr, 0);
+				
+				/* This command requires a ServerStringArgument object as an argument.
+				*  Make sure the argument is available
+				*/
+				if (vec_size(thisRequest->args) > 0) {
+
+				    /*
+				     * First argument should be the Project object:
+				     */
+				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
+
+				    /* The ServerStringArgument that's part of this request contains
+				     * the trueName of the branch that needs to be retrieved:
+				     */
+				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
+
+				    /* Now just do what the File Repository object would do: */
+				    branch_arg = filerepository_GetBranch(localRepos, proj_arg, string_arg->data);
+
+				    reply = reply_create("Success: Branch retrieved.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, branch_arg);
+
+				} else {
+				    reply = reply_create("Error retrieving Branch.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, branch_arg);
+				} /* end if checking if argument is present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &outgoingset);
+
+				thisRequest = NULL;
+
 				break;
+
+			    /**********************************************************
+			     *   REVISE A BRANCH (IN SUPPORT OF COMMIT COMMAND):
+			     **********************************************************/
+			    case PCMS_OPCODE_REVISEBRANCH:
+
+				/* Idea is that repos should be a file repository on this
+				*  server, so instantiate a FileRepos object for this command:
+				*/
+				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
+				strncpy(localURIstr, "file:",5);
+				strcat(localURIstr, nextRequest->repos_path);
+				localRepos = repository_open(localURIstr, 0);
+				
+				/* This command requires Project and Branch objects as arguments.
+				 * Make sure the arguments are available:
+				 */
+				if (vec_size(thisRequest->args) > 0) {
+
+				    /* First argument should be the Project object: */
+				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
+
+				    /* The Branch object should be next: */
+				    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 1));
+
+				    /* Now just do what the File Repository object would do: */
+				    filerepository_ReviseBranch(localRepos, proj_arg, branch_arg);
+
+				    reply = reply_create("Success: Branch updated.\n", thisRequest->sockfd);
+
+				} else {
+				    reply = reply_create("Error updating Branch.\n", thisRequest->sockfd);
+				} /* end if checking if argument is present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &outgoingset);
+
+				thisRequest = NULL;
+
+				break;
+
+			    /**********************************************************
+			     *   REVISE AN ENTITY (IN SUPPORT OF COMMIT COMMAND):
+			     **********************************************************/
+			    case PCMS_OPCODE_REVISEENTITY:
+
+				/* Idea is that repos should be a file repository on this
+				*  server, so instantiate a FileRepos object for this command:
+				*/
+				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
+				strncpy(localURIstr, "file:",5);
+				strcat(localURIstr, nextRequest->repos_path);
+				localRepos = repository_open(localURIstr, 0);
+				
+				/* This command requires a ServerStringArgument object as an argument.
+				*  Make sure the argument is available
+				*/
+				if (vec_size(thisRequest->args) > 0) {
+				    /* The Serializable object that's part of this request contains
+				     * the info for the entity that needs to be revised:
+				     */
+				    ser_arg = (void *)(vec_fetch(thisRequest->args, 0));
+
+				    /* Now just do what the File Repository object would do: */
+				    reply = reply_create(filerepository_ReviseEntity(localRepos, 0, ser_arg), thisRequest->sockfd);
+
+				} else {
+				    reply = reply_create("Error revising Entity.\n", thisRequest->sockfd);
+				} /* end if checking if argument is present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &outgoingset);
+
+				thisRequest = NULL;
+
+				break;
+
 			    case PCMS_OPCODE_PETGETPROJECT:
 				break;
 			    case PCMS_OPCODE_PETRENAMEPROJECT:




From vandy@snocrash.cs.jhu.edu Tue Nov 13 12:10:18 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fADHAIv14149
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 13 Nov 2001 12:10:18 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id MAA00857;
	Tue, 13 Nov 2001 12:54:33 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fADH7Yd29068;
	Tue, 13 Nov 2001 12:07:34 -0500
Date: Tue, 13 Nov 2001 12:07:34 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111131707.fADH7Yd29068@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src pcmsrules.mk.in
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/13 12:07:34

  Modified:    src      pcmsrules.mk.in
  Log:
  Changes to support changes :)

Revision  Changes    Path
1.3       +2 -1      pcms/src/pcmsrules.mk.in

Index: pcmsrules.mk.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/pcmsrules.mk.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pcmsrules.mk.in	2001/11/08 23:03:26	1.2
+++ pcmsrules.mk.in	2001/11/13 17:07:34	1.3
@@ -29,7 +29,8 @@
 	$(TOPDIR)/common/xmalloc.o \
 	$(TOPDIR)/common/os.o \
 	$(TOPDIR)/common/ServerRequest.o \
-	$(TOPDIR)/common/ServerReply.o
+	$(TOPDIR)/common/ServerReply.o \
+	$(TOPDIR)/common/ServerStringArgument.o
 
 REPOSOBJECTS=\
 	$(TOPDIR)/repos/fs/CachedFileRepos.o \




From vandy@snocrash.cs.jhu.edu Wed Nov 14 17:27:37 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fAEMRbv27585
	for <dcms-cvs@eros.cs.jhu.edu>; Wed, 14 Nov 2001 17:27:37 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA00891;
	Wed, 14 Nov 2001 18:11:41 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fAEMObb06072;
	Wed, 14 Nov 2001 17:24:37 -0500
Date: Wed, 14 Nov 2001 17:24:37 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111142224.fAEMObb06072@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server pcmsserver.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/14 17:24:37

  Modified:    src/client WsEntity.c
               src/common Change.c Entity.c Entity.h ServerReply.c
                        ServerReply.h pcms_opcode.h
               src/repos/fs CachedFileRepos.c FileRepos.c FileRepos.h
               src/repos/net NetRepository.c NetRepository.h
               src/server pcmsserver.c
  Log:
  More changes for implementing server-side logic.

Revision  Changes    Path
1.3       +1 -1      pcms/src/client/WsEntity.c

Index: WsEntity.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/WsEntity.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WsEntity.c	2001/10/19 03:44:10	1.2
+++ WsEntity.c	2001/11/14 22:24:36	1.3
@@ -178,7 +178,7 @@
 wsentity_serialize(SDR_stream *strm, const void *ob)
 {
   const WsEntity *wse = ob;
-  
+
   /* First do the entity part: */
   /* NOTE: IF YOU CHANGE THIS, CHANGE IT IN ENTITY ALSO!!! */
   sdr_w_string("familyNID", strm, wse->e.familyNID);



1.3       +0 -1      pcms/src/common/Change.c

Index: Change.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/Change.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Change.c	2001/10/19 03:44:10	1.2
+++ Change.c	2001/11/14 22:24:36	1.3
@@ -57,7 +57,6 @@
   Change *chg = (Change *) pcms_malloc(sizeof(Change));
 
   chg->serType = &Change_SerType;
-  chg->serTrueName = 0;
   
   chg->parent             = sdr_r_string("parent", strm);
   chg->mergeParent        = sdr_r_string("mergeParent", strm);



1.3       +3 -3      pcms/src/common/Entity.c

Index: Entity.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/Entity.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Entity.c	2001/10/19 03:44:10	1.2
+++ Entity.c	2001/11/14 22:24:36	1.3
@@ -30,7 +30,7 @@
   Entity *e = (Entity *) pcms_malloc(sizeof(Entity));
 
   e->serType             = &Entity_SerType;
-  e->serTrueName         = 0;
+  e->serTrueName         = 0; 
 
   /* NOTE: IF YOU CHANGE THIS, CHANGE IT IN WSENTITY ALSO!!! */
   e->familyNID           = sdr_r_string("familyNID", strm);
@@ -49,8 +49,8 @@
   return e;
 }
 
-static void
-entity_show(const void *v)
+static
+void entity_show(const void *v)
 {
   const Entity *e = v;
   



1.2       +5 -0      pcms/src/common/Entity.h

Index: Entity.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/Entity.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Entity.h	2001/10/10 22:07:21	1.1
+++ Entity.h	2001/11/14 22:24:36	1.2
@@ -1,4 +1,6 @@
 /* Copyright (C) 2000, The EROS Group, LLC. */
+#ifndef __ENTITY_H__
+#define __ENTITY_H__
 
 /* Entity -- description of a particular entity
  */
@@ -54,3 +56,6 @@
 #endif
 
 void entity_CreateFamNID(Entity *);
+
+#endif
+



1.3       +1 -2      pcms/src/common/ServerReply.c

Index: ServerReply.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerReply.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServerReply.c	2001/11/13 17:02:33	1.2
+++ ServerReply.c	2001/11/14 22:24:36	1.3
@@ -46,8 +46,7 @@
   return p;
 } /* end reply_create */
 
-static void
-reply_show(const void *ob)
+static void reply_show(const void *ob)
 {
   const ServerReply *p = ob;
   unsigned int u;



1.3       +6 -0      pcms/src/common/ServerReply.h

Index: ServerReply.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerReply.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServerReply.h	2001/11/13 17:02:33	1.2
+++ ServerReply.h	2001/11/14 22:24:36	1.3
@@ -1,4 +1,7 @@
 /* Copyright (C) 2000, The EROS Group, LLC. */
+#ifndef __SERVERREPLY_H__
+#define __SERVERREPLY_H__
+
 #include "pcms_opcode.h"
 
 typedef struct ServerReply {
@@ -16,4 +19,7 @@
  * Need method to add return objects:
  */
 void serverreply_AddArgument(ServerReply*, void*);
+
+
+#endif
 



1.4       +1 -0      pcms/src/common/pcms_opcode.h

Index: pcms_opcode.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/pcms_opcode.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- pcms_opcode.h	2001/11/13 17:02:33	1.3
+++ pcms_opcode.h	2001/11/14 22:24:36	1.4
@@ -34,6 +34,7 @@
 #define CREATEBRANCH "createBranch"
 #define PETRENAMEBRANCH "renamePetBranch"
 #define GETBRANCH "getBranch"
+#define GETENTITY "getEntity"
 #define PETGETBRANCH "getPetBranch"
 #define REVISEBRANCH "reviseBranch"
 #define REVISEENTITY "reviseEntity"



1.5       +1 -1      pcms/src/repos/fs/CachedFileRepos.c

Index: CachedFileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/CachedFileRepos.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CachedFileRepos.c	2001/11/13 17:06:12	1.4
+++ CachedFileRepos.c	2001/11/14 22:24:37	1.5
@@ -148,7 +148,7 @@
 	  cacheiterator->next = ecache->cachehead->next;
 	  cacheiterator->next->prev = cacheiterator;
 	  ecache->cachehead->next = cacheiterator;
-	  return cacheiterator->ent;
+	  return (cacheiterator->ent);
 	}
 	else {
 	  /* Item invalid, remove and exit the loop to get the item from disk*/



1.5       +1 -2      pcms/src/repos/fs/FileRepos.c

Index: FileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FileRepos.c	2001/11/13 17:06:12	1.4
+++ FileRepos.c	2001/11/14 22:24:37	1.5
@@ -642,8 +642,7 @@
   return trueName;
 }
 
-  void *
-filerepository_GetEntity(Repository *r,
+void * filerepository_GetEntity(Repository *r,
 			  const char *trueName)
 {
   SDR_stream *strm;



1.3       +1 -1      pcms/src/repos/fs/FileRepos.h

Index: FileRepos.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FileRepos.h	2001/11/13 17:06:12	1.2
+++ FileRepos.h	2001/11/14 22:24:37	1.3
@@ -61,7 +61,7 @@
   const char *
 filerepository_ReviseEntity(Repository *,
 			    const char *, void *);
-  void *
+void *
 filerepository_GetEntity(Repository *,
 			 const char *);
  void



1.7       +78 -2     pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NetRepository.c	2001/11/13 17:05:19	1.6
+++ NetRepository.c	2001/11/14 22:24:37	1.7
@@ -606,10 +606,86 @@
 
 } /* end netrepository_ReviseEntity */
 
-  void *
+/*
+ * Return a pointer to an Entity, given the Repository and
+ * the Entity's true name as input.
+ */
+void *
 netrepository_GetEntity(Repository *r,
-			 const char *tName) {return NULL;}
+			 const char *tName) {
+    
+	SDR_stream* net_stream;
+	char *net_buf;
+	char *rawReply;
+	unsigned int incoming;
+	ServerStringArgument *ser_tName;
+	Serializable *retEnt;
+	
+	ServerRequest *sr;
+	ServerReply *sreply;
 
+	/* Paranoia checks: */
+	if (r == NULL)
+	    return NULL;
+
+	if (r->uri->netloc == NULL)
+	    return NULL;
+
+	if (tName == NULL)
+	    return NULL;
+
+	net_stream = stream_openstring(STREAM_XML);
+
+	sr = request_create(GETENTITY, r->uri->path, r->uri->username, PCMS_OPCODE_GETENTITY);
+	ser_tName = serverarg_create(tName);
+
+	/* Now add the true name of the Project as an argument to this request: */
+	serverrequest_AddArgument(sr, ser_tName);
+
+	/* Now serialize the request into an XML stream: */
+	sdr_write (SERVERREQUEST, net_stream, sr);
+	
+	/* Convert XML stream to char* to send over wire: */
+	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
+
+	/* Now send the data over the socket: */
+	sendBuff(*(r->connfd), net_buf);
+
+	/* Wait for the response: */
+	read (*(r->connfd), &incoming, sizeof(incoming));
+
+	if (incoming > 0) {
+	    /* Allocate just enough space for server's reply: */
+	    rawReply = (char *)pcms_malloc(incoming);
+	    read(*(r->connfd), rawReply, incoming);
+
+	    /* Create SDR stream to allow easy deserialization of reply: */
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY, net_stream);
+
+	    /* retrieve the Entity/Change object from the reply: */
+	    retEnt = (Serializable *)(vec_fetch(sreply->return_objs,0)); 
+	    
+	    /* This next step is VERY IMPORTANT:  Realize that the entity
+	     * we're retrieving here can be an Entity or a Change object
+	     * (and others?) that do NOT serialize they're true name.  This
+	     * is because the true name is essentially the file name of the
+	     * entity and the entity itself doesn't need to store that.  Thus,
+	     * right before we send this entity back over the wire, we need
+	     * to set its true name accordingly.  Note that its true name
+	     * came as an input parameter to this function, so that makes it
+	     * easy.
+             */
+	    retEnt->ser_trueName = tName;
+
+	    return retEnt;
+
+	} /* end if incoming > 0 */
+
+    return NULL;
+
+} /* end netrepository_GetEntity */
 
 void netrepository_init(Repository * r) {
   r->CreateRepository = netrepository_CreateRepository;



1.4       +1 -1      pcms/src/repos/net/NetRepository.h

Index: NetRepository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NetRepository.h	2001/11/13 17:05:19	1.3
+++ NetRepository.h	2001/11/14 22:24:37	1.4
@@ -56,7 +56,7 @@
 netrepository_ReviseEntity(Repository *,
 			    const char *, void *);
 
-  void *
+void *
 netrepository_GetEntity(Repository *,
 			 const char *);
 



1.7       +114 -58   pcms/src/server/pcmsserver.c

Index: pcmsserver.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/pcmsserver.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- pcmsserver.c	2001/11/13 17:06:59	1.6
+++ pcmsserver.c	2001/11/14 22:24:37	1.7
@@ -9,13 +9,15 @@
 #include <./common/ServerStringArgument.h>
 
 #define MAX_CLIENTS 100
-#define MESSAGE_LENGTH 4096
 
 #define SIZEOFREQUESTQUEUE 100
 
 void quitter(int);
+void open_local_repos_if_needed(char *);
 
 int quit;
+Repository *localRepos = NULL;
+char *storeReposURI = NULL;
 
 /****************************************************
 * M A I N   processing loop.
@@ -38,13 +40,14 @@
 int main() {
 	struct sockaddr_in servaddr, cliaddr;
 	int servfd;
-	fd_set fullset, incomingset, outgoingset;
+	fd_set readholder, incomingset;
+	fd_set writeholder, outgoingset;
 	int clients[MAX_CLIENTS];
 	int index;
 	int select_ready;
-	char message[MESSAGE_LENGTH];
+	char *message;
 	int lmess, trmess;
-	int i, clidx, readres,clientlen;
+	int i, readres,clientlen;
 	struct sigaction quit_action;
 	struct timeval tv;
 	
@@ -59,7 +62,6 @@
 char *repos;
 int x;
 unsigned int code;
-Repository *localRepos;
 URI *localURI;
 char *localURIstr;
 const char *retVersion;
@@ -74,6 +76,7 @@
 Project *proj_arg;
 Branch *branch_arg;
 ServerStringArgument *string_arg;
+void *ent_arg;
 void *ser_arg;
 
 	quit_action.sa_handler = (&quitter);
@@ -91,8 +94,10 @@
 		exit(errno);
 	}
 /* try non-blocking I/O: */
+	/***
 val = fcntl(servfd, F_GETFL, 0);
 fcntl(servfd, F_SETFL, val | O_NONBLOCK);
+***/
 
 	bzero(&servaddr, sizeof(servaddr));
 	bzero(&cliaddr, sizeof(cliaddr));
@@ -111,14 +116,16 @@
 		exit(errno);
 	}
 
-	FD_ZERO(&fullset);
+	FD_ZERO(&readholder);
+	FD_ZERO(&writeholder);
 	FD_ZERO(&outgoingset);
-	FD_SET(servfd, &fullset);
+	FD_SET(servfd, &readholder);
 	max_sockfd_so_far = servfd;
 	max_index_into_clients = -1;
 	
 	while(!quit) {
-		incomingset = fullset;
+		incomingset = readholder;
+		outgoingset = writeholder;
 	
 		tv.tv_sec = 0;
 		tv.tv_usec = 500;
@@ -126,6 +133,8 @@
 		select_ready = select(max_sockfd_so_far + 1, &incomingset, &outgoingset, NULL, &tv);
 
 		if (select_ready > 0) {
+
+		        /* First check server's listening socket for connection requests: */
 			if (FD_ISSET(servfd, &incomingset)) {
 				printf ("*** servfd is ready.\n");
 				clientlen = sizeof(cliaddr);
@@ -147,28 +156,30 @@
 				} /* end if too many clients */
 
 				/* Add this new socket to the fd_set: */
-				FD_SET(client_socket, &fullset);
+				FD_SET(client_socket, &readholder);
 				if (client_socket > max_sockfd_so_far)
 				    max_sockfd_so_far = client_socket;
 
 				if (index > max_index_into_clients)
 				    max_index_into_clients = index;
 
-/*				select_ready--;   */
+				select_ready--;   
 
 			} /* end if FD_ISSET servfd  */   
 
 			/* After accepting a client's connect, check if there's still other pending events: */
 			if (select_ready > 0) {  
 			    for (i = 0; i <= max_index_into_clients; i++) {
-				if ( (sockfd = clients[i]) > 0) {
+				if ( (sockfd = clients[i]) >= 0) {
 				    if (FD_ISSET(sockfd, &incomingset)) {
 					if ( (readres = read(sockfd, &lmess, sizeof(lmess))) == 0) { 
 					    close(sockfd);
-					    FD_CLR(sockfd, &fullset);
+					    FD_CLR(sockfd, &readholder);
 					    clients[i] = -1;
 					} else {
-					    numread = read(clients[clidx], message, lmess);
+					    /* Allocate just enough space to read incoming message: */
+					    message = (char *)pcms_malloc(lmess);
+					    numread = read(sockfd, message, lmess);
 					    assert (numread > 0);
 
 					    /* Read the request: */
@@ -181,6 +192,10 @@
 					    /* Now add it to the queue: */
 					    AddToMsgQueue(readq, nextRequest);  
 					    stream_close(strm);
+
+					    if (--select_ready <= 0)
+						break;
+
 					} /* end if-else socket still active */
 
 				    } /* end if FD_ISSET on sockfd */
@@ -202,7 +217,7 @@
 				write (thisReply->sockfd, &len, sizeof(len));  
 				write (thisReply->sockfd, retVersion, len);
 				stream_close(reply_strm);
-				FD_CLR(thisReply->sockfd, &outgoingset);
+				FD_CLR(thisReply->sockfd, &writeholder);
 			    } /* end if FD_ISSET */
 
 			} /* end while not IsEmptyMsgQueue(writeq) */
@@ -224,13 +239,7 @@
 				/* Idea is that repos should be a file repository on this
 				*  server, so instantiate a FileRepos object for this command:
 				*/
-				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
-				strncpy(localURIstr, "file:",5);
-				strcat(localURIstr, nextRequest->repos_path);
-				localRepos = (Repository *)pcms_malloc(sizeof(Repository));
-				localRepos->uri = uri_create(localURIstr);
-				localRepos->auth = 0;
-				localRepos->info = 0;
+				open_local_repos_if_needed(nextRequest->repos_path);
 				
 				/* Now create a repository just like the File Repository: */
 				if (filerepository_CreateRepository(localRepos) == 0)
@@ -240,7 +249,7 @@
 
 				/* Add this reply to the write queue: */
 				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &outgoingset);
+				FD_SET(reply->sockfd, &writeholder);
 
 				break;
 
@@ -252,11 +261,8 @@
 				/* Idea is that repos should be a file repository on this
 				*  server, so instantiate a FileRepos object for this command:
 				*/
-				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
-				strncpy(localURIstr, "file:",5);
-				strcat(localURIstr, nextRequest->repos_path);
-				localRepos = repository_open(localURIstr, 0);
-				
+				open_local_repos_if_needed(nextRequest->repos_path);
+
 				/* Now use the local file repository to get the version
 				*  and write that back to the client via its socket:
 				*/
@@ -264,7 +270,7 @@
 
 				/* Add this reply to the write queue: */
 				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &outgoingset);
+				FD_SET(reply->sockfd, &writeholder);
 
 				break;
 
@@ -276,10 +282,7 @@
 				/* Idea is that repos should be a file repository on this
 				*  server, so instantiate a FileRepos object for this command:
 				*/
-				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
-				strncpy(localURIstr, "file:",5);
-				strcat(localURIstr, nextRequest->repos_path);
-				localRepos = repository_open(localURIstr, 0);
+				open_local_repos_if_needed(nextRequest->repos_path);
 				
 				/* This command requires a Project object and
 				   a Branch object as arguments.  */
@@ -300,7 +303,7 @@
 
 				/* Add this reply to the write queue: */
 				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &outgoingset);
+				FD_SET(reply->sockfd, &writeholder);
 
 				thisRequest = NULL;
 				break;
@@ -313,10 +316,7 @@
 				/* Idea is that repos should be a file repository on this
 				*  server, so instantiate a FileRepos object for this command:
 				*/
-				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
-				strncpy(localURIstr, "file:",5);
-				strcat(localURIstr, nextRequest->repos_path);
-				localRepos = repository_open(localURIstr, 0);
+				open_local_repos_if_needed(nextRequest->repos_path);
 				
 				/* This command requires a Project object as an argument.
 				*  Make sure the argument is available
@@ -337,7 +337,7 @@
 
 				/* Add this reply to the write queue: */
 				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &outgoingset);
+				FD_SET(reply->sockfd, &writeholder);
 
 				thisRequest = NULL;
 				break;
@@ -350,10 +350,7 @@
 				/* Idea is that repos should be a file repository on this
 				*  server, so instantiate a FileRepos object for this command:
 				*/
-				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
-				strncpy(localURIstr, "file:",5);
-				strcat(localURIstr, nextRequest->repos_path);
-				localRepos = repository_open(localURIstr, 0);
+				open_local_repos_if_needed(nextRequest->repos_path);
 				
 				/* This command requires a ServerStringArgument object as an argument.
 				*  Make sure the argument is available
@@ -377,7 +374,7 @@
 
 				/* Add this reply to the write queue: */
 				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &outgoingset);
+				FD_SET(reply->sockfd, &writeholder);
 
 				thisRequest = NULL;
 				break;
@@ -390,10 +387,7 @@
 				/* Idea is that repos should be a file repository on this
 				*  server, so instantiate a FileRepos object for this command:
 				*/
-				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
-				strncpy(localURIstr, "file:",5);
-				strcat(localURIstr, nextRequest->repos_path);
-				localRepos = repository_open(localURIstr, 0);
+				open_local_repos_if_needed(nextRequest->repos_path);
 				
 				/* This command requires a ServerStringArgument object as an argument.
 				*  Make sure the argument is available
@@ -423,7 +417,7 @@
 
 				/* Add this reply to the write queue: */
 				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &outgoingset);
+				FD_SET(reply->sockfd, &writeholder);
 
 				thisRequest = NULL;
 
@@ -437,10 +431,7 @@
 				/* Idea is that repos should be a file repository on this
 				*  server, so instantiate a FileRepos object for this command:
 				*/
-				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
-				strncpy(localURIstr, "file:",5);
-				strcat(localURIstr, nextRequest->repos_path);
-				localRepos = repository_open(localURIstr, 0);
+				open_local_repos_if_needed(nextRequest->repos_path);
 				
 				/* This command requires Project and Branch objects as arguments.
 				 * Make sure the arguments are available:
@@ -464,13 +455,50 @@
 
 				/* Add this reply to the write queue: */
 				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &outgoingset);
+				FD_SET(reply->sockfd, &writeholder);
 
 				thisRequest = NULL;
 
 				break;
 
 			    /**********************************************************
+			     *   RETURN AN ENTITY (IN SUPPORT OF UPDATE COMMAND):
+			     **********************************************************/
+			    case PCMS_OPCODE_GETENTITY:
+
+				/* Idea is that repos should be a file repository on this
+				*  server, so instantiate a FileRepos object for this command:
+				*/
+				open_local_repos_if_needed(nextRequest->repos_path);
+				
+				/* This command requires a ServerStringArgument object as an argument.
+				*  Make sure the argument is available
+				*/
+				if (vec_size(thisRequest->args) > 0) {
+				    /* The ServerStringArgument that's part of this request contains
+				     * the trueName of the entity that needs to be retrieved:
+				     */
+				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
+
+				    /* Now just do what the File Repository object would do: */
+				    ent_arg = filerepository_GetEntity(localRepos, string_arg->data);
+				    
+				    reply = reply_create("Success: Entity retrieved.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, ent_arg);
+
+				} else {
+				    reply = reply_create("Error retrieving Entity.\n", thisRequest->sockfd);
+				} /* end if checking if argument is present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &writeholder);
+
+				thisRequest = NULL;
+
+				break;
+
+			    /**********************************************************
 			     *   REVISE AN ENTITY (IN SUPPORT OF COMMIT COMMAND):
 			     **********************************************************/
 			    case PCMS_OPCODE_REVISEENTITY:
@@ -478,10 +506,7 @@
 				/* Idea is that repos should be a file repository on this
 				*  server, so instantiate a FileRepos object for this command:
 				*/
-				localURIstr = (char *)pcms_malloc(strlen(nextRequest->repos_path) + 5);
-				strncpy(localURIstr, "file:",5);
-				strcat(localURIstr, nextRequest->repos_path);
-				localRepos = repository_open(localURIstr, 0);
+				open_local_repos_if_needed(nextRequest->repos_path);
 				
 				/* This command requires a ServerStringArgument object as an argument.
 				*  Make sure the argument is available
@@ -501,19 +526,23 @@
 
 				/* Add this reply to the write queue: */
 				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &outgoingset);
+				FD_SET(reply->sockfd, &writeholder);
 
 				thisRequest = NULL;
 
 				break;
 
 			    case PCMS_OPCODE_PETGETPROJECT:
+				open_local_repos_if_needed(nextRequest->repos_path);
 				break;
 			    case PCMS_OPCODE_PETRENAMEPROJECT:
+				open_local_repos_if_needed(nextRequest->repos_path);
 				break;
 			    case PCMS_OPCODE_LISTPROJECTS:
+				open_local_repos_if_needed(nextRequest->repos_path);
 				break;
 			    case PCMS_OPCODE_LISTPROJPETNAMES:
+				open_local_repos_if_needed(nextRequest->repos_path);
 				break;
 			    default:
 				break;
@@ -533,4 +562,31 @@
 void quitter(int dummy) {
 	quit = 1;
 }
+
+/*
+ * Trying to reduce amount of work on the server-side:  only create/open
+ * a local file repository if the one we currently have is not the one
+ * the user needs.
+ */
+void open_local_repos_if_needed(char *path) {
+
+    char *localURIstr = (char *)pcms_malloc(strlen(path) + 5);
+
+    localURIstr = xstrndup("file:",5);
+    localURIstr = xstrcat(localURIstr, path);
+
+    /* First check if local repository already exists: */
+    if (localRepos == NULL) {
+	localRepos = (Repository *)pcms_malloc(sizeof(Repository));
+	localRepos = repository_open(localURIstr, 0);
+	storeReposURI = xstrdup(localURIstr);
+    /* If so, check if it points to one user wants: */
+    } else if (!nmequal(storeReposURI, localURIstr)) {
+	localRepos = (Repository *)pcms_malloc(sizeof(Repository));
+	localRepos = repository_open(localURIstr, 0);
+	storeReposURI = xstrdup(localURIstr);
+    } /* end if-then-else */
+
+} /* end open_local_repository */
+
 




From bastille@snocrash.cs.jhu.edu Wed Nov 14 18:02:50 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fAEN2ov27801
	for <dcms-cvs@eros.cs.jhu.edu>; Wed, 14 Nov 2001 18:02:50 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA00951;
	Wed, 14 Nov 2001 18:46:53 -0500
Received: (from bastille@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fAEMxsX01006;
	Wed, 14 Nov 2001 17:59:54 -0500
Date: Wed, 14 Nov 2001 17:59:54 -0500
From: Raphael Schweber-Koren <bastille@snocrash.cs.jhu.edu>
Message-Id: <200111142259.fAEMxsX01006@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/tests/basetree mergefile
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

bastille    01/11/14 17:59:54

  Modified:    tests    Makefile.in
  Added:       tests    13aMergeEqual.sh 13bMergeAllDiff.sh
                        13cMergeReposDiffer.sh 13dMergeWorkingDiffer.sh
                        13eMergeCommonDiffer.sh 14commitimmupdate.sh
                        mergecommon.sh mergefinish.sh
               tests/basetree mergefile
  Log:
  Merge Tests, and some infrastructure for some more.
  Files: Repository, Common Ancestor, Working Directory
  
  Merge Tests, and some infrastructure for some more.
  Files: Repository, Common Ancestor, Working Directory
  -Trivial case of all files are equal
  -All files are different
  -The Repository file differs
  -The Working Directory file differs
  -The Common Ancestor differs
  
  14commitimmupdate: try committing, and then immediately updating.
  This tests whether the files are being touched. (They shouldn't be).

Revision  Changes    Path
1.9       +7 -1      pcms/tests/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/Makefile.in,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Makefile.in	2001/11/12 17:28:19	1.8
+++ Makefile.in	2001/11/14 22:59:54	1.9
@@ -12,7 +12,13 @@
 	09import-checkout.sh \
 	10twomods.sh \
 	11entrename.sh \
-	12mvupdate.sh
+	12mvupdate.sh \
+	13aMergeEqual.sh \
+	13bMergeAllDiff.sh \
+	13cMergeReposDiffer.sh \
+	13dMergeWorkingDiffer.sh \
+	13eMergeCommonDiffer.sh \
+	14commitimmupdate.sh
 
 all:
 



1.1                  pcms/tests/13aMergeEqual.sh

Index: 13aMergeEqual.sh
===================================================================
#!/bin/sh

. testvars.sh
. repossel.sh

. mergecommon.sh

cd output

$PCMS --server ${REPOS} update

cd ${TEST_DIR}

if [ has_changed input/mergefile output/mergefile ]
then 
    echo "$0: FAIL"
    exit 1
fi

. mergefinish.sh

exit 0



1.1                  pcms/tests/13bMergeAllDiff.sh

Index: 13bMergeAllDiff.sh
===================================================================
#!/bin/sh

. testvars.sh
. repossel.sh

. mergecommon.sh

sed 's/line two/lin 2/' input/mergefile > tmp
mv tmp input/mergefile

cd input

$PCMS --server ${REPOS} commit -m 'Commit of Merge02 Test' --author "Test Agent"
status=$?

if [ ${status} != 0 ]
then
    echo "$0: FAIL"
    exit 1
fi

cd ${TEST_DIR}

sed 's/line two/lin 202/' output/mergefile > tmp
mv tmp output/mergefile

cd output
$PCMS --server ${REPOS} update

conflict=`grep '<<<<<<<' output/mergefile`

if [ -z "$conflict"] 
then
    echo "$0: FAIL"
    exit 1
fi

. mergefinish.sh

exit 0



1.1                  pcms/tests/13cMergeReposDiffer.sh

Index: 13cMergeReposDiffer.sh
===================================================================
#!/bin/sh

 . testvars.sh
 . repossel.sh
 
 . mergecommon.sh

sed 's/line two/linnne 2/' input/mergefile > tmpmrg
cp tmpmrg input/mergefile

cd input
$PCMS --server ${REPOS} commit -m 'Commit of Repository Change' --author "Test Agent"
status=$?

if [ ${status} != 0 ]
then
	echo "exited with status ${status}"
	exit 1
fi

cd ${TEST_DIR}

cd output
$PCMS --server ${REPOS} update

cd ${TEST_DIR}
conflicts=`diff -r tmpmrg output/mergefile`

echo ":$conflicts:"

if [ -n "$conflicts" ]
then
	echo "$0: FAIL"
	exit 1
fi

. mergefinish.sh

exit 0



1.1                  pcms/tests/13dMergeWorkingDiffer.sh

Index: 13dMergeWorkingDiffer.sh
===================================================================
#!/bin/bash

. testvars.sh
. repossel.sh

. mergecommon.sh

sed 's/line three/linnne 3three3/' output/mergefile > tmpmrg
cp tmpmrg output/mergefile

cd output
$PCMS --server ${REPOS} update
status=$?

if [ ${status} != 0 ]
then
	echo "$0: FAIL"
	exit 1
fi

cd ${TEST_DIR}

conflict=`diff -r tmpmrg output/mergefile`

if [ -n "$conflict" ]
then
	echo "$0: FAIL"
	exit 1
fi

. mergefinish.sh

exit 1



1.1                  pcms/tests/13eMergeCommonDiffer.sh

Index: 13eMergeCommonDiffer.sh
===================================================================
#!/bin/sh

. testvars.sh
. repossel.sh

. mergecommon.sh

sed 's/line four/linnnne 4four4/' input/mergefile > tmpmrg

cp tmpmrg input/mergefile
cd input
$PCMS --server ${REPOS} commit -m 'Commit of Identical Change, 13e' --author "Test Agent"
status=$?

if [ ${status} != 0 ]
then
	echo "$0: FAIL"
	exit 1
fi

cd ${TEST_DIR}
cp tmpmrg output/mergefile

cd output
$PCMS --server ${REPOS} update
status=$?

if [ ${status} != 0 ]
then
        echo "$0: FAIL"
        exit 1
fi

cd ${TEST_DIR}
changes = `diff -r tmpmrg output/mergefile`

if [ -n "$changes" ]
then
	echo "$0: FAIL"
	exit 1
fi

. mergefinish.sh

exit 0





1.1                  pcms/tests/14commitimmupdate.sh

Index: 14commitimmupdate.sh
===================================================================
#!/bin/sh

. testvars.sh
. repossel.sh

. mergecommon.sh

cd output
$PCMS --server ${REPOS} commit -m 'Initial checkin of the test project' --author "Test Agent"
status=$?

if [ ${status} != 0 ]
then
    echo "$0: FAIL"
    exit 1
fi

cp mergefile ../mrgstmp

echo "Sleeping 1 minute"
sleep 5

$PCMS --server ${REPOS} update

if [mergefile -nt ../mrgstmp ]
then
	echo "$0: FAIL"
	exit 1
fi

exit 0



1.1                  pcms/tests/mergecommon.sh

Index: mergecommon.sh
===================================================================
#!/bin/sh

$PCMS create repository --server ${REPOS} > /dev/null 2>&1
status=$?

if [ ${status} != 0 ]
then
    echo "$0: FAIL"
    exit 1
fi

cp -r basetree input

cd input;

$PCMS --server ${REPOS} import --name 'Test Merge Project' --nickname 'test' --author "Test Agent" -m 'This is a test projet'
status=$?

cd ${TEST_DIR}

if [ ${status} != 0 ]
then
	echo "$0: FAIL"
	exit 1
fi

changes=`diff -r basetree input | grep -v ': .pcms$'`

if [ -n "${changes}" ]
then
	echo "$0: FAIL"
	exit 1
fi

cd input

$PCMS --server ${REPOS} commit -m 'Initinitial checkin of the test project' --author "Test Agent"
status=$?

if [ ${status} != 0 ]
then
    echo "$0: FAIL"
    exit 1
fi

cd ${TEST_DIR}

mkdir output

cd output

$PCMS --server ${REPOS} checkout test:main
status=$?

if [ ${status} != 0 ]
then
    echo "$0: FAIL"
    exit 1
fi

cd ${TEST_DIR}

if has_changed input output
then
	echo "$0: FAIL"
	exit 1
fi





1.1                  pcms/tests/mergefinish.sh

Index: mergefinish.sh
===================================================================
#!/bin/sh

cd ${TEST_DIR}/output

$PCMS --server ${REPOS} commit -m 'Final Merge Commit Attempt' --author "Test Agent"
status=$?

if [ ${status} != 0 ]
then
	echo "$0: FAIL"
	exit 1
fi





1.1                  pcms/tests/basetree/mergefile

Index: mergefile
===================================================================
This is line one
This is line two
This is line three
This is line four
This is line five




From vandy@snocrash.cs.jhu.edu Wed Nov 14 18:27:34 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fAENRYv27894
	for <dcms-cvs@eros.cs.jhu.edu>; Wed, 14 Nov 2001 18:27:34 -0500
Received: from snocrash.cs.jhu.edu (IDENT:root@snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id TAA01007;
	Wed, 14 Nov 2001 19:11:37 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fAENObp01191;
	Wed, 14 Nov 2001 18:24:37 -0500
Date: Wed, 14 Nov 2001 18:24:37 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111142324.fAENObp01191@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server pcmsserver.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/14 18:24:37

  Modified:    src/common Change.c pcms_opcode.h
               src/repos/net NetRepository.c
               src/server pcmsserver.c
  Log:
  Yet more changes for server-side.  (The only constant is change...)

Revision  Changes    Path
1.4       +1 -1      pcms/src/common/Change.c

Index: Change.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/Change.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Change.c	2001/11/14 22:24:36	1.3
+++ Change.c	2001/11/14 23:24:37	1.4
@@ -57,7 +57,7 @@
   Change *chg = (Change *) pcms_malloc(sizeof(Change));
 
   chg->serType = &Change_SerType;
-  
+  chg->serTrueName = 0;
   chg->parent             = sdr_r_string("parent", strm);
   chg->mergeParent        = sdr_r_string("mergeParent", strm);
   chg->isPartialMerge     = sdr_r_ulong("isPartialMerge", strm);



1.5       +4 -4      pcms/src/common/pcms_opcode.h

Index: pcms_opcode.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/pcms_opcode.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- pcms_opcode.h	2001/11/14 22:24:36	1.4
+++ pcms_opcode.h	2001/11/14 23:24:37	1.5
@@ -5,12 +5,12 @@
 #define PCMS_OPCODE_CREATEPROJECT 501
 #define PCMS_OPCODE_GETPROJECT 502
 #define PCMS_OPCODE_PETGETPROJECT 503
-#define PCMS_OPCODE_PETRENAMEPROJECT 504
+#define PCMS_OPCODE_RENAMEPROJECT 504
 #define PCMS_OPCODE_LISTPROJECTS 505
 #define PCMS_OPCODE_LISTPROJPETNAMES 506
 #define PCMS_OPCODE_LISTBRANCHPETNAMES 507
 #define PCMS_OPCODE_CREATEBRANCH 508
-#define PCMS_OPCODE_PETRENAMEBRANCH 509
+#define PCMS_OPCODE_RENAMEBRANCH 509
 #define PCMS_OPCODE_GETBRANCH 510
 #define PCMS_OPCODE_PETGETBRANCH 511
 #define PCMS_OPCODE_REVISEBRANCH 512
@@ -27,12 +27,12 @@
 #define CREATEREPOSITORY "createRepos"
 #define GETPROJECT "getProject"
 #define PETGETPROJECT "getPetProject"
-#define PETRENAMEPROJECT "renamePetProject"
+#define RENAMEPROJECT "renameProject"
 #define LISTPROJECTS "listProjects"
 #define LISTPROJPETNAMES "listProjectPetNames"
 #define LISTBRANCHPETNAMES "listBranchPetNames"
 #define CREATEBRANCH "createBranch"
-#define PETRENAMEBRANCH "renamePetBranch"
+#define RENAMEBRANCH "renameBranch"
 #define GETBRANCH "getBranch"
 #define GETENTITY "getEntity"
 #define PETGETBRANCH "getPetBranch"



1.8       +169 -2    pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- NetRepository.c	2001/11/14 22:24:37	1.7
+++ NetRepository.c	2001/11/14 23:24:37	1.8
@@ -306,16 +306,131 @@
     return NULL;
 } /* end netrepository_GetProject */
 
+/*
+ * Return a Project object given the pet name as input.
+ * Return NULL if project not found.
+ */
 Project *
 netrepository_PetGetProject(Repository *r, const char *pName) {
     
+	SDR_stream* net_stream;
+	char *net_buf;
+	char *rawReply;
+	unsigned int incoming;
+	ServerStringArgument *ser_pName;
+	Project *retProj;
+	
+	ServerRequest *sr;
+	ServerReply *sreply;
+
+	/* Paranoia checks: */
+	if (r == NULL)
+	    return NULL;
+
+	if (r->uri->netloc == NULL)
+	    return NULL;
+
+	if (pName == NULL)
+	    return NULL;
+
+	net_stream = stream_openstring(STREAM_XML);
+
+	sr = request_create(PETGETPROJECT, r->uri->path, r->uri->username, PCMS_OPCODE_PETGETPROJECT);
+	ser_pName = serverarg_create(pName);
+
+	/* Now add the true name of the Project as an argument to this request: */
+	serverrequest_AddArgument(sr, ser_pName);
+
+	/* Now serialize the request into an XML stream: */
+	sdr_write (SERVERREQUEST, net_stream, sr);
+	
+	/* Convert XML stream to char* to send over wire: */
+	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
+
+	/* Now send the data over the socket: */
+	sendBuff(*(r->connfd), net_buf);
+
+	/* Wait for the response: */
+	read (*(r->connfd), &incoming, sizeof(incoming));
+
+	if (incoming > 0) {
+	    /* Allocate just enough space for server's reply: */
+	    rawReply = (char *)pcms_malloc(incoming);
+	    read(*(r->connfd), rawReply, incoming);
+
+	    /* Create SDR stream to allow easy deserialization of reply: */
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY, net_stream);
+
+	    /* We need the Project to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    retProj = (Project *)(vec_fetch(sreply->return_objs,0)); 
+	    return retProj;
+
+	} /* end if incoming > 0 */
+    
     return NULL;
 } /* end netrepository_PetGetProject */
 
+/*
+ * Rename a Project, given the Repository, current name, and new name
+ * as input:
+ */
   int 
 netrepository_PetRenameProject(Repository *r,
-				const char *oldName, const char *newName) {return 0;}
-  StrVec * 
+				const char *oldName, const char *newName) {
+    
+    SDR_stream* net_stream;
+    char *net_buf;
+    char *rawReply;
+    unsigned int incoming;
+    
+    ServerRequest *sr;
+    ServerReply *sreply;
+    ServerStringArgument *ser_oldName;
+    ServerStringArgument *ser_newName;
+
+    net_stream = stream_openstring(STREAM_XML);
+
+    sr = request_create(RENAMEPROJECT, r->uri->path, r->uri->username, PCMS_OPCODE_RENAMEPROJECT);
+    ser_oldName = serverarg_create(oldName);
+    ser_newName = serverarg_create(newName);
+
+    /* Now add the Project argument to this request: */
+    serverrequest_AddArgument(sr, ser_oldName);
+    serverrequest_AddArgument(sr, ser_newName);
+
+    /* Now serialize the request into an XML stream: */
+    sdr_write (SERVERREQUEST, net_stream, sr);
+    
+    /* Convert XML stream to char* to send over wire: */
+    net_buf = (char *)net_stream->data;
+    stream_close(net_stream);
+
+    /* Now send the data over the socket: */
+    sendBuff(*(r->connfd), net_buf);
+
+    /* Wait for the response: */
+    read (*(r->connfd), &incoming, sizeof(incoming));
+
+    if (incoming > 0) {
+	rawReply = (char *)pcms_malloc(incoming);
+	read(*(r->connfd), rawReply, incoming);
+	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	sreply = sdr_read(SERVERREPLY, net_stream);
+	
+	report(sreply->data);
+	return 1;
+    } else {
+	report("Invalid Server Reply.\n");
+	return -1;
+    } /* end if else */
+
+    return 0;
+} /* end netrepository_PetRenameProject */
+
+StrVec * 
 netrepository_ListProjects(Repository *r) {return NULL;}
 
   StrVec * 
@@ -381,11 +496,63 @@
 
 } /* end netrepository_CreateBranch */
 
+/*
+ * Rename a branch given the branch's Project, the branch's current
+ * name, and the branch's new name as parameters:
+ */
   int
 netrepository_PetRenameBranch(Repository *r,
 			       Project *p,
 			       const char *oldName,
 			       const char *newName) {
+    
+    SDR_stream* net_stream;
+    char *net_buf;
+    char *rawReply;
+    unsigned int incoming;
+    
+    ServerRequest *sr;
+    ServerReply *sreply;
+    ServerStringArgument *ser_oldName;
+    ServerStringArgument *ser_newName;
+
+    net_stream = stream_openstring(STREAM_XML);
+
+    sr = request_create(RENAMEBRANCH, r->uri->path, r->uri->username, PCMS_OPCODE_RENAMEBRANCH);
+    ser_oldName = serverarg_create(oldName);
+    ser_newName = serverarg_create(newName);
+
+    /* Now add the Project argument to this request: */
+    serverrequest_AddArgument(sr, p);
+    serverrequest_AddArgument(sr, ser_oldName);
+    serverrequest_AddArgument(sr, ser_newName);
+
+    /* Now serialize the request into an XML stream: */
+    sdr_write (SERVERREQUEST, net_stream, sr);
+    
+    /* Convert XML stream to char* to send over wire: */
+    net_buf = (char *)net_stream->data;
+    stream_close(net_stream);
+
+    /* Now send the data over the socket: */
+    sendBuff(*(r->connfd), net_buf);
+
+    /* Wait for the response: */
+    read (*(r->connfd), &incoming, sizeof(incoming));
+
+    if (incoming > 0) {
+	rawReply = (char *)pcms_malloc(incoming);
+	read(*(r->connfd), rawReply, incoming);
+	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	sreply = sdr_read(SERVERREPLY, net_stream);
+	
+	report(sreply->data);
+	return 1;
+    } else {
+	report("Invalid Server Reply.\n");
+	return -1;
+    } /* end if else */
+
     return 0;
 } /* end netrepository_PetRenameBranch */
 



1.8       +102 -3    pcms/src/server/pcmsserver.c

Index: pcmsserver.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/pcmsserver.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- pcmsserver.c	2001/11/14 22:24:37	1.7
+++ pcmsserver.c	2001/11/14 23:24:37	1.8
@@ -76,6 +76,7 @@
 Project *proj_arg;
 Branch *branch_arg;
 ServerStringArgument *string_arg;
+ServerStringArgument *string_arg2;
 void *ent_arg;
 void *ser_arg;
 
@@ -136,10 +137,9 @@
 
 		        /* First check server's listening socket for connection requests: */
 			if (FD_ISSET(servfd, &incomingset)) {
-				printf ("*** servfd is ready.\n");
 				clientlen = sizeof(cliaddr);
 				client_socket = accept(servfd, (struct sockaddr *) &cliaddr, &clientlen);
-				fprintf(stderr, "Got Connection From %s\n", inet_ntoa(cliaddr.sin_addr));
+				fprintf(stderr, "Processing request from %s\n", inet_ntoa(cliaddr.sin_addr)); 
 
 				/* Save the client socket file descriptor in an "active" list: */
 				for (index = 0; index < MAX_CLIENTS; index++) {
@@ -532,12 +532,111 @@
 
 				break;
 
+			    /**********************************************************
+			     *   GET A PROJECT BASED ON PET NAME PASSED AS PARAMETER:
+			     **********************************************************/
 			    case PCMS_OPCODE_PETGETPROJECT:
+
 				open_local_repos_if_needed(nextRequest->repos_path);
+				
+				/* This command requires a ServerStringArgument object as an argument.
+				*  Make sure the argument is available
+				*/
+				if (vec_size(thisRequest->args) > 0) {
+				    /* The ServerStringArgument that's part of this request contains
+				     * the pet name of the project that needs to be retrieved:
+				     */
+				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
+
+				    /* Now just do what the File Repository object would do: */
+				    proj_arg = filerepository_PetGetProject(localRepos, string_arg->data);
+
+				    reply = reply_create("Success: Project retrieved.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, proj_arg);
+
+				} else {
+				    reply = reply_create("Error retrieving Project.\n", thisRequest->sockfd);
+				} /* end if checking if argument is present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &writeholder);
+
+				thisRequest = NULL;
+
+				break;
+				
+			    /**********************************************************************
+			     * RENAME A BRANCH:  NEEDS PROJECT, CURRENT NAME, NEW NAME AS ARGUMENTS:
+			     *********************************************************************/
+			    case PCMS_OPCODE_RENAMEBRANCH:
+
+				open_local_repos_if_needed(nextRequest->repos_path);
+
+				/* This command requires several objects as arguments. */
+				if (vec_size(thisRequest->args) > 0) {
+				    
+				    /* First is the Project of interest: */
+				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
+
+				    /* Second is the old name of the branch: */
+				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
+
+				    /* Second is the new name of the branch: */
+				    string_arg2 = (ServerStringArgument *)(vec_fetch(thisRequest->args, 2));
+
+				    /* Now just do what the File Repository object would do: */
+				    if (filerepository_PetRenameBranch (localRepos, proj_arg, string_arg->data, string_arg2->data) == -1)
+					reply = reply_create("Error renaming branch.\n", thisRequest->sockfd);
+				    else
+					reply = reply_create("Success: Branch renamed.\n", thisRequest->sockfd);
+
+				} else {
+				    reply = reply_create("Error renaming branch (Not enough arguments).\n", thisRequest->sockfd);
+				} /* end if checking if argument is present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &writeholder);
+
+				thisRequest = NULL;
+
 				break;
-			    case PCMS_OPCODE_PETRENAMEPROJECT:
+
+			    /**********************************************************************
+			     * RENAME A PROJECT:  NEEDS CURRENT NAME, NEW NAME AS ARGUMENTS:
+			     *********************************************************************/
+			    case PCMS_OPCODE_RENAMEPROJECT:
+
 				open_local_repos_if_needed(nextRequest->repos_path);
+
+				/* This command requires several objects as arguments. */
+				if (vec_size(thisRequest->args) > 0) {
+				    
+				    /* First is the old name of the project: */
+				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
+
+				    /* Second is the new name of the project: */
+				    string_arg2 = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
+
+				    /* Now just do what the File Repository object would do: */
+				    if (filerepository_PetRenameProject (localRepos, string_arg->data, string_arg2->data) == -1)
+					reply = reply_create("Error renaming Project:(name already exists).\n", thisRequest->sockfd);
+				    else
+					reply = reply_create("Success: Project renamed.\n", thisRequest->sockfd);
+
+				} else {
+				    reply = reply_create("Error renaming Project:(not enough arguments).\n", thisRequest->sockfd);
+				} /* end if checking if argument is present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &writeholder);
+
+				thisRequest = NULL;
+
 				break;
+
 			    case PCMS_OPCODE_LISTPROJECTS:
 				open_local_repos_if_needed(nextRequest->repos_path);
 				break;




From bastille@snocrash.cs.jhu.edu Thu Nov 15 17:55:28 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fAFMtSv27444
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 15 Nov 2001 17:55:28 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA00890;
	Thu, 15 Nov 2001 18:39:24 -0500
Received: (from bastille@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fAFMqLI09466;
	Thu, 15 Nov 2001 17:52:21 -0500
Date: Thu, 15 Nov 2001 17:52:21 -0500
From: Raphael Schweber-Koren <bastille@snocrash.cs.jhu.edu>
Message-Id: <200111152252.fAFMqLI09466@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/tests 13aMergeEqual.sh 13bMergeAllDiff.sh 13dMergeWorkingDiffer.sh 13eMergeCommonDiffer.sh 14commitimmupdate.sh Makefile.in runtest.sh
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

bastille    01/11/15 17:52:21

  Modified:    tests    13aMergeEqual.sh 13bMergeAllDiff.sh
                        13dMergeWorkingDiffer.sh 13eMergeCommonDiffer.sh
                        14commitimmupdate.sh Makefile.in runtest.sh
  Log:
  Various bugfixes to the mergetests and support for full verbose output from the makefile (for both the file and net suite).

Revision  Changes    Path
1.2       +1 -1      pcms/tests/13aMergeEqual.sh

Index: 13aMergeEqual.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/13aMergeEqual.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 13aMergeEqual.sh	2001/11/14 22:59:54	1.1
+++ 13aMergeEqual.sh	2001/11/15 22:52:20	1.2
@@ -11,7 +11,7 @@
 
 cd ${TEST_DIR}
 
-if [ has_changed input/mergefile output/mergefile ]
+if has_changed input/mergefile output/mergefile
 then 
     echo "$0: FAIL"
     exit 1



1.2       +3 -1      pcms/tests/13bMergeAllDiff.sh

Index: 13bMergeAllDiff.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/13bMergeAllDiff.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 13bMergeAllDiff.sh	2001/11/14 22:59:54	1.1
+++ 13bMergeAllDiff.sh	2001/11/15 22:52:20	1.2
@@ -27,9 +27,11 @@
 cd output
 $PCMS --server ${REPOS} update
 
+cd ${TEST_DIR}
+
 conflict=`grep '<<<<<<<' output/mergefile`
 
-if [ -z "$conflict"] 
+if [ -z "$conflict" ] 
 then
     echo "$0: FAIL"
     exit 1



1.2       +1 -1      pcms/tests/13dMergeWorkingDiffer.sh

Index: 13dMergeWorkingDiffer.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/13dMergeWorkingDiffer.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 13dMergeWorkingDiffer.sh	2001/11/14 22:59:54	1.1
+++ 13dMergeWorkingDiffer.sh	2001/11/15 22:52:20	1.2
@@ -30,4 +30,4 @@
 
 . mergefinish.sh
 
-exit 1
+exit 0



1.2       +1 -1      pcms/tests/13eMergeCommonDiffer.sh

Index: 13eMergeCommonDiffer.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/13eMergeCommonDiffer.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 13eMergeCommonDiffer.sh	2001/11/14 22:59:54	1.1
+++ 13eMergeCommonDiffer.sh	2001/11/15 22:52:20	1.2
@@ -32,7 +32,7 @@
 fi
 
 cd ${TEST_DIR}
-changes = `diff -r tmpmrg output/mergefile`
+changes=`diff -r tmpmrg output/mergefile`
 
 if [ -n "$changes" ]
 then



1.2       +5 -1      pcms/tests/14commitimmupdate.sh

Index: 14commitimmupdate.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/14commitimmupdate.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 14commitimmupdate.sh	2001/11/14 22:59:54	1.1
+++ 14commitimmupdate.sh	2001/11/15 22:52:20	1.2
@@ -22,10 +22,14 @@
 
 $PCMS --server ${REPOS} update
 
-if [mergefile -nt ../mrgstmp ]
+if [ mergefile -nt ../mrgstmp ]
 then
 	echo "$0: FAIL"
 	exit 1
 fi
+
+cd ${TEST_DIR}
+
+. mergefinish.sh
 
 exit 0



1.10      +14 -7     pcms/tests/Makefile.in

Index: Makefile.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/Makefile.in,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Makefile.in	2001/11/14 22:59:54	1.9
+++ Makefile.in	2001/11/15 22:52:20	1.10
@@ -3,7 +3,6 @@
 TESTS=\
 	01check_scripts.sh \
 	02cre_repos01.sh \
-	03cre_repos02.sh \
 	04import.sh \
 	05import-commit.sh \
 	06modify.sh \
@@ -23,23 +22,31 @@
 all:
 
 clean:
-	-rm -rf repos input output pcmstest.dbg *~
+	-rm -rf repos input output *~ netrepos
 
 test:
-	rm -f pcmstest.dbg
-	touch pcmstest.dbg
 	@for test in $(TESTS); do \
 	  ./runtest.sh $$test || exit 1; \
 	done
 
 nettest:
-	rm -f pcmstest.dbg
-	touch pcmstest.dbg
-	${PCMSSERVER} &
+	$(PCMSSERVER) &
 	@for test in $(TESTS); do \
 		./runtest.sh -n $$test || exit 1; \
 	done
 	killall pcmsserver -s INT
+
+vtest:
+	@for test in $(TESTS); do \
+	  ./runtest.sh -v $$test || exit 1; \
+	done
+
+netvtest:
+	${PCMSSERVER} &
+	@for test in $(TESTS); do \
+	  ./runtest.sh -vn $$test || exit 1; \
+	done
+
 
 distclean: clean
 	-rm -f Makefile



1.7       +5 -7      pcms/tests/runtest.sh

Index: runtest.sh
===================================================================
RCS file: /users/bigdisk/cvs/pcms/tests/runtest.sh,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- runtest.sh	2001/11/12 17:28:19	1.6
+++ runtest.sh	2001/11/15 22:52:20	1.7
@@ -21,7 +21,7 @@
     case "$1" in
 	-x) sh_args="${sh_args} -x"; shift;;
 	-m) memdbg_opt=1; shift;;
-	-v) sh_args="${sh_args} -x"; verbose_opt=1; shift;;
+	-v) sh_args="${sh_args}"; verbose_opt=1; shift;;
 	-q) quiet_opt=1; shift;;
 	-n) net_opt="-n"; shift;;
 	--) shift; break;;
@@ -36,23 +36,21 @@
     NJAMD_CHK_FREE=segv export NJAMD_CHK_FREE
 fi
 
-make clean > /dev/null 2>&1
-
 for test in $*
 do
-    echo "/bin/sh ${sh_args} ${test} ${net_opt}"
+	make clean > /dev/null 2>&1
+
+    testcalled="/bin/sh ${sh_args} ${test} ${net_opt}"
     output=`/bin/sh ${sh_args} ${test} ${net_opt}  2>&1`
     status=$?
 
-    echo "$output" >> pcmstest.dbg
-
     if [ ${status} = 0 ]
     then
+	echo PASS: "$test"
 	if [ ${verbose_opt} != 0 ]
 	then
 	    echo "$output" | sed 's/^/  /'
 	fi
-	echo PASS: "$test"
     elif [ ${status} = 1 ]
     then
 	echo FAIL: "$test"




From vandy@snocrash.cs.jhu.edu Thu Nov 15 18:17:09 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fAFNH9v27546
	for <dcms-cvs@eros.cs.jhu.edu>; Thu, 15 Nov 2001 18:17:09 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id TAA00952;
	Thu, 15 Nov 2001 19:01:05 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fAFNE6E09623;
	Thu, 15 Nov 2001 18:14:06 -0500
Date: Thu, 15 Nov 2001 18:14:06 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111152314.fAFNE6E09623@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server pcmsserver.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/15 18:14:06

  Modified:    src/client pcms.c
               src/repos/net NetRepository.c
               src/server pcmsserver.c
  Log:
  More server-side changes:
   -  using cached file repos on server side (thanks Raphael!)
   -  can now import, commit, checkout, diff, status via client-server

Revision  Changes    Path
1.5       +0 -1      pcms/src/client/pcms.c

Index: pcms.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/pcms.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- pcms.c	2001/11/13 16:59:04	1.4
+++ pcms.c	2001/11/15 23:14:05	1.5
@@ -407,7 +407,6 @@
   
   ws_RewriteWorkspace();
 
-  xprintf("ALERT: checkout not fully implemented!\n");
 }
 
 void



1.9       +121 -13   pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- NetRepository.c	2001/11/14 23:24:37	1.8
+++ NetRepository.c	2001/11/15 23:14:05	1.9
@@ -17,6 +17,8 @@
 /**  OLD:   inline void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen); */
 inline void sendBuff(int connectfd, const void* messagebuf);
 
+char * read_entire_msg_from_socket(int, unsigned int);
+
 int netrepository_CreateRepository(Repository *r) {
 	SDR_stream* net_stream;
 	char *net_buf;
@@ -45,7 +47,9 @@
 
 	if (incoming > 0) {
 	    rawReply = (char *)pcms_malloc(incoming);
-	    read(*(r->connfd), rawReply, incoming);
+
+	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
+
 	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
 	    sreply = sdr_read(SERVERREPLY, net_stream);
 	    report (sreply->data);
@@ -173,7 +177,7 @@
 	if (incoming > 0) {   
 	    /* Allocate just enough space for server's reply: */
 	    rawReply = (char *)pcms_malloc(incoming);
-	    read(*(r->connfd), rawReply, incoming);
+	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 
 	    /* Create SDR stream to allow easy deserialization of reply: */
 	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
@@ -221,7 +225,7 @@
 
 	if (incoming > 0) {
 	    rawReply = (char *)pcms_malloc(incoming);
-	    read(*(r->connfd), rawReply, incoming);
+	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
 	    sreply = sdr_read(SERVERREPLY, net_stream);
 
@@ -290,7 +294,7 @@
 	if (incoming > 0) {
 	    /* Allocate just enough space for server's reply: */
 	    rawReply = (char *)pcms_malloc(incoming);
-	    read(*(r->connfd), rawReply, incoming);
+	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 
 	    /* Create SDR stream to allow easy deserialization of reply: */
 	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
@@ -357,7 +361,7 @@
 	if (incoming > 0) {
 	    /* Allocate just enough space for server's reply: */
 	    rawReply = (char *)pcms_malloc(incoming);
-	    read(*(r->connfd), rawReply, incoming);
+	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 
 	    /* Create SDR stream to allow easy deserialization of reply: */
 	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
@@ -416,7 +420,7 @@
 
     if (incoming > 0) {
 	rawReply = (char *)pcms_malloc(incoming);
-	read(*(r->connfd), rawReply, incoming);
+	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
 	sreply = sdr_read(SERVERREPLY, net_stream);
 	
@@ -478,7 +482,7 @@
 
     if (incoming > 0) {
 	rawReply = (char *)pcms_malloc(incoming);
-	read(*(r->connfd), rawReply, incoming);
+	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
 	sreply = sdr_read(SERVERREPLY, net_stream);
 	
@@ -542,7 +546,7 @@
 
     if (incoming > 0) {
 	rawReply = (char *)pcms_malloc(incoming);
-	read(*(r->connfd), rawReply, incoming);
+	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
 	sreply = sdr_read(SERVERREPLY, net_stream);
 	
@@ -616,7 +620,7 @@
 	if (incoming > 0) {
 	    /* Allocate just enough space for server's reply: */
 	    rawReply = (char *)pcms_malloc(incoming);
-	    read(*(r->connfd), rawReply, incoming);
+	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 
 	    /* Create SDR stream to allow easy deserialization of reply: */
 	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
@@ -631,9 +635,77 @@
     return NULL;
 } /* end netrepository_GetBranch */
 
+/*
+ * Return a Branch object, given its pet name and its Project as input parameters:
+ */
   Branch *
-netrepository_PetGetBranch(Repository *r, Project *p, const char *bName) {return NULL;}
+netrepository_PetGetBranch(Repository *r, Project *p, const char *bName) {
+    
+	SDR_stream* net_stream;
+	char *net_buf;
+	char *rawReply;
+	unsigned int incoming;
+	ServerStringArgument *ser_bName;
+	Branch *retBranch;
+	
+	ServerRequest *sr;
+	ServerReply *sreply;
+
+	/* Paranoia checks: */
+	if (r == NULL)
+	    return NULL;
+
+	if (r->uri->netloc == NULL)
+	    return NULL;
+
+	if (bName == NULL)
+	    return NULL;
+
+	if (p == NULL)
+	    return NULL;
+
+	net_stream = stream_openstring(STREAM_XML);
+
+	sr = request_create(PETGETBRANCH, r->uri->path, r->uri->username, PCMS_OPCODE_PETGETBRANCH);
+	ser_bName = serverarg_create(bName);
+
+	/* Now add the Project and branch pet name as arguments to this request: */
+	serverrequest_AddArgument(sr, p);
+	serverrequest_AddArgument(sr, ser_bName);
+
+	/* Now serialize the request into an XML stream: */
+	sdr_write (SERVERREQUEST, net_stream, sr);
+	
+	/* Convert XML stream to char* to send over wire: */
+	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
+
+	/* Now send the data over the socket: */
+	sendBuff(*(r->connfd), net_buf);
+
+	/* Wait for the response: */
+	read (*(r->connfd), &incoming, sizeof(incoming));
+
+	if (incoming > 0) {
+	    /* Allocate just enough space for server's reply: */
+	    rawReply = (char *)pcms_malloc(incoming);
+	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
+
+	    /* Create SDR stream to allow easy deserialization of reply: */
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY, net_stream);
 
+	    /* We need the Branch to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    retBranch = (Branch *)(vec_fetch(sreply->return_objs,0)); 
+	    return retBranch;
+
+	} /* end if incoming > 0 */
+    
+    return NULL;
+
+} /* end netrepository_PetGetBranch
+
 /*
  * Update the Branch object in support of a Commit operation.  The
  * appropriate Repository and Project objects are passed as input, along
@@ -692,7 +764,7 @@
 	if (incoming > 0) {
 	    /* Allocate just enough space for server's reply: */
 	    rawReply = (char *)pcms_malloc(incoming);
-	    read(*(r->connfd), rawReply, incoming);
+	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 
 	    /* Create SDR stream to allow easy deserialization of reply: */
 	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
@@ -757,7 +829,7 @@
 
 	    /* Allocate just enough space for server's reply: */
 	    rawReply = (char *)pcms_malloc(incoming);
-	    read(*(r->connfd), rawReply, incoming);
+	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 
 	    /* Create SDR stream to allow easy deserialization of reply: */
 	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
@@ -825,7 +897,7 @@
 	if (incoming > 0) {
 	    /* Allocate just enough space for server's reply: */
 	    rawReply = (char *)pcms_malloc(incoming);
-	    read(*(r->connfd), rawReply, incoming);
+	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 
 	    /* Create SDR stream to allow easy deserialization of reply: */
 	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
@@ -888,3 +960,39 @@
   r->connfd = NULL;
 
 }
+
+/*
+ * Purpose of this function is when the socket read buffer is
+ * full, but the entire message hasn't been read, we need to
+ * execute multiple read's. 
+ */
+char * read_entire_msg_from_socket(int socket, unsigned int expected) {
+
+    char *entire_msg = (char *)pcms_malloc(expected);
+    unsigned int numread = read(socket, entire_msg, expected);
+
+    if (numread < expected) {
+
+	unsigned int tindex = 0;
+	char *tmp_message = (char *)pcms_malloc(expected);
+	tmp_message = xstrdup(entire_msg);
+
+	/* Make sure we read entire message: */
+	while (numread < expected) {
+	    tindex = read(socket, entire_msg, expected);
+	    numread = numread + tindex;
+	    entire_msg[tindex] = '\0';
+	    tmp_message = xstrcat(tmp_message, entire_msg);
+	} /* end while numread < lmess */
+
+	/* Store the final (complete) message back in the
+	 * "entire message" variable:
+	 */
+	entire_msg = xstrdup(tmp_message);
+    
+    } /* end if numread < expected */
+
+    return entire_msg;
+
+} /* end read_entire_msg_from_socket */
+



1.9       +75 -16    pcms/src/server/pcmsserver.c

Index: pcmsserver.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/pcmsserver.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- pcmsserver.c	2001/11/14 23:24:37	1.8
+++ pcmsserver.c	2001/11/15 23:14:06	1.9
@@ -46,13 +46,13 @@
 	int index;
 	int select_ready;
 	char *message;
-	int lmess, trmess;
+	unsigned int lmess;
 	int i, readres,clientlen;
 	struct sigaction quit_action;
 	struct timeval tv;
 	
 int val;
-int numread;
+unsigned int numread;
 ServerRequest *nextRequest;
 ServerRequest *thisRequest;
 ServerReply *thisReply;
@@ -180,8 +180,31 @@
 					    /* Allocate just enough space to read incoming message: */
 					    message = (char *)pcms_malloc(lmess);
 					    numread = read(sockfd, message, lmess);
-					    assert (numread > 0);
 
+					    /* If we didn't read the entire socket stream the first time,
+					     * keep reading until we have the entire message.  
+					     */
+					    if (numread < lmess) {
+
+						unsigned int tindex = 0;
+						char *tmp_message = (char *)pcms_malloc(lmess);
+						tmp_message = xstrdup(message);
+
+						/* Make sure we read entire message: */
+						while (numread < lmess) {
+						    tindex = read(sockfd, message, lmess);
+						    numread = numread + tindex;
+						    message[tindex] = '\0';
+						    tmp_message = xstrcat(tmp_message, message);
+						} /* end while numread < lmess */
+
+						/* Store the final (complete) message back in the
+						 * "message" variable:
+						 */
+						message = xstrdup(tmp_message);
+					    
+					    } /* end if numread < lmess */
+
 					    /* Read the request: */
 					    strm = stream_fromstring(STREAM_XML, message, strlen(message));
 					    nextRequest = sdr_read(SERVERREQUEST, strm);
@@ -242,7 +265,7 @@
 				open_local_repos_if_needed(nextRequest->repos_path);
 				
 				/* Now create a repository just like the File Repository: */
-				if (filerepository_CreateRepository(localRepos) == 0)
+				if (localRepos->CreateRepository(localRepos) == 0)
 				    reply = reply_create("Success.\n", thisRequest->sockfd);
 				else
 				    reply = reply_create("Error.\n", thisRequest->sockfd);
@@ -266,7 +289,7 @@
 				/* Now use the local file repository to get the version
 				*  and write that back to the client via its socket:
 				*/
-				reply = reply_create(filerepository_GetVersion(localRepos), thisRequest->sockfd);
+				reply = reply_create(localRepos->GetVersion(localRepos), thisRequest->sockfd);
 
 				/* Add this reply to the write queue: */
 				AddToMsgQueue(writeq, reply);
@@ -292,7 +315,7 @@
 				    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 1));
 
 				    /* Now just do what the File Repository object would do: */
-				    filerepository_CreateBranch(localRepos, proj_arg, branch_arg);
+				    localRepos->CreateBranch(localRepos, proj_arg, branch_arg);
 
 				    reply = reply_create("Success: Branch Created.\n", thisRequest->sockfd);
 				    serverreply_AddArgument(reply, branch_arg);
@@ -325,7 +348,7 @@
 				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
 
 				    /* Now just do what the File Repository object would do: */
-				    filerepository_CreateProject(localRepos, proj_arg);
+				    localRepos->CreateProject(localRepos, proj_arg);
 
 				    reply = reply_create("Success: Project created.\n", thisRequest->sockfd);
 				    serverreply_AddArgument(reply, proj_arg);
@@ -362,7 +385,7 @@
 				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
 
 				    /* Now just do what the File Repository object would do: */
-				    proj_arg = filerepository_GetProject(localRepos, string_arg->data);
+				    proj_arg = localRepos->GetProject(localRepos, string_arg->data);
 
 				    reply = reply_create("Success: Project retrieved.\n", thisRequest->sockfd);
 				    serverreply_AddArgument(reply, proj_arg);
@@ -405,7 +428,7 @@
 				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
 
 				    /* Now just do what the File Repository object would do: */
-				    branch_arg = filerepository_GetBranch(localRepos, proj_arg, string_arg->data);
+				    branch_arg = localRepos->GetBranch(localRepos, proj_arg, string_arg->data);
 
 				    reply = reply_create("Success: Branch retrieved.\n", thisRequest->sockfd);
 				    serverreply_AddArgument(reply, branch_arg);
@@ -445,7 +468,7 @@
 				    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 1));
 
 				    /* Now just do what the File Repository object would do: */
-				    filerepository_ReviseBranch(localRepos, proj_arg, branch_arg);
+				    localRepos->ReviseBranch(localRepos, proj_arg, branch_arg);
 
 				    reply = reply_create("Success: Branch updated.\n", thisRequest->sockfd);
 
@@ -481,7 +504,7 @@
 				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
 
 				    /* Now just do what the File Repository object would do: */
-				    ent_arg = filerepository_GetEntity(localRepos, string_arg->data);
+				    ent_arg = localRepos->GetEntity(localRepos, string_arg->data);
 				    
 				    reply = reply_create("Success: Entity retrieved.\n", thisRequest->sockfd);
 				    serverreply_AddArgument(reply, ent_arg);
@@ -518,7 +541,7 @@
 				    ser_arg = (void *)(vec_fetch(thisRequest->args, 0));
 
 				    /* Now just do what the File Repository object would do: */
-				    reply = reply_create(filerepository_ReviseEntity(localRepos, 0, ser_arg), thisRequest->sockfd);
+				    reply = reply_create(localRepos->ReviseEntity(localRepos, 0, ser_arg), thisRequest->sockfd);
 
 				} else {
 				    reply = reply_create("Error revising Entity.\n", thisRequest->sockfd);
@@ -533,6 +556,40 @@
 				break;
 
 			    /**********************************************************
+			     *   GET A BRANCH BASED ON PET NAME PASSED AS PARAMETER:
+			     **********************************************************/
+			    case PCMS_OPCODE_PETGETBRANCH:
+
+				open_local_repos_if_needed(nextRequest->repos_path);
+				
+				/* This command requires two arguments: */
+				if (vec_size(thisRequest->args) > 0) {
+
+				    /* The ServerStringArgument that's part of this request contains
+				     * the pet name of the project that needs to be retrieved:
+				     */
+				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
+				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
+
+				    /* Now just do what the File Repository object would do: */
+				    branch_arg = localRepos->PetGetBranch(localRepos, proj_arg, string_arg->data);
+
+				    reply = reply_create("Success: Branch retrieved.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, branch_arg);
+
+				} else {
+				    reply = reply_create("Error retrieving Branch:(not enough arguments)\n", thisRequest->sockfd);
+				} /* end if checking if argument is present */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &writeholder);
+
+				thisRequest = NULL;
+
+				break;
+
+			    /**********************************************************
 			     *   GET A PROJECT BASED ON PET NAME PASSED AS PARAMETER:
 			     **********************************************************/
 			    case PCMS_OPCODE_PETGETPROJECT:
@@ -549,7 +606,7 @@
 				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
 
 				    /* Now just do what the File Repository object would do: */
-				    proj_arg = filerepository_PetGetProject(localRepos, string_arg->data);
+				    proj_arg = localRepos->PetGetProject(localRepos, string_arg->data);
 
 				    reply = reply_create("Success: Project retrieved.\n", thisRequest->sockfd);
 				    serverreply_AddArgument(reply, proj_arg);
@@ -586,7 +643,7 @@
 				    string_arg2 = (ServerStringArgument *)(vec_fetch(thisRequest->args, 2));
 
 				    /* Now just do what the File Repository object would do: */
-				    if (filerepository_PetRenameBranch (localRepos, proj_arg, string_arg->data, string_arg2->data) == -1)
+				    if (localRepos->PetRenameBranch (localRepos, proj_arg, string_arg->data, string_arg2->data) == -1)
 					reply = reply_create("Error renaming branch.\n", thisRequest->sockfd);
 				    else
 					reply = reply_create("Success: Branch renamed.\n", thisRequest->sockfd);
@@ -620,7 +677,7 @@
 				    string_arg2 = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
 
 				    /* Now just do what the File Repository object would do: */
-				    if (filerepository_PetRenameProject (localRepos, string_arg->data, string_arg2->data) == -1)
+				    if (localRepos->PetRenameProject (localRepos, string_arg->data, string_arg2->data) == -1)
 					reply = reply_create("Error renaming Project:(name already exists).\n", thisRequest->sockfd);
 				    else
 					reply = reply_create("Success: Project renamed.\n", thisRequest->sockfd);
@@ -665,7 +722,7 @@
 /*
  * Trying to reduce amount of work on the server-side:  only create/open
  * a local file repository if the one we currently have is not the one
- * the user needs.
+ * the user needs. (We're using a cached file repository for efficiency.)
  */
 void open_local_repos_if_needed(char *path) {
 
@@ -678,11 +735,13 @@
     if (localRepos == NULL) {
 	localRepos = (Repository *)pcms_malloc(sizeof(Repository));
 	localRepos = repository_open(localURIstr, 0);
+	cachedfilerepository_init(localRepos);
 	storeReposURI = xstrdup(localURIstr);
     /* If so, check if it points to one user wants: */
     } else if (!nmequal(storeReposURI, localURIstr)) {
 	localRepos = (Repository *)pcms_malloc(sizeof(Repository));
 	localRepos = repository_open(localURIstr, 0);
+	cachedfilerepository_init(localRepos);
 	storeReposURI = xstrdup(localURIstr);
     } /* end if-then-else */
 




From vandy@snocrash.cs.jhu.edu Fri Nov 16 13:05:20 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fAGI5Kv13574
	for <dcms-cvs@eros.cs.jhu.edu>; Fri, 16 Nov 2001 13:05:20 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id NAA00799;
	Fri, 16 Nov 2001 13:49:09 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fAGI23215446;
	Fri, 16 Nov 2001 13:02:03 -0500
Date: Fri, 16 Nov 2001 13:02:03 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111161802.fAGI23215446@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server pcmsserver.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/16 13:02:02

  Modified:    src/client pcms.c
               src/common pcms_opcode.h
               src/repos/common Repository.h
               src/repos/fs CachedFileRepos.c FileRepos.c FileRepos.h
               src/repos/net NetRepository.c NetRepository.h
               src/server pcmsserver.c
  Log:
  More server-side changes

Revision  Changes    Path
1.6       +3 -3      pcms/src/client/pcms.c

Index: pcms.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/pcms.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- pcms.c	2001/11/15 23:14:05	1.5
+++ pcms.c	2001/11/16 18:02:02	1.6
@@ -330,7 +330,7 @@
     p = repos_GetProject(r, vec_fetch(sv, u));
 
     petNames = repos_ListProjPetNames(r, p);
-    xprintf("%s %s [", p->serTrueName, p->nickname);
+    xprintf("%s %s [", p->serTrueName, p->name);
 
     for (pn = 0; pn < vec_size(petNames); pn++) {
       if (pn)
@@ -362,8 +362,8 @@
     unsigned pn;
     Branch *b = repos_GetBranch(r, p, vec_fetch(sv, u));
 
-    petNames = repos_ListBranchPetNames(r, b);
-    xprintf("%s %s [", b->serTrueName, b->nickname);
+    petNames = repos_ListBranchPetNames(r, b, p->serTrueName);
+    xprintf("%s %s [", b->serTrueName, b->name);
 
     for (pn = 0; pn < vec_size(petNames); pn++) {
       if (pn)



1.6       +1 -0      pcms/src/common/pcms_opcode.h

Index: pcms_opcode.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/pcms_opcode.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- pcms_opcode.h	2001/11/14 23:24:37	1.5
+++ pcms_opcode.h	2001/11/16 18:02:02	1.6
@@ -30,6 +30,7 @@
 #define RENAMEPROJECT "renameProject"
 #define LISTPROJECTS "listProjects"
 #define LISTPROJPETNAMES "listProjectPetNames"
+#define LISTBRANCHES "listBranches"
 #define LISTBRANCHPETNAMES "listBranchPetNames"
 #define CREATEBRANCH "createBranch"
 #define RENAMEBRANCH "renameBranch"



1.6       +2 -2      pcms/src/repos/common/Repository.h

Index: Repository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/Repository.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Repository.h	2001/11/13 17:06:12	1.5
+++ Repository.h	2001/11/16 18:02:02	1.6
@@ -51,7 +51,7 @@
 
   /* This interface is also wrong -- needs authinfo! */
   StrVec * (*ListBranches)(Repository *r, Project *p);
-  StrVec * (*ListBranchPetNames)(Repository *r, Branch *b);
+  StrVec * (*ListBranchPetNames)(Repository *r, Branch *b, const char *pName);
 
   /* Entity management: -- both 2nd args must be serializables */
   const char *(*ReviseEntity)(Repository *r, const char *prevTrueName, void *);
@@ -83,7 +83,7 @@
 
 /* This interface is also wrong! */
 #define repos_ListBranches(r,p)       r->ListBranches(r,p)
-#define repos_ListBranchPetNames(r,p) r->ListBranchPetNames(r,p)
+#define repos_ListBranchPetNames(r,p,c) r->ListBranchPetNames(r,p,c)
 
 /* Entity management: -- 2nd arg to ReviseEntity must be Serializable */
 #define repos_ReviseEntity(r,ptn,ent) r->ReviseEntity(r,ptn,ent)



1.6       +2 -2      pcms/src/repos/fs/CachedFileRepos.c

Index: CachedFileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/CachedFileRepos.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CachedFileRepos.c	2001/11/14 22:24:37	1.5
+++ CachedFileRepos.c	2001/11/16 18:02:02	1.6
@@ -67,9 +67,9 @@
 }
 
  static StrVec * 
-cachedfilerepository_ListBranchPetNames(Repository *r, Branch *b)
+cachedfilerepository_ListBranchPetNames(Repository *r, Branch *b, const char *pName)
 {
-  return (StrVec *)filerepository_ListBranchPetNames(r, b);
+  return (StrVec *)filerepository_ListBranchPetNames(r, b, pName);
 }
 
 /* Manipulation of branches: */



1.6       +7 -3      pcms/src/repos/fs/FileRepos.c

Index: FileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FileRepos.c	2001/11/14 22:24:37	1.5
+++ FileRepos.c	2001/11/16 18:02:02	1.6
@@ -338,17 +338,21 @@
 }
 
   StrVec * 
-filerepository_ListBranchPetNames(Repository *r, Branch *b)
+filerepository_ListBranchPetNames(Repository *r, Branch *b, char *pName)
 {
   DIR* dir;
   struct dirent *ent;
   StrVec *vec = strvec_create();
   const char *path;
   
-  assert(b->project->serTrueName);
+  /* this assert doesn't pass since the Project object is not serialized
+   * as part of the Branch object! */
+/*  assert(b->project->serTrueName);  */
+
+  assert(pName);
   
   path = path_join(r->uri->path, "projects");
-  path = path_join(path, b->project->serTrueName);
+  path = path_join(path, pName);
   path = path_join(path, "petnames");
 
   dir = opendir(path);



1.4       +1 -1      pcms/src/repos/fs/FileRepos.h

Index: FileRepos.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FileRepos.h	2001/11/14 22:24:37	1.3
+++ FileRepos.h	2001/11/16 18:02:02	1.4
@@ -36,7 +36,7 @@
 filerepository_ListProjPetNames(Repository *, Project *);
 
   StrVec * 
-filerepository_ListBranchPetNames(Repository *, Branch *);
+filerepository_ListBranchPetNames(Repository *, Branch *, const char *);
 
   int 
 filerepository_CreateBranch(Repository *, Project *, Branch *);



1.10      +207 -8    pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- NetRepository.c	2001/11/15 23:14:05	1.9
+++ NetRepository.c	2001/11/16 18:02:02	1.10
@@ -370,6 +370,7 @@
 	    /* We need the Project to come back in the reply so we can
 	       update the 'serTrueName' field: */
 	    retProj = (Project *)(vec_fetch(sreply->return_objs,0)); 
+	    retProj->petName = pName;
 	    return retProj;
 
 	} /* end if incoming > 0 */
@@ -434,15 +435,114 @@
     return 0;
 } /* end netrepository_PetRenameProject */
 
+/*
+ * Return a list of string names of all projects in
+ * a given repository:
+ */
 StrVec * 
-netrepository_ListProjects(Repository *r) {return NULL;}
+netrepository_ListProjects(Repository *r) {
+    
+    SDR_stream* net_stream;
+    char *net_buf;
+    char *rawReply;
+    unsigned int incoming;
+    StrVec *retStrVec;
+    
+    ServerRequest *sr;
+    ServerReply *sreply;
 
-  StrVec * 
-netrepository_ListProjPetNames(Repository *r, Project *p) {return NULL;}
+    net_stream = stream_openstring(STREAM_XML);
+
+    sr = request_create(LISTPROJECTS, r->uri->path, r->uri->username, PCMS_OPCODE_LISTPROJECTS);
+
+    /* Now serialize the request into an XML stream: */
+    sdr_write (SERVERREQUEST, net_stream, sr);
+    
+    /* Convert XML stream to char* to send over wire: */
+    net_buf = (char *)net_stream->data;
+    stream_close(net_stream);
 
+    /* Now send the data over the socket: */
+    sendBuff(*(r->connfd), net_buf);
+
+    /* Wait for the response: */
+    read (*(r->connfd), &incoming, sizeof(incoming));
+
+    if (incoming > 0) {
+	rawReply = (char *)pcms_malloc(incoming);
+	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
+	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	sreply = sdr_read(SERVERREPLY, net_stream);
+	
+	/* Retrieve StrVec object from the reply in order to
+	   update the Branch serTrueName field */
+	retStrVec = (StrVec *)(vec_fetch(sreply->return_objs,0)); 
+
+	report(sreply->data);
+    } else {
+	report("Invalid Server Reply.\n");
+	retStrVec = NULL;
+    } /* end if-else incoming > 0 */
+
+    return retStrVec;
+
+} /* end netrepository_ListProjects */
+
+/*
+ * Return the list of project pet names for a given Project.  This call
+ * is used in conjunction with the "listProjects" function above to
+ * complete the "list projects" client command.
+ */
   StrVec * 
-netrepository_ListBranchPetNames(Repository *r, Branch *b) {return NULL;}
+netrepository_ListProjPetNames(Repository *r, Project *p) {
+    
+    SDR_stream* net_stream;
+    char *net_buf;
+    char *rawReply;
+    unsigned int incoming;
+    StrVec *retStrVec;
+    
+    ServerRequest *sr;
+    ServerReply *sreply;
+
+    net_stream = stream_openstring(STREAM_XML);
+
+    sr = request_create(LISTPROJPETNAMES, r->uri->path, r->uri->username, PCMS_OPCODE_LISTPROJPETNAMES);
+
+    /* Now add the Project as an argument to this request: */
+    serverrequest_AddArgument(sr, p);
+
+    /* Now serialize the request into an XML stream: */
+    sdr_write (SERVERREQUEST, net_stream, sr);
+    
+    /* Convert XML stream to char* to send over wire: */
+    net_buf = (char *)net_stream->data;
+    stream_close(net_stream);
+
+    /* Now send the data over the socket: */
+    sendBuff(*(r->connfd), net_buf);
+
+    /* Wait for the response: */
+    read (*(r->connfd), &incoming, sizeof(incoming));
+
+    if (incoming > 0) {
+	rawReply = (char *)pcms_malloc(incoming);
+	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
+	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	sreply = sdr_read(SERVERREPLY, net_stream);
+	
+	/* Retrieve StrVec object from the reply in order to
+	   update the Branch serTrueName field */
+	retStrVec = (StrVec *)(vec_fetch(sreply->return_objs,0)); 
 
+    } else {
+	report("Invalid Server Reply.\n");
+	retStrVec = NULL;
+    } /* end if-else incoming > 0 */
+
+    return retStrVec;
+} /* end netrepository_ListProjPetNames */
+
 /*
 * Method to create a Branch for a remote Repository.  Basically, wrap
 * the necessary parameters in a Server Request object and send it up
@@ -575,7 +675,7 @@
 	char *rawReply;
 	unsigned int incoming;
 	ServerStringArgument *ser_bName;
-	Branch *retBranch;
+	Branch *retBranch = NULL;
 	
 	ServerRequest *sr;
 	ServerReply *sreply;
@@ -629,10 +729,10 @@
 	    /* We need the Branch to come back in the reply so we can
 	       update the 'serTrueName' field: */
 	    retBranch = (Branch *)(vec_fetch(sreply->return_objs,0)); 
-	    return retBranch;
+	    retBranch->project = p;
 	} /* end if incoming > 0 */
 
-    return NULL;
+    return retBranch;
 } /* end netrepository_GetBranch */
 
 /*
@@ -780,8 +880,107 @@
     return 0;
 } /* end netrepository_ReviseBranch */
 
+  StrVec * 
+netrepository_ListBranchPetNames(Repository *r, Branch *b, const char *pName) {
+    
+    SDR_stream* net_stream;
+    char *net_buf;
+    char *rawReply;
+    unsigned int incoming;
+    StrVec *retStrVec;
+    
+    ServerRequest *sr;
+    ServerReply *sreply;
+
+    net_stream = stream_openstring(STREAM_XML);
+
+    sr = request_create(LISTBRANCHPETNAMES, r->uri->path, r->uri->username, PCMS_OPCODE_LISTBRANCHPETNAMES);
+
+    /* Now add the Branch as an argument to this request: */
+    serverrequest_AddArgument(sr, b);
+    serverrequest_AddArgument(sr, serverarg_create(pName));
+
+    /* Now serialize the request into an XML stream: */
+    sdr_write (SERVERREQUEST, net_stream, sr);
+    
+    /* Convert XML stream to char* to send over wire: */
+    net_buf = (char *)net_stream->data;
+    stream_close(net_stream);
+
+    /* Now send the data over the socket: */
+    sendBuff(*(r->connfd), net_buf);
+
+    /* Wait for the response: */
+    read (*(r->connfd), &incoming, sizeof(incoming));
+
+    if (incoming > 0) {
+	rawReply = (char *)pcms_malloc(incoming);
+	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
+	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	sreply = sdr_read(SERVERREPLY, net_stream);
+	
+	/* Retrieve StrVec object from the reply in order to
+	   update the Branch serTrueName field */
+	retStrVec = (StrVec *)(vec_fetch(sreply->return_objs,0)); 
+
+    } else {
+	report("Invalid Server Reply.\n");
+	retStrVec = NULL;
+    } /* end if-else incoming > 0 */
+
+    return retStrVec;
+} /* end netrepository_ListBranchPetNames */
+
   StrVec *
-netrepository_ListBranches(Repository *r, Project *p) {return NULL;}
+netrepository_ListBranches(Repository *r, Project *p) {
+    
+    SDR_stream* net_stream;
+    char *net_buf;
+    char *rawReply;
+    unsigned int incoming;
+    StrVec *retStrVec;
+    
+    ServerRequest *sr;
+    ServerReply *sreply;
+
+    net_stream = stream_openstring(STREAM_XML);
+
+    sr = request_create(LISTBRANCHES, r->uri->path, r->uri->username, PCMS_OPCODE_LISTBRANCHES);
+
+    /* Now add the Project as an argument to this request: */
+    serverrequest_AddArgument(sr, p);
+
+    /* Now serialize the request into an XML stream: */
+    sdr_write (SERVERREQUEST, net_stream, sr);
+    
+    /* Convert XML stream to char* to send over wire: */
+    net_buf = (char *)net_stream->data;
+    stream_close(net_stream);
+
+    /* Now send the data over the socket: */
+    sendBuff(*(r->connfd), net_buf);
+
+    /* Wait for the response: */
+    read (*(r->connfd), &incoming, sizeof(incoming));
+
+    if (incoming > 0) {
+	rawReply = (char *)pcms_malloc(incoming);
+	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
+	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	sreply = sdr_read(SERVERREPLY, net_stream);
+	
+	/* Retrieve StrVec object from the reply in order to
+	   update the Branch serTrueName field */
+	retStrVec = (StrVec *)(vec_fetch(sreply->return_objs,0)); 
+
+	report(sreply->data);
+    } else {
+	report("Invalid Server Reply.\n");
+	retStrVec = NULL;
+    } /* end if-else incoming > 0 */
+
+    return retStrVec;
+} /* end netrepository_ListBranches */
 
 const char *
 netrepository_ReviseEntity(Repository *r,



1.5       +1 -1      pcms/src/repos/net/NetRepository.h

Index: NetRepository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- NetRepository.h	2001/11/14 22:24:37	1.4
+++ NetRepository.h	2001/11/16 18:02:02	1.5
@@ -28,7 +28,7 @@
 netrepository_ListProjPetNames(Repository *, Project *);
 
   StrVec * 
-netrepository_ListBranchPetNames(Repository *, Branch *);
+netrepository_ListBranchPetNames(Repository *, Branch *, const char *);
 
   int 
 netrepository_CreateBranch(Repository *, Project *, Branch *);



1.10      +119 -0    pcms/src/server/pcmsserver.c

Index: pcmsserver.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/pcmsserver.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- pcmsserver.c	2001/11/15 23:14:06	1.9
+++ pcmsserver.c	2001/11/16 18:02:02	1.10
@@ -75,6 +75,8 @@
 char *tooManyClients = "Connection refused... too many clients.";
 Project *proj_arg;
 Branch *branch_arg;
+StrVec *proj_list;
+StrVec *branch_list;
 ServerStringArgument *string_arg;
 ServerStringArgument *string_arg2;
 void *ent_arg;
@@ -694,12 +696,129 @@
 
 				break;
 
+			    /*********************************************************
+			     * GENERATE A LIST OF ALL BRANCHES FOR A GIVEN PROJECT:
+			     ********************************************************/
+			    case PCMS_OPCODE_LISTBRANCHES:
+
+				open_local_repos_if_needed(nextRequest->repos_path);
+
+				/* This command requires a Project argument. */
+				if (vec_size(thisRequest->args) > 0) {
+				    
+				    /* First is the Project of interest: */
+				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
+
+				    /* Now just do what the File Repository object would do: */
+				    branch_list = NULL;
+				    branch_list = localRepos->ListBranches(localRepos, proj_arg);
+				    if (branch_list == NULL)
+					reply = reply_create("Error accessing Branch.\n", thisRequest->sockfd);
+				    else {
+					reply = reply_create("Success: Branches retrieved.\n", thisRequest->sockfd);
+					serverreply_AddArgument(reply, branch_list);
+				    } /* end if branch_list == NULL*/
+				} else {
+				    reply = reply_create("Error accessing Branch:(no Project specified as argument.)\n", thisRequest->sockfd);
+				} /* end if-else vec_size() > 0 */
+
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &writeholder);
+
+				break;
+
+			    /*********************************************************
+			     * GENERATE A LIST OF PET NAMES FOR A GIVEN BRANCH:
+			     ********************************************************/
+			    case PCMS_OPCODE_LISTBRANCHPETNAMES:
+
+				open_local_repos_if_needed(nextRequest->repos_path);
+
+				/* This command requires a Branch argument. */
+				if (vec_size(thisRequest->args) > 0) {
+				    
+				    /* First is the Project of interest: */
+				    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 0));
+
+				    /* Next is the true name of the Branch's Project: */
+				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
+
+				    /* Now just do what the File Repository object would do: */
+				    branch_list = NULL;
+				    branch_list = localRepos->ListBranchPetNames(localRepos, branch_arg, string_arg->data);
+				    if (branch_list == NULL)
+					reply = reply_create("Error retrieving nickname of Branch.\n", thisRequest->sockfd);
+				    else {
+					reply = reply_create("Success: Branch nickname retrieved.\n", thisRequest->sockfd);
+					serverreply_AddArgument(reply, branch_list);
+				    } /* end if branch_list == NULL*/
+				} else {
+				    reply = reply_create("Error retrieving nickname:(no Branch specified as argument.)\n", thisRequest->sockfd);
+				} /* end if-else vec_size() > 0 */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &writeholder);
+
+				break;
+
+			    /*********************************************************
+			     * GENERATE A LIST OF ALL PROJECTS FOR A GIVEN REPOSITORY:
+			     ********************************************************/
 			    case PCMS_OPCODE_LISTPROJECTS:
+
 				open_local_repos_if_needed(nextRequest->repos_path);
+
+				/* Now just do what the File Repository object would do: */
+				proj_list = NULL;
+				proj_list = localRepos->ListProjects(localRepos);
+				if (proj_list == NULL)
+				    reply = reply_create("Error trying to list Projects.\n", thisRequest->sockfd);
+				else {
+				    reply = reply_create("Success: Projects retrieved.\n", thisRequest->sockfd);
+				    serverreply_AddArgument(reply, proj_list);
+				} /* end if proj_list == NULL*/
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &writeholder);
+
 				break;
+
+			    /*********************************************************
+			     * GENERATE A LIST OF PET NAMES FOR A GIVEN PROJECT:
+			     ********************************************************/
 			    case PCMS_OPCODE_LISTPROJPETNAMES:
+
 				open_local_repos_if_needed(nextRequest->repos_path);
+
+				/* This command requires a Project argument. */
+				if (vec_size(thisRequest->args) > 0) {
+				    
+				    /* First is the Project of interest: */
+				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
+
+				    /* Now just do what the File Repository object would do: */
+				    proj_list = NULL;
+				    proj_list = localRepos->ListProjPetNames(localRepos, proj_arg);
+				    if (proj_list == NULL)
+					reply = reply_create("Error trying to list Projects.\n", thisRequest->sockfd);
+				    else {
+					reply = reply_create("Success: Project pet names retrieved.\n", thisRequest->sockfd);
+					serverreply_AddArgument(reply, proj_list);
+				    } /* end if proj_list == NULL*/
+				} else {
+				    reply = reply_create("Error retrieving nickname:(no Project specified as argument.)\n", thisRequest->sockfd);
+				} /* end if-else vec_size() > 0 */
+
+				/* Add this reply to the write queue: */
+				AddToMsgQueue(writeq, reply);
+				FD_SET(reply->sockfd, &writeholder);
+
 				break;
+
 			    default:
 				break;
 			} /* end switch block */




From vandy@snocrash.cs.jhu.edu Fri Nov 16 14:25:59 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fAGJPxv14323
	for <dcms-cvs@eros.cs.jhu.edu>; Fri, 16 Nov 2001 14:25:59 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id PAA00902;
	Fri, 16 Nov 2001 15:09:48 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fAGJMnS15902;
	Fri, 16 Nov 2001 14:22:49 -0500
Date: Fri, 16 Nov 2001 14:22:49 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111161922.fAGJMnS15902@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/client WsEntity.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/16 14:22:48

  Modified:    src/client WsEntity.c
  Log:
  Orig. version had an endlessly recursive call to itself. I ripped that
  out and replaced it with a bunch of "xprintf" calls...

Revision  Changes    Path
1.4       +21 -2     pcms/src/client/WsEntity.c

Index: WsEntity.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/WsEntity.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WsEntity.c	2001/11/14 22:24:36	1.3
+++ WsEntity.c	2001/11/16 19:22:47	1.4
@@ -164,10 +164,29 @@
 wsentity_show(const void *ob)
 {
   const WsEntity *wse = ob;
+  const Entity localE = wse->e;
   
-  xprintf("WsEntity %s\n", wse->e.fsName);
+  xprintf("====> WsEntity (begin)\n");
+  xprintf("familyNID: %s\n", wse->e.familyNID);
+  xprintf("contentTrueName: %s\n", wse->e.contentTrueName);
+  xprintf("commitInfoTrueName: %s\n", wse->e.commitInfoTrueName);
+  xprintf("fsName: %s\n", wse->e.fsName);
+  xprintf("entityType: %d\n", wse->e.entityType);
 
-  sdr_show(ob);
+  xprintf("parent: %s\n", wse->e.parent);
+  xprintf("mergeParent: %s\n", wse->e.mergeParent);
+
+  xprintf("projectTrueName: %s\n", wse->e.projectTrueName);
+  xprintf("branchTrueName: %s\n", wse->e.branchTrueName);
+  xprintf("branchVersion: %d\n", wse->e.branchVersion);
+
+  xprintf("flags: %d\n", wse->flags);
+  xprintf("orig_fsName: %s\n", wse->orig_fsName);
+  xprintf("orig_contentTrueName: %s\n", wse->orig_contentTrueName);
+  xprintf("orig_entityName: %s\n", wse->orig_entityName);
+  xprintf("orig_entityType: %d\n", wse->orig_entityType);
+
+  xprintf("====> WsEntity (end)\n");
 
 #if 0
   sdr_show(wse->baseEntity);




From vandy@snocrash.cs.jhu.edu Mon Nov 19 19:46:20 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fAK0kKv09366
	for <dcms-cvs@eros.cs.jhu.edu>; Mon, 19 Nov 2001 19:46:20 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id UAA00701;
	Mon, 19 Nov 2001 20:29:38 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fAK0gcq12338;
	Mon, 19 Nov 2001 19:42:38 -0500
Date: Mon, 19 Nov 2001 19:42:38 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111200042.fAK0gcq12338@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/repos/net NetRepository.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/19 19:42:37

  Modified:    src/repos/fs FileRepos.c
               src/repos/net NetRepository.c
  Log:
  Minor fixes.

Revision  Changes    Path
1.7       +1 -1      pcms/src/repos/fs/FileRepos.c

Index: FileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- FileRepos.c	2001/11/16 18:02:02	1.6
+++ FileRepos.c	2001/11/20 00:42:37	1.7
@@ -338,7 +338,7 @@
 }
 
   StrVec * 
-filerepository_ListBranchPetNames(Repository *r, Branch *b, char *pName)
+filerepository_ListBranchPetNames(Repository *r, Branch *b, const char *pName)
 {
   DIR* dir;
   struct dirent *ent;



1.11      +1 -1      pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- NetRepository.c	2001/11/16 18:02:02	1.10
+++ NetRepository.c	2001/11/20 00:42:37	1.11
@@ -370,7 +370,7 @@
 	    /* We need the Project to come back in the reply so we can
 	       update the 'serTrueName' field: */
 	    retProj = (Project *)(vec_fetch(sreply->return_objs,0)); 
-	    retProj->petName = pName;
+/*	    retProj->petName = pName; */
 	    return retProj;
 
 	} /* end if incoming > 0 */




From vandy@snocrash.cs.jhu.edu Tue Nov 20 18:38:36 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fAKNcaV05361
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 20 Nov 2001 18:38:36 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id TAA00842;
	Tue, 20 Nov 2001 19:21:49 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fAKNYjl21989;
	Tue, 20 Nov 2001 18:34:45 -0500
Date: Tue, 20 Nov 2001 18:34:45 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111202334.fAKNYjl21989@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server pcmsserver.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/20 18:34:45

  Modified:    src      globals.h pcms.h pcmsrules.mk.in
               src/client Options.c pcms.c
               src/common ServerReply.c ServerReply.h
               src/repos pcmsrepos.h
               src/repos/common Repository.h
               src/repos/fs CachedFileRepos.c FileRepos.c
               src/repos/net NetRepository.c NetRepository.h
               src/server pcmsserver.c
  Log:
  Cleaned up server code a bit;  added exception handling so errors are
  propagated back to client in client-server mode;

Revision  Changes    Path
1.14      +8 -0      pcms/src/globals.h

Index: globals.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/globals.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- globals.h	2001/10/02 02:17:56	1.13
+++ globals.h	2001/11/20 23:34:44	1.14
@@ -28,6 +28,14 @@
 /* Debugging classes: */
 extern unsigned dbg_mask;
 
+/* Network message types: */
+#define NET_REPLY 50
+#define NET_ERROR 51
+#define NET_INFO  52
+
+jmp_buf jmp_buffer;
+char *server_err_msg;
+
 #define DBG_STARTUP  0x1u
 #define DBG_PATH     0x2u
 #define DBG_COMMIT   0x4u



1.13      +1 -0      pcms/src/pcms.h

Index: pcms.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/pcms.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- pcms.h	2001/11/08 23:25:32	1.12
+++ pcms.h	2001/11/20 23:34:44	1.13
@@ -19,6 +19,7 @@
 #include <limits.h>
 #include <dirent.h>
 #include <assert.h>
+#include <setjmp.h>
 
 typedef struct Change Change;
 typedef struct CommitInfo CommitInfo;



1.4       +7 -3      pcms/src/pcmsrules.mk.in

Index: pcmsrules.mk.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/pcmsrules.mk.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- pcmsrules.mk.in	2001/11/13 17:07:34	1.3
+++ pcmsrules.mk.in	2001/11/20 23:34:44	1.4
@@ -30,7 +30,7 @@
 	$(TOPDIR)/common/os.o \
 	$(TOPDIR)/common/ServerRequest.o \
 	$(TOPDIR)/common/ServerReply.o \
-	$(TOPDIR)/common/ServerStringArgument.o
+	$(TOPDIR)/common/ServerStringArgument.o 
 
 REPOSOBJECTS=\
 	$(TOPDIR)/repos/fs/CachedFileRepos.o \
@@ -75,12 +75,16 @@
 	$(TOPDIR)/client/PendingChange.o \
 	$(TOPDIR)/client/WorkSpace.o \
 	$(TOPDIR)/client/Options.o \
-	$(TOPDIR)/client/Merge.o
+	$(TOPDIR)/client/Merge.o \
+	$(TOPDIR)/client/ReportError.o 
 
 CLIENT=$(TOPDIR)/pcms
 
 SERVEROBJECTS=\
-	$(TOPDIR)/server/pcmsserver.o $(TOPDIR)/server/MsgQueue.o
+	$(TOPDIR)/server/pcmsserver.o \
+	$(TOPDIR)/server/DispatchRequest.o \
+	$(TOPDIR)/server/MsgQueue.o \
+	$(TOPDIR)/server/ReportError.o
 
 SERVER=$(TOPDIR)/pcmsserver
 



1.3       +2 -0      pcms/src/client/Options.c

Index: Options.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/Options.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Options.c	2001/10/19 03:44:10	1.2
+++ Options.c	2001/11/20 23:34:44	1.3
@@ -176,6 +176,7 @@
   }
 }
 
+/**** MOVED TO SEPARATE FILE:
 void
 report_error(int isFatal, const char *fmt, ...)
 {
@@ -199,6 +200,7 @@
     exit(isFatal);
   }
 }
+****/
 
 void
 report(const char *fmt, ...)



1.7       +0 -74     pcms/src/client/pcms.c

Index: pcms.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/pcms.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- pcms.c	2001/11/16 18:02:02	1.6
+++ pcms.c	2001/11/20 23:34:44	1.7
@@ -1,82 +1,8 @@
 /* Copyright (C) 2000, The EROS Group, LLC. */
 
-/* PCMS Project Configuration Management System */
-
 #include <pcms.h>
 #include <repos/pcmsrepos.h>
 #include "pcmsclient.h"
-
-/***
- char *ServerURI = 0;
- ****/
-
-/****
-int
-validate_pet_name(const char *s)
-{
-  if (s == 0)
-    return 0;
-  if (strlen(s) == 0)
-    return 0;
-
-  if (s[0] == '-' || s[0] == '.')
-    return 0;
-      
-  while (*s) {
-    char c = *s++;
-    if (isalnum(c) == 0 &&
-	c != '_' &&
-	c != '.' &&
-	c != '-')
-      return 0;
-  }
-
-  return 1;  
-}
-
-char *
-xstrcat(const char *s1, const char *s2)
-{
-  char *news =
-    (char *) pcms_malloc (sizeof(char) * (strlen(s1) + strlen(s2) + 1));
-  if (news == 0)
-    report_error(EX_NoMemory, "Out of memory\n");
-
-  strcpy(news, s1);
-  strcat(news, s2);
-  return news;
-}
-
-char *
-xstrdup(const char *s)
-{
-  char *news =
-    (char *) pcms_malloc(sizeof(char) * (strlen(s) + 1));
-  if (news == 0)
-    report_error(EX_NoMemory, "Out of memory\n");
-
-  strcpy(news, s);
-  return news;
-}
-
-char *
-xstrndup(const char *s, int len)
-{
-  char *news;
-  
-  if (strlen(s) < len)
-    return xstrdup(s);
-
-  news = (char *) pcms_malloc(sizeof(char) * (len + 1));
-  if (news == 0)
-    report_error(EX_NoMemory, "Out of memory\n");
-
-  strncpy(news, s, len);
-  news[len] = 0;
-  return news;
-}
-*****/
-
 
 void
 pcms_rename_branch(Repository *r, int argc, char **argv)



1.4       +5 -2      pcms/src/common/ServerReply.c

Index: ServerReply.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerReply.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServerReply.c	2001/11/14 22:24:36	1.3
+++ ServerReply.c	2001/11/20 23:34:44	1.4
@@ -11,6 +11,7 @@
   const ServerReply *p = ob;
   
   sdr_w_string("serTrueName", strm, p->serTrueName);
+  sdr_w_ulong("rtype", strm, p->rtype);
   sdr_w_string("data", strm, p->data);
   sdr_w_ulong("sock", strm, p->sockfd);
   sdr_write("args", strm, p->return_objs);
@@ -24,6 +25,7 @@
 
   p->serType	    = &ServerReply_SerType;
   p->serTrueName    = sdr_r_string("serTrueName", strm);
+  p->rtype	    = sdr_r_ulong("rtype", strm);
   p->data           = sdr_r_string("data", strm);
   p->sockfd	    = sdr_r_ulong("sock", strm);
   p->return_objs    = sdr_read("args", strm);
@@ -32,13 +34,13 @@
 }
 
 ServerReply *
-reply_create(const char *reply, int socket)
+reply_create(int type, const char *reply, int socket)
 {
   ServerReply *p = (ServerReply *) pcms_malloc(sizeof(ServerReply));
 
   p->serType = &ServerReply_SerType;
   p->serTrueName = 0;
-
+  p->rtype = type;
   p->data = reply;
   p->sockfd = socket;
   p->return_objs = obvec_create();
@@ -52,6 +54,7 @@
   unsigned int u;
   
   xprintf("SerTrueName:     %s\n", p->serTrueName);
+  xprintf("Type       :     %d\n", p->rtype);
   xprintf("Data       :     %s\n", p->data);
   xprintf("Socket     :     %d\n", p->sockfd);
 



1.4       +2 -1      pcms/src/common/ServerReply.h

Index: ServerReply.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerReply.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServerReply.h	2001/11/14 22:24:36	1.3
+++ ServerReply.h	2001/11/20 23:34:44	1.4
@@ -7,13 +7,14 @@
 typedef struct ServerReply {
   Serializable ser;
   
+  int rtype;  /* info-only, error, or successful reply */
   const char *data;
   int sockfd;
   ObVec *return_objs;
 
 } ServerReply;
 
-ServerReply *reply_create (const char *reply, int socket);
+ServerReply *reply_create (int type, const char *reply, int socket);
 
 /*
  * Need method to add return objects:



1.3       +5 -0      pcms/src/repos/pcmsrepos.h

Index: pcmsrepos.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/pcmsrepos.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- pcmsrepos.h	2001/10/25 01:03:02	1.2
+++ pcmsrepos.h	2001/11/20 23:34:44	1.3
@@ -1,3 +1,6 @@
+#ifndef __PCMSREPOS_H__
+#define __PCMSREPOS_H__
+
 /*Copyright (C) 2000, The EROS Group, LLC. */
 
 typedef struct URI URI;
@@ -10,4 +13,6 @@
 #include "repos/common/EntityCache.h"
 #include "repos/fs/FileRepos.h"
 #include "repos/net/NetRepository.h"
+
+#endif
 



1.7       +2 -1      pcms/src/repos/common/Repository.h

Index: Repository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/Repository.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Repository.h	2001/11/16 18:02:02	1.6
+++ Repository.h	2001/11/20 23:34:44	1.7
@@ -12,6 +12,7 @@
  * The base class encapsulates the protocol between the user agent and
  * the repository.
  */
+#include <repos/Channel.h>
 
 struct Repository {
   /*  Serializable ser; */
@@ -20,7 +21,7 @@
   AuthInfo    *auth;
   void        *info;		/* type specific info */
   EntityCache *cache;
-  int 	      *connfd;
+  Channel     *channel;         /* network protocol-specific connection info */
   
   const char *(*GetVersion)(Repository *r);
 



1.7       +1 -1      pcms/src/repos/fs/CachedFileRepos.c

Index: CachedFileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/CachedFileRepos.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CachedFileRepos.c	2001/11/16 18:02:02	1.6
+++ CachedFileRepos.c	2001/11/20 23:34:44	1.7
@@ -252,7 +252,7 @@
   r->GetEntity = cachedfilerepository_GetEntity;
 
   r->cache = createEntityCache();
-  r->connfd = NULL;
+  r->channel = NULL;
 }
 
 



1.8       +1 -1      pcms/src/repos/fs/FileRepos.c

Index: FileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FileRepos.c	2001/11/20 00:42:37	1.7
+++ FileRepos.c	2001/11/20 23:34:44	1.8
@@ -700,7 +700,7 @@
   r->GetEntity = filerepository_GetEntity;
 
   r->cache = NULL;
-  r->connfd = NULL;
+  r->channel = NULL;
 }
 
 



1.12      +207 -692  pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- NetRepository.c	2001/11/20 00:42:37	1.11
+++ NetRepository.c	2001/11/20 23:34:45	1.12
@@ -1,5 +1,6 @@
 #include <pcms.h>
 #include <repos/pcmsrepos.h>
+#include <repos/Channel.h>
 #include <common/ServerRequest.h>
 #include <common/ServerReply.h>
 #include <common/ServerStringArgument.h>
@@ -17,70 +18,29 @@
 /**  OLD:   inline void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen); */
 inline void sendBuff(int connectfd, const void* messagebuf);
 
+/* Method to ensure all bytes are read from socket, especially
+   when socket buffer is exceeded */
 char * read_entire_msg_from_socket(int, unsigned int);
 
-int netrepository_CreateRepository(Repository *r) {
-	SDR_stream* net_stream;
-	char *net_buf;
-	char *rawReply;
-	unsigned int incoming;
-	
-	ServerRequest *sr;
-	ServerReply *sreply;
-
-	net_stream = stream_openstring(STREAM_XML);
-
-	sr = request_create(CREATEREPOSITORY, r->uri->path, r->uri->username, PCMS_OPCODE_CREATEREPOSITORY);
-
-	/* Now serialize the request into an XML stream: */
-	sdr_write (SERVERREQUEST, net_stream, sr);
-	
-	/* Convert XML stream to char* to send over wire: */
-	net_buf = (char *)net_stream->data;
-	stream_close(net_stream);
-
-	/* Now send the data over the socket: */
-	sendBuff(*(r->connfd), net_buf);
-
-	/* Wait for the response: */
-	read (*(r->connfd), &incoming, sizeof(incoming));
-
-	if (incoming > 0) {
-	    rawReply = (char *)pcms_malloc(incoming);
-
-	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
+/* Method to encapsulate all network protocol-specific details
+   of sending request to the Server */
+Serializable * invoke_server (Repository *r, ServerRequest *);
 
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY, net_stream);
-	    report (sreply->data);
-	    return 0;
-	} else {
-	    report (sreply->data);
-	    return -1;
-	} /* end if-else */
-
-} /* end netrepository_CreateRepository */
-
 int netrepository_connect(Repository *r) {
 	
-	
 	struct sockaddr_in cliaddr;
-	/*int message_length, mess_sent;*/
-	/*char message[4096 + sizeof(message_length)];
-	char *input;*/
 	struct hostent *netlocaddr;
 	struct in_addr **hostptr;
 	int connsucceed;
 	
-	r->connfd = (int *)pcms_malloc(sizeof(int));
-	
 	if ((netlocaddr = gethostbyname2(r->uri->netloc, AF_INET)) == NULL) {
 		printf("%s\n", hstrerror(h_errno));
 	}
 	
 	hostptr = (struct in_addr **) netlocaddr->h_addr_list;
 
-	*(r->connfd) = socket(AF_INET, SOCK_STREAM, 0);
+	r->channel->sockfd = socket(AF_INET, SOCK_STREAM, 0);
+	r->channel->channelID = 1;  
 	
 	for (connsucceed = 0 ; *hostptr != NULL; hostptr++) {
 	
@@ -91,7 +51,7 @@
 		
 		fprintf(stderr, "Connecting to %s: %s, port %d\n", r->uri->netloc, inet_ntoa(cliaddr.sin_addr), ntohs(cliaddr.sin_port)); 
 	
-		if (connect(*(r->connfd), (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
+		if (connect(r->channel->sockfd, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
 			fprintf(stderr, "Connect Error\n");
 		}
 		else {
@@ -104,17 +64,6 @@
 	}
 
 	return 0;
-
-	/*bzero(&message, MAX_MESSAGE_LENGTH + sizeof(message_length));
-	
-	for ( ; ; ) {
-		printf("Enter Message: ");
-
-		input = (char *)pcms_malloc(MAX_MESSAGE_LENGTH * sizeof(char));
-		scanf("%s", input);
-		
-		sendMessage(*(r->connfd), input);
-	}*/
 }
 
 void sendStr(int connectfd, const char* messagebuf) {
@@ -146,100 +95,58 @@
 }
 
 /*
-*  Create a ServerRequest with the opcode for "get version",
-*  send it upstream and wait for the reply.
-*/
-const char *
-netrepository_GetVersion(Repository *r) {
-	SDR_stream* net_stream;
-	char* net_buf;
-	char* rawReply;
-	unsigned int incoming;
-
-	ServerRequest *sr;
-	ServerReply *sreply;
-
-	net_stream = stream_openstring(STREAM_XML);
+ *  Create a Repository via a network repository.
+ */
+int netrepository_CreateRepository(Repository *r) {
 	
-	sr = request_create(GETVERSION, r->uri->path, r->uri->username, PCMS_OPCODE_GETVERSION);  
-        sdr_write (SERVERREQUEST, net_stream, sr);
+        ServerReply *reply;
+	ServerRequest *sr = request_create(CREATEREPOSITORY, r->uri->path, 
+		                           r->uri->username, PCMS_OPCODE_CREATEREPOSITORY);
 
-	net_buf = (char *)net_stream->data;
-	stream_close(net_stream);
-
-	/* Send the request to the remote repository: */
-	sendBuff(*(r->connfd), net_buf);
+	reply = (ServerReply *)(invoke_server(r, sr));
+	report (reply->data);
 
-	/* Read the length of the server's reply: */
-	read(*(r->connfd), &incoming, sizeof(incoming));  
-	
-	/* If not null then process accordingly: */
-	if (incoming > 0) {   
-	    /* Allocate just enough space for server's reply: */
-	    rawReply = (char *)pcms_malloc(incoming);
-	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
+	return 0;
+} /* end netrepository_CreateRepository */
 
-	    /* Create SDR stream to allow easy deserialization of reply: */
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY,net_stream);
+/*
+ *  Create a ServerRequest with the opcode for "get version",
+ *  send it upstream and wait for the reply.
+ */
+const char *
+netrepository_GetVersion(Repository *r) {
 
-	    /* Return just the part we're interested in: */
-	    return sreply->data;  
-	} else
-	    return "No response from repository"; 
-}
+	ServerReply *reply;
+	ServerRequest *sr = request_create(GETVERSION, r->uri->path, 
+		                           r->uri->username, PCMS_OPCODE_GETVERSION);  
+
+	reply = (ServerReply *)(invoke_server(r, sr));
+	return reply->data;  
+} /* end netrepository_GetVersion */
   
 /*
 * Create a ServerRequest object with the opcode for "create project"
 * and wait for the reply.
 */
 int netrepository_CreateProject(Repository *r, Project *p) {
-	SDR_stream* net_stream;
-	char *net_buf;
-	char *rawReply;
-	unsigned int incoming;
+
 	Project *retProj;
 	
-	ServerRequest *sr;
-	ServerReply *sreply;
-
-	net_stream = stream_openstring(STREAM_XML);
-
-	sr = request_create(CREATEPROJECT, r->uri->path, r->uri->username, PCMS_OPCODE_CREATEPROJECT);
+	ServerReply *reply;
+	ServerRequest *sr = request_create(CREATEPROJECT, r->uri->path, 
+		                           r->uri->username, PCMS_OPCODE_CREATEPROJECT);
 
 	/* Now add the Project argument to this request: */
 	serverrequest_AddArgument(sr, p);
 
-	/* Now serialize the request into an XML stream: */
-	sdr_write (SERVERREQUEST, net_stream, sr);
-	
-	/* Convert XML stream to char* to send over wire: */
-	net_buf = (char *)net_stream->data;
-	stream_close(net_stream);
+	reply = (ServerReply *)(invoke_server(r, sr));
 
-	/* Now send the data over the socket: */
-	sendBuff(*(r->connfd), net_buf);
-
-	/* Wait for the response: */
-	read (*(r->connfd), &incoming, sizeof(incoming));
-
-	if (incoming > 0) {
-	    rawReply = (char *)pcms_malloc(incoming);
-	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY, net_stream);
+	/* We need the Project to come back in the reply so we can
+	   update the 'serTrueName' field: */
+	retProj = (Project *)(vec_fetch(reply->return_objs,0)); 
+	p->serTrueName = retProj->serTrueName;
 
-	    /* We need the Project to come back in the reply so we can
-	       update the 'serTrueName' field: */
-	    retProj = (Project *)(vec_fetch(sreply->return_objs,0)); 
-	    p->serTrueName = retProj->serTrueName;
-
-	    report(sreply->data);
-	    return 1;
-	} else {
-	    report("Invalid Server Reply.\n");
-	    return -1;
-	} /* end if-else */
+	report(reply->data);
 
 } /* end netrepository_CreateProject */
 
@@ -250,15 +157,11 @@
 Project *
 netrepository_GetProject(Repository *r, const char *pName) {
     
-	SDR_stream* net_stream;
-	char *net_buf;
-	char *rawReply;
-	unsigned int incoming;
 	ServerStringArgument *ser_pName;
 	Project *retProj;
-	
-	ServerRequest *sr;
-	ServerReply *sreply;
+	ServerReply *reply;
+	ServerRequest *sr = request_create(GETPROJECT, r->uri->path, 
+		                           r->uri->username, PCMS_OPCODE_GETPROJECT);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -270,44 +173,18 @@
 	if (pName == NULL)
 	    return NULL;
 
-	net_stream = stream_openstring(STREAM_XML);
-
-	sr = request_create(GETPROJECT, r->uri->path, r->uri->username, PCMS_OPCODE_GETPROJECT);
 	ser_pName = serverarg_create(pName);
 
 	/* Now add the true name of the Project as an argument to this request: */
 	serverrequest_AddArgument(sr, ser_pName);
-
-	/* Now serialize the request into an XML stream: */
-	sdr_write (SERVERREQUEST, net_stream, sr);
-	
-	/* Convert XML stream to char* to send over wire: */
-	net_buf = (char *)net_stream->data;
-	stream_close(net_stream);
-
-	/* Now send the data over the socket: */
-	sendBuff(*(r->connfd), net_buf);
-
-	/* Wait for the response: */
-	read (*(r->connfd), &incoming, sizeof(incoming));
-
-	if (incoming > 0) {
-	    /* Allocate just enough space for server's reply: */
-	    rawReply = (char *)pcms_malloc(incoming);
-	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-
-	    /* Create SDR stream to allow easy deserialization of reply: */
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY, net_stream);
 
-	    /* We need the Project to come back in the reply so we can
-	       update the 'serTrueName' field: */
-	    retProj = (Project *)(vec_fetch(sreply->return_objs,0)); 
-	    return retProj;
+	reply = (ServerReply *)(invoke_server(r, sr));
 
-	} /* end if incoming > 0 */
+	/* We need the Project to come back in the reply so we can
+	   update the 'serTrueName' field: */
+	retProj = (Project *)(vec_fetch(reply->return_objs,0)); 
+	return retProj;
 
-    return NULL;
 } /* end netrepository_GetProject */
 
 /*
@@ -317,15 +194,11 @@
 Project *
 netrepository_PetGetProject(Repository *r, const char *pName) {
     
-	SDR_stream* net_stream;
-	char *net_buf;
-	char *rawReply;
-	unsigned int incoming;
 	ServerStringArgument *ser_pName;
 	Project *retProj;
-	
-	ServerRequest *sr;
-	ServerReply *sreply;
+	ServerReply *reply;
+	ServerRequest *sr = request_create(PETGETPROJECT, r->uri->path, 
+		                           r->uri->username, PCMS_OPCODE_PETGETPROJECT);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -337,44 +210,18 @@
 	if (pName == NULL)
 	    return NULL;
 
-	net_stream = stream_openstring(STREAM_XML);
-
-	sr = request_create(PETGETPROJECT, r->uri->path, r->uri->username, PCMS_OPCODE_PETGETPROJECT);
 	ser_pName = serverarg_create(pName);
 
 	/* Now add the true name of the Project as an argument to this request: */
 	serverrequest_AddArgument(sr, ser_pName);
-
-	/* Now serialize the request into an XML stream: */
-	sdr_write (SERVERREQUEST, net_stream, sr);
-	
-	/* Convert XML stream to char* to send over wire: */
-	net_buf = (char *)net_stream->data;
-	stream_close(net_stream);
 
-	/* Now send the data over the socket: */
-	sendBuff(*(r->connfd), net_buf);
+	reply = (ServerReply *)(invoke_server(r,sr));
 
-	/* Wait for the response: */
-	read (*(r->connfd), &incoming, sizeof(incoming));
+	/* We need the Project to come back in the reply so we can
+	   update the 'serTrueName' field: */
+	retProj = (Project *)(vec_fetch(reply->return_objs,0)); 
+	return retProj;
 
-	if (incoming > 0) {
-	    /* Allocate just enough space for server's reply: */
-	    rawReply = (char *)pcms_malloc(incoming);
-	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-
-	    /* Create SDR stream to allow easy deserialization of reply: */
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY, net_stream);
-
-	    /* We need the Project to come back in the reply so we can
-	       update the 'serTrueName' field: */
-	    retProj = (Project *)(vec_fetch(sreply->return_objs,0)); 
-/*	    retProj->petName = pName; */
-	    return retProj;
-
-	} /* end if incoming > 0 */
-    
     return NULL;
 } /* end netrepository_PetGetProject */
 
@@ -382,23 +229,15 @@
  * Rename a Project, given the Repository, current name, and new name
  * as input:
  */
-  int 
+int 
 netrepository_PetRenameProject(Repository *r,
 				const char *oldName, const char *newName) {
     
-    SDR_stream* net_stream;
-    char *net_buf;
-    char *rawReply;
-    unsigned int incoming;
-    
-    ServerRequest *sr;
-    ServerReply *sreply;
     ServerStringArgument *ser_oldName;
     ServerStringArgument *ser_newName;
-
-    net_stream = stream_openstring(STREAM_XML);
-
-    sr = request_create(RENAMEPROJECT, r->uri->path, r->uri->username, PCMS_OPCODE_RENAMEPROJECT);
+    ServerReply *reply;
+    ServerRequest *sr = request_create(RENAMEPROJECT, r->uri->path, 
+	                               r->uri->username, PCMS_OPCODE_RENAMEPROJECT);
     ser_oldName = serverarg_create(oldName);
     ser_newName = serverarg_create(newName);
 
@@ -406,31 +245,8 @@
     serverrequest_AddArgument(sr, ser_oldName);
     serverrequest_AddArgument(sr, ser_newName);
 
-    /* Now serialize the request into an XML stream: */
-    sdr_write (SERVERREQUEST, net_stream, sr);
-    
-    /* Convert XML stream to char* to send over wire: */
-    net_buf = (char *)net_stream->data;
-    stream_close(net_stream);
-
-    /* Now send the data over the socket: */
-    sendBuff(*(r->connfd), net_buf);
-
-    /* Wait for the response: */
-    read (*(r->connfd), &incoming, sizeof(incoming));
-
-    if (incoming > 0) {
-	rawReply = (char *)pcms_malloc(incoming);
-	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	sreply = sdr_read(SERVERREPLY, net_stream);
-	
-	report(sreply->data);
-	return 1;
-    } else {
-	report("Invalid Server Reply.\n");
-	return -1;
-    } /* end if else */
+    reply = (ServerReply *)(invoke_server(r,sr));
+    report(reply->data);
 
     return 0;
 } /* end netrepository_PetRenameProject */
@@ -442,47 +258,17 @@
 StrVec * 
 netrepository_ListProjects(Repository *r) {
     
-    SDR_stream* net_stream;
-    char *net_buf;
-    char *rawReply;
-    unsigned int incoming;
     StrVec *retStrVec;
-    
-    ServerRequest *sr;
-    ServerReply *sreply;
-
-    net_stream = stream_openstring(STREAM_XML);
-
-    sr = request_create(LISTPROJECTS, r->uri->path, r->uri->username, PCMS_OPCODE_LISTPROJECTS);
-
-    /* Now serialize the request into an XML stream: */
-    sdr_write (SERVERREQUEST, net_stream, sr);
-    
-    /* Convert XML stream to char* to send over wire: */
-    net_buf = (char *)net_stream->data;
-    stream_close(net_stream);
-
-    /* Now send the data over the socket: */
-    sendBuff(*(r->connfd), net_buf);
-
-    /* Wait for the response: */
-    read (*(r->connfd), &incoming, sizeof(incoming));
-
-    if (incoming > 0) {
-	rawReply = (char *)pcms_malloc(incoming);
-	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	sreply = sdr_read(SERVERREPLY, net_stream);
-	
-	/* Retrieve StrVec object from the reply in order to
-	   update the Branch serTrueName field */
-	retStrVec = (StrVec *)(vec_fetch(sreply->return_objs,0)); 
-
-	report(sreply->data);
-    } else {
-	report("Invalid Server Reply.\n");
-	retStrVec = NULL;
-    } /* end if-else incoming > 0 */
+    ServerReply *reply;
+    ServerRequest *sr = request_create(LISTPROJECTS, r->uri->path, 
+	                               r->uri->username, PCMS_OPCODE_LISTPROJECTS);
+
+    reply = (ServerReply *)(invoke_server(r,sr));
+	
+    /* Retrieve StrVec object from the reply in order to
+       update the Branch serTrueName field */
+    retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
+    report(reply->data);
 
     return retStrVec;
 
@@ -493,52 +279,22 @@
  * is used in conjunction with the "listProjects" function above to
  * complete the "list projects" client command.
  */
-  StrVec * 
+StrVec * 
 netrepository_ListProjPetNames(Repository *r, Project *p) {
     
-    SDR_stream* net_stream;
-    char *net_buf;
-    char *rawReply;
-    unsigned int incoming;
     StrVec *retStrVec;
-    
-    ServerRequest *sr;
-    ServerReply *sreply;
-
-    net_stream = stream_openstring(STREAM_XML);
-
-    sr = request_create(LISTPROJPETNAMES, r->uri->path, r->uri->username, PCMS_OPCODE_LISTPROJPETNAMES);
+    ServerReply *reply;
+    ServerRequest *sr = request_create(LISTPROJPETNAMES, r->uri->path, 
+	                               r->uri->username, PCMS_OPCODE_LISTPROJPETNAMES);
 
     /* Now add the Project as an argument to this request: */
     serverrequest_AddArgument(sr, p);
 
-    /* Now serialize the request into an XML stream: */
-    sdr_write (SERVERREQUEST, net_stream, sr);
-    
-    /* Convert XML stream to char* to send over wire: */
-    net_buf = (char *)net_stream->data;
-    stream_close(net_stream);
-
-    /* Now send the data over the socket: */
-    sendBuff(*(r->connfd), net_buf);
-
-    /* Wait for the response: */
-    read (*(r->connfd), &incoming, sizeof(incoming));
-
-    if (incoming > 0) {
-	rawReply = (char *)pcms_malloc(incoming);
-	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	sreply = sdr_read(SERVERREPLY, net_stream);
-	
-	/* Retrieve StrVec object from the reply in order to
-	   update the Branch serTrueName field */
-	retStrVec = (StrVec *)(vec_fetch(sreply->return_objs,0)); 
-
-    } else {
-	report("Invalid Server Reply.\n");
-	retStrVec = NULL;
-    } /* end if-else incoming > 0 */
+    reply = (ServerReply *)(invoke_server(r,sr));
+	
+    /* Retrieve StrVec object from the reply in order to
+       update the Branch serTrueName field */
+    retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
 
     return retStrVec;
 } /* end netrepository_ListProjPetNames */
@@ -550,53 +306,24 @@
 */
 int netrepository_CreateBranch(Repository *r, Project *p, Branch *b) {
     
-    SDR_stream* net_stream;
-    char *net_buf;
-    char *rawReply;
-    unsigned int incoming;
     Branch *retBranch;
-    
-    ServerRequest *sr;
-    ServerReply *sreply;
-
-    net_stream = stream_openstring(STREAM_XML);
-
-    sr = request_create(CREATEBRANCH, r->uri->path, r->uri->username, PCMS_OPCODE_CREATEBRANCH);
+    ServerReply *reply;
+    ServerRequest *sr = request_create(CREATEBRANCH, r->uri->path, 
+	                               r->uri->username, PCMS_OPCODE_CREATEBRANCH);
 
     /* Now add the Project and Branch arguments to this request: */
     serverrequest_AddArgument(sr, p);
     serverrequest_AddArgument(sr, b);
 
-    /* Now serialize the request into an XML stream: */
-    sdr_write (SERVERREQUEST, net_stream, sr);
+    reply = (ServerReply *)(invoke_server(r,sr));
+	
+    /* Retrieve Branch object from the reply in order to
+       update the Branch serTrueName field */
+    retBranch = (Branch *)(vec_fetch(reply->return_objs,0)); 
+    b->serTrueName = retBranch->serTrueName;
+    report(reply->data);
     
-    /* Convert XML stream to char* to send over wire: */
-    net_buf = (char *)net_stream->data;
-    stream_close(net_stream);
-
-    /* Now send the data over the socket: */
-    sendBuff(*(r->connfd), net_buf);
-
-    /* Wait for the response: */
-    read (*(r->connfd), &incoming, sizeof(incoming));
-
-    if (incoming > 0) {
-	rawReply = (char *)pcms_malloc(incoming);
-	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	sreply = sdr_read(SERVERREPLY, net_stream);
-	
-	/* Retrieve Branch object from the reply in order to
-	   update the Branch serTrueName field */
-	retBranch = (Branch *)(vec_fetch(sreply->return_objs,0)); 
-	b->serTrueName = retBranch->serTrueName;
-
-	report(sreply->data);
-	return 1;
-    } else {
-	report("Invalid Server Reply.\n");
-	return -1;
-    } /* end if-else */
+    return 0;
 
 } /* end netrepository_CreateBranch */
 
@@ -604,25 +331,17 @@
  * Rename a branch given the branch's Project, the branch's current
  * name, and the branch's new name as parameters:
  */
-  int
+int
 netrepository_PetRenameBranch(Repository *r,
 			       Project *p,
 			       const char *oldName,
 			       const char *newName) {
     
-    SDR_stream* net_stream;
-    char *net_buf;
-    char *rawReply;
-    unsigned int incoming;
-    
-    ServerRequest *sr;
-    ServerReply *sreply;
     ServerStringArgument *ser_oldName;
     ServerStringArgument *ser_newName;
-
-    net_stream = stream_openstring(STREAM_XML);
-
-    sr = request_create(RENAMEBRANCH, r->uri->path, r->uri->username, PCMS_OPCODE_RENAMEBRANCH);
+    ServerReply *reply;
+    ServerRequest *sr = request_create(RENAMEBRANCH, r->uri->path, 
+	                               r->uri->username, PCMS_OPCODE_RENAMEBRANCH);
     ser_oldName = serverarg_create(oldName);
     ser_newName = serverarg_create(newName);
 
@@ -631,31 +350,8 @@
     serverrequest_AddArgument(sr, ser_oldName);
     serverrequest_AddArgument(sr, ser_newName);
 
-    /* Now serialize the request into an XML stream: */
-    sdr_write (SERVERREQUEST, net_stream, sr);
-    
-    /* Convert XML stream to char* to send over wire: */
-    net_buf = (char *)net_stream->data;
-    stream_close(net_stream);
-
-    /* Now send the data over the socket: */
-    sendBuff(*(r->connfd), net_buf);
-
-    /* Wait for the response: */
-    read (*(r->connfd), &incoming, sizeof(incoming));
-
-    if (incoming > 0) {
-	rawReply = (char *)pcms_malloc(incoming);
-	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	sreply = sdr_read(SERVERREPLY, net_stream);
-	
-	report(sreply->data);
-	return 1;
-    } else {
-	report("Invalid Server Reply.\n");
-	return -1;
-    } /* end if else */
+    reply = (ServerReply *)(invoke_server(r,sr));
+    report(reply->data);
 
     return 0;
 } /* end netrepository_PetRenameBranch */
@@ -670,15 +366,11 @@
 netrepository_GetBranch(Repository *r, Project *p,
 			 const char *bName) {
     
-	SDR_stream* net_stream;
-	char *net_buf;
-	char *rawReply;
-	unsigned int incoming;
 	ServerStringArgument *ser_bName;
 	Branch *retBranch = NULL;
-	
-	ServerRequest *sr;
-	ServerReply *sreply;
+	ServerReply *reply;
+	ServerRequest *sr = request_create(GETBRANCH, r->uri->path, 
+		                           r->uri->username, PCMS_OPCODE_GETBRANCH);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -693,9 +385,6 @@
 	if (bName == NULL)
 	    return NULL;
 
-	net_stream = stream_openstring(STREAM_XML);
-
-	sr = request_create(GETBRANCH, r->uri->path, r->uri->username, PCMS_OPCODE_GETBRANCH);
 	ser_bName = serverarg_create(bName);
 
 	/* Now add the Project as an argument to this request: */
@@ -703,53 +392,28 @@
 
 	/* Now add the true name of the Branch as an argument to this request: */
 	serverrequest_AddArgument(sr, ser_bName);
-
-	/* Now serialize the request into an XML stream: */
-	sdr_write (SERVERREQUEST, net_stream, sr);
-	
-	/* Convert XML stream to char* to send over wire: */
-	net_buf = (char *)net_stream->data;
-	stream_close(net_stream);
 
-	/* Now send the data over the socket: */
-	sendBuff(*(r->connfd), net_buf);
+	reply = (ServerReply *)(invoke_server(r,sr));
 
-	/* Wait for the response: */
-	read (*(r->connfd), &incoming, sizeof(incoming));
+	/* We need the Branch to come back in the reply so we can
+	   update the 'serTrueName' field: */
+	retBranch = (Branch *)(vec_fetch(reply->return_objs,0)); 
+	retBranch->project = p;
 
-	if (incoming > 0) {
-	    /* Allocate just enough space for server's reply: */
-	    rawReply = (char *)pcms_malloc(incoming);
-	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-
-	    /* Create SDR stream to allow easy deserialization of reply: */
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY, net_stream);
-
-	    /* We need the Branch to come back in the reply so we can
-	       update the 'serTrueName' field: */
-	    retBranch = (Branch *)(vec_fetch(sreply->return_objs,0)); 
-	    retBranch->project = p;
-	} /* end if incoming > 0 */
-
-    return retBranch;
+	return retBranch;
 } /* end netrepository_GetBranch */
 
 /*
  * Return a Branch object, given its pet name and its Project as input parameters:
  */
-  Branch *
+Branch *
 netrepository_PetGetBranch(Repository *r, Project *p, const char *bName) {
     
-	SDR_stream* net_stream;
-	char *net_buf;
-	char *rawReply;
-	unsigned int incoming;
 	ServerStringArgument *ser_bName;
 	Branch *retBranch;
-	
-	ServerRequest *sr;
-	ServerReply *sreply;
+	ServerReply *reply;
+	ServerRequest *sr = request_create(PETGETBRANCH, r->uri->path, 
+		                           r->uri->username, PCMS_OPCODE_PETGETBRANCH);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -764,47 +428,20 @@
 	if (p == NULL)
 	    return NULL;
 
-	net_stream = stream_openstring(STREAM_XML);
-
-	sr = request_create(PETGETBRANCH, r->uri->path, r->uri->username, PCMS_OPCODE_PETGETBRANCH);
 	ser_bName = serverarg_create(bName);
 
 	/* Now add the Project and branch pet name as arguments to this request: */
 	serverrequest_AddArgument(sr, p);
 	serverrequest_AddArgument(sr, ser_bName);
 
-	/* Now serialize the request into an XML stream: */
-	sdr_write (SERVERREQUEST, net_stream, sr);
-	
-	/* Convert XML stream to char* to send over wire: */
-	net_buf = (char *)net_stream->data;
-	stream_close(net_stream);
+	reply = (ServerReply *)(invoke_server(r,sr));
 
-	/* Now send the data over the socket: */
-	sendBuff(*(r->connfd), net_buf);
-
-	/* Wait for the response: */
-	read (*(r->connfd), &incoming, sizeof(incoming));
-
-	if (incoming > 0) {
-	    /* Allocate just enough space for server's reply: */
-	    rawReply = (char *)pcms_malloc(incoming);
-	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-
-	    /* Create SDR stream to allow easy deserialization of reply: */
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY, net_stream);
-
-	    /* We need the Branch to come back in the reply so we can
-	       update the 'serTrueName' field: */
-	    retBranch = (Branch *)(vec_fetch(sreply->return_objs,0)); 
-	    return retBranch;
-
-	} /* end if incoming > 0 */
-    
-    return NULL;
+	/* We need the Branch to come back in the reply so we can
+	   update the 'serTrueName' field: */
+	retBranch = (Branch *)(vec_fetch(reply->return_objs,0)); 
+	return retBranch;
 
-} /* end netrepository_PetGetBranch
+} /* end netrepository_PetGetBranch */
 
 /*
  * Update the Branch object in support of a Commit operation.  The
@@ -814,16 +451,12 @@
  * (Note the Repository object is not Serializable, so we just pass the
  * path field up the stream.)
  */
-  int 
+int 
 netrepository_ReviseBranch(Repository *r, Project *p, Branch *b) {
     
-	SDR_stream* net_stream;
-	char *net_buf;
-	char *rawReply;
-	unsigned int incoming;
-	
-	ServerRequest *sr;
-	ServerReply *sreply;
+	ServerReply *reply;
+	ServerRequest *sr = request_create(REVISEBRANCH, r->uri->path, 
+		                           r->uri->username, PCMS_OPCODE_REVISEBRANCH);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -838,146 +471,58 @@
 	if (b == NULL)
 	    return -1;
 
-	net_stream = stream_openstring(STREAM_XML);
-
-	sr = request_create(REVISEBRANCH, r->uri->path, r->uri->username, PCMS_OPCODE_REVISEBRANCH);
-
 	/* Now add the Project as an argument to this request: */
 	serverrequest_AddArgument(sr, p);
 
 	/* Now add the Branch as an argument to this request: */
 	serverrequest_AddArgument(sr, b);
-
-	/* Now serialize the request into an XML stream: */
-	sdr_write (SERVERREQUEST, net_stream, sr);
-	
-	/* Convert XML stream to char* to send over wire: */
-	net_buf = (char *)net_stream->data;
-	stream_close(net_stream);
-
-	/* Now send the data over the socket: */
-	sendBuff(*(r->connfd), net_buf);
-
-	/* Wait for the response: */
-	read (*(r->connfd), &incoming, sizeof(incoming));
-
-	if (incoming > 0) {
-	    /* Allocate just enough space for server's reply: */
-	    rawReply = (char *)pcms_malloc(incoming);
-	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
 
-	    /* Create SDR stream to allow easy deserialization of reply: */
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY, net_stream);
+	reply = (ServerReply *)(invoke_server(r,sr));
+	report(reply->data);
 
-	    report(sreply->data);
-	    return 0;
-	} else {
-	    report ("Invalid Server Reply.\n");
-	    return -1;
-	} /* end if incoming > 0 */
+	return 0;
 
-    return 0;
 } /* end netrepository_ReviseBranch */
 
-  StrVec * 
+StrVec * 
 netrepository_ListBranchPetNames(Repository *r, Branch *b, const char *pName) {
     
-    SDR_stream* net_stream;
-    char *net_buf;
-    char *rawReply;
-    unsigned int incoming;
     StrVec *retStrVec;
-    
-    ServerRequest *sr;
-    ServerReply *sreply;
-
-    net_stream = stream_openstring(STREAM_XML);
+    ServerReply *reply;
+    ServerRequest *sr = request_create(LISTBRANCHPETNAMES, r->uri->path, 
+	                               r->uri->username, PCMS_OPCODE_LISTBRANCHPETNAMES);
 
-    sr = request_create(LISTBRANCHPETNAMES, r->uri->path, r->uri->username, PCMS_OPCODE_LISTBRANCHPETNAMES);
-
     /* Now add the Branch as an argument to this request: */
     serverrequest_AddArgument(sr, b);
     serverrequest_AddArgument(sr, serverarg_create(pName));
 
-    /* Now serialize the request into an XML stream: */
-    sdr_write (SERVERREQUEST, net_stream, sr);
-    
-    /* Convert XML stream to char* to send over wire: */
-    net_buf = (char *)net_stream->data;
-    stream_close(net_stream);
-
-    /* Now send the data over the socket: */
-    sendBuff(*(r->connfd), net_buf);
-
-    /* Wait for the response: */
-    read (*(r->connfd), &incoming, sizeof(incoming));
-
-    if (incoming > 0) {
-	rawReply = (char *)pcms_malloc(incoming);
-	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	sreply = sdr_read(SERVERREPLY, net_stream);
-	
-	/* Retrieve StrVec object from the reply in order to
-	   update the Branch serTrueName field */
-	retStrVec = (StrVec *)(vec_fetch(sreply->return_objs,0)); 
-
-    } else {
-	report("Invalid Server Reply.\n");
-	retStrVec = NULL;
-    } /* end if-else incoming > 0 */
+    reply = (ServerReply *)(invoke_server(r,sr));
+	
+    /* Retrieve StrVec object from the reply in order to
+       update the Branch serTrueName field */
+    retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
 
     return retStrVec;
+
 } /* end netrepository_ListBranchPetNames */
 
-  StrVec *
+StrVec *
 netrepository_ListBranches(Repository *r, Project *p) {
     
-    SDR_stream* net_stream;
-    char *net_buf;
-    char *rawReply;
-    unsigned int incoming;
     StrVec *retStrVec;
-    
-    ServerRequest *sr;
-    ServerReply *sreply;
+    ServerReply *reply;
+    ServerRequest *sr = request_create(LISTBRANCHES, r->uri->path, 
+	                               r->uri->username, PCMS_OPCODE_LISTBRANCHES);
 
-    net_stream = stream_openstring(STREAM_XML);
-
-    sr = request_create(LISTBRANCHES, r->uri->path, r->uri->username, PCMS_OPCODE_LISTBRANCHES);
-
     /* Now add the Project as an argument to this request: */
     serverrequest_AddArgument(sr, p);
 
-    /* Now serialize the request into an XML stream: */
-    sdr_write (SERVERREQUEST, net_stream, sr);
-    
-    /* Convert XML stream to char* to send over wire: */
-    net_buf = (char *)net_stream->data;
-    stream_close(net_stream);
-
-    /* Now send the data over the socket: */
-    sendBuff(*(r->connfd), net_buf);
-
-    /* Wait for the response: */
-    read (*(r->connfd), &incoming, sizeof(incoming));
-
-    if (incoming > 0) {
-	rawReply = (char *)pcms_malloc(incoming);
-	rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	sreply = sdr_read(SERVERREPLY, net_stream);
-	
-	/* Retrieve StrVec object from the reply in order to
-	   update the Branch serTrueName field */
-	retStrVec = (StrVec *)(vec_fetch(sreply->return_objs,0)); 
-
-	report(sreply->data);
-    } else {
-	report("Invalid Server Reply.\n");
-	retStrVec = NULL;
-    } /* end if-else incoming > 0 */
+    reply = (ServerReply *)(invoke_server(r,sr));
+	
+    /* Retrieve StrVec object from the reply in order to
+       update the Branch serTrueName field */
+    retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
+    report(reply->data);
 
     return retStrVec;
 } /* end netrepository_ListBranches */
@@ -986,13 +531,9 @@
 netrepository_ReviseEntity(Repository *r,
 			    const char *tName, void *serobject) { 
     
-	SDR_stream* net_stream;
-	char *net_buf;
-	char *rawReply;
-	unsigned int incoming;
-	
-	ServerRequest *sr;
-	ServerReply *sreply;
+	ServerReply *reply;
+	ServerRequest *sr = request_create(REVISEENTITY, r->uri->path, 
+		                           r->uri->username, PCMS_OPCODE_REVISEENTITY);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -1003,44 +544,15 @@
 
 	if (serobject == NULL)
 	    return NULL;
-
-	net_stream = stream_openstring(STREAM_XML);
-
-	sr = request_create(REVISEENTITY, r->uri->path, r->uri->username, PCMS_OPCODE_REVISEENTITY);
  
 	/* Now add the incoming Serializable object as an argument to this request: */
 	serverrequest_AddArgument(sr, serobject);
-
-	/* Now serialize the request into an XML stream: */
-	sdr_write (SERVERREQUEST, net_stream, sr);
-	
-	/* Convert XML stream to char* to send over wire: */
-	net_buf = (char *)net_stream->data;
-	stream_close(net_stream);
-
-	/* Now send the data over the socket: */
-	sendBuff(*(r->connfd), net_buf);
-
-	/* Wait for the response: */
-	read (*(r->connfd), &incoming, sizeof(incoming));
-
-	if (incoming > 0) {
-
-	    /* Allocate just enough space for server's reply: */
-	    rawReply = (char *)pcms_malloc(incoming);
-	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-
-	    /* Create SDR stream to allow easy deserialization of reply: */
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY, net_stream);
-
-	    /* We need the True Name to come back in the reply so we can
-	       update the 'serTrueName' field: */
-	    return sreply->data;
 
-	} /* end incoming > 0 */
+	reply = (ServerReply *)(invoke_server(r,sr));
 
-    return NULL; 
+	/* We need the True Name to come back in the reply so we can
+	   update the 'serTrueName' field: */
+	return reply->data;
 
 } /* end netrepository_ReviseEntity */
 
@@ -1052,15 +564,11 @@
 netrepository_GetEntity(Repository *r,
 			 const char *tName) {
     
-	SDR_stream* net_stream;
-	char *net_buf;
-	char *rawReply;
-	unsigned int incoming;
 	ServerStringArgument *ser_tName;
 	Serializable *retEnt;
-	
-	ServerRequest *sr;
-	ServerReply *sreply;
+	ServerReply *reply;
+	ServerRequest *sr = request_create(GETENTITY, r->uri->path, 
+		                           r->uri->username, PCMS_OPCODE_GETENTITY);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -1072,57 +580,30 @@
 	if (tName == NULL)
 	    return NULL;
 
-	net_stream = stream_openstring(STREAM_XML);
-
-	sr = request_create(GETENTITY, r->uri->path, r->uri->username, PCMS_OPCODE_GETENTITY);
 	ser_tName = serverarg_create(tName);
 
 	/* Now add the true name of the Project as an argument to this request: */
 	serverrequest_AddArgument(sr, ser_tName);
-
-	/* Now serialize the request into an XML stream: */
-	sdr_write (SERVERREQUEST, net_stream, sr);
-	
-	/* Convert XML stream to char* to send over wire: */
-	net_buf = (char *)net_stream->data;
-	stream_close(net_stream);
 
-	/* Now send the data over the socket: */
-	sendBuff(*(r->connfd), net_buf);
+	reply = (ServerReply *)(invoke_server(r,sr));
 
-	/* Wait for the response: */
-	read (*(r->connfd), &incoming, sizeof(incoming));
-
-	if (incoming > 0) {
-	    /* Allocate just enough space for server's reply: */
-	    rawReply = (char *)pcms_malloc(incoming);
-	    rawReply = read_entire_msg_from_socket(*(r->connfd), incoming);
-
-	    /* Create SDR stream to allow easy deserialization of reply: */
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY, net_stream);
-
-	    /* retrieve the Entity/Change object from the reply: */
-	    retEnt = (Serializable *)(vec_fetch(sreply->return_objs,0)); 
+	/* retrieve the Entity/Change object from the reply: */
+	retEnt = (Serializable *)(vec_fetch(reply->return_objs,0)); 
 	    
-	    /* This next step is VERY IMPORTANT:  Realize that the entity
-	     * we're retrieving here can be an Entity or a Change object
-	     * (and others?) that do NOT serialize they're true name.  This
-	     * is because the true name is essentially the file name of the
-	     * entity and the entity itself doesn't need to store that.  Thus,
-	     * right before we send this entity back over the wire, we need
-	     * to set its true name accordingly.  Note that its true name
-	     * came as an input parameter to this function, so that makes it
-	     * easy.
-             */
-	    retEnt->ser_trueName = tName;
+	/* This next step is VERY IMPORTANT:  Realize that the entity
+	 * we're retrieving here can be an Entity or a Change object
+	 * (and others?) that do NOT serialize they're true name.  This
+	 * is because the true name is essentially the file name of the
+	 * entity and the entity itself doesn't need to store that.  Thus,
+	 * right before we send this entity back over the wire, we need
+	 * to set its true name accordingly.  Note that its true name
+	 * came as an input parameter to this function, so that makes it
+	 * easy.
+	 */
+	retEnt->ser_trueName = tName;
 
-	    return retEnt;
+	return retEnt;
 
-	} /* end if incoming > 0 */
-
-    return NULL;
-
 } /* end netrepository_GetEntity */
 
 void netrepository_init(Repository * r) {
@@ -1156,8 +637,7 @@
   r->GetEntity = netrepository_GetEntity;
 
   r->cache = NULL;
-  r->connfd = NULL;
-
+  r->channel = (Channel *)pcms_malloc(sizeof(Channel));
 }
 
 /*
@@ -1194,4 +674,39 @@
     return entire_msg;
 
 } /* end read_entire_msg_from_socket */
+
+Serializable * invoke_server (Repository *r, ServerRequest *request) {
+
+	SDR_stream* net_stream;
+	char *net_buf;
+	char *rawReply;
+	unsigned int incoming;
+	ServerReply *sreply;
+	
+	net_stream = stream_openstring(STREAM_XML);
+
+	/* Now serialize the request into an XML stream: */
+	sdr_write (SERVERREQUEST, net_stream, request);
+	
+	/* Convert XML stream to char* to send over wire: */
+	net_buf = (char *)net_stream->data;
+	stream_close(net_stream);
+
+	/* Now send the data over the socket: */
+	sendBuff(r->channel->sockfd, net_buf);
+
+	/* Wait for the response: */
+	read (r->channel->sockfd, &incoming, sizeof(incoming));
+
+	if (incoming > 0) {
+	    rawReply = (char *)pcms_malloc(incoming);
+
+	    rawReply = read_entire_msg_from_socket(r->channel->sockfd, incoming);
+
+	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	    sreply = sdr_read(SERVERREPLY, net_stream);
+	} /* end if incoming > 0 */
+	
+	return (Serializable *)sreply;
+} /* end invoke_Server */
 



1.6       +1 -0      pcms/src/repos/net/NetRepository.h

Index: NetRepository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NetRepository.h	2001/11/16 18:02:02	1.5
+++ NetRepository.h	2001/11/20 23:34:45	1.6
@@ -1,4 +1,5 @@
 /* Copyright (C) 2000, The EROS Group, LLC. */
+
 int
 netrepository_CreateRepository(Repository *);
 



1.11      +11 -616   pcms/src/server/pcmsserver.c

Index: pcmsserver.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/pcmsserver.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- pcmsserver.c	2001/11/16 18:02:02	1.10
+++ pcmsserver.c	2001/11/20 23:34:45	1.11
@@ -13,11 +13,9 @@
 #define SIZEOFREQUESTQUEUE 100
 
 void quitter(int);
-void open_local_repos_if_needed(char *);
+extern ServerReply *dispatch_request(ServerRequest *);
 
 int quit;
-Repository *localRepos = NULL;
-char *storeReposURI = NULL;
 
 /****************************************************
 * M A I N   processing loop.
@@ -64,7 +62,7 @@
 unsigned int code;
 URI *localURI;
 char *localURIstr;
-const char *retVersion;
+const char *raw_reply;
 ServerReply *reply;
 SDR_stream *reply_strm;
 unsigned int len;
@@ -73,14 +71,6 @@
 int max_index_into_clients;
 int max_sockfd_so_far;
 char *tooManyClients = "Connection refused... too many clients.";
-Project *proj_arg;
-Branch *branch_arg;
-StrVec *proj_list;
-StrVec *branch_list;
-ServerStringArgument *string_arg;
-ServerStringArgument *string_arg2;
-void *ent_arg;
-void *ser_arg;
 
 	quit_action.sa_handler = (&quitter);
 	
@@ -96,7 +86,7 @@
 		fprintf(stderr, "Socket Creation Error\n");
 		exit(errno);
 	}
-/* try non-blocking I/O: */
+/* Need non-blocking I/O for the sockets created by accept: */
 	/***
 val = fcntl(servfd, F_GETFL, 0);
 fcntl(servfd, F_SETFL, val | O_NONBLOCK);
@@ -237,12 +227,15 @@
 			    if (FD_ISSET(thisReply->sockfd, &outgoingset)) {
 				reply_strm = stream_openstring(STREAM_XML);
 				sdr_write(SERVERREPLY, reply_strm, thisReply);
-				retVersion = (char *)reply_strm->data;
-				len = strlen(retVersion);
+				raw_reply = (char *)reply_strm->data;
+				len = strlen(raw_reply);
 				write (thisReply->sockfd, &len, sizeof(len));  
-				write (thisReply->sockfd, retVersion, len);
+				write (thisReply->sockfd, raw_reply, len);
 				stream_close(reply_strm);
 				FD_CLR(thisReply->sockfd, &writeholder);
+
+				/* free the thisReply memory here? */
+
 			    } /* end if FD_ISSET */
 
 			} /* end while not IsEmptyMsgQueue(writeq) */
@@ -254,575 +247,8 @@
 		     ***********************************************/
 		    while (!IsEmptyMsgQueue(readq)) {
 			thisRequest = (ServerRequest *)GetFromMsgQueue(readq);
-			switch (thisRequest->opcode) {
-
-			    /*******************************************
-			     *   CREATE A REPOSITORY:
-			     *******************************************/
-			    case PCMS_OPCODE_CREATEREPOSITORY:
-
-				/* Idea is that repos should be a file repository on this
-				*  server, so instantiate a FileRepos object for this command:
-				*/
-				open_local_repos_if_needed(nextRequest->repos_path);
-				
-				/* Now create a repository just like the File Repository: */
-				if (localRepos->CreateRepository(localRepos) == 0)
-				    reply = reply_create("Success.\n", thisRequest->sockfd);
-				else
-				    reply = reply_create("Error.\n", thisRequest->sockfd);
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				break;
-
-			    /*******************************************
-			     *   GET THE VERSION OF THIS SERVER:
-			     *******************************************/
-			    case PCMS_OPCODE_GETVERSION:
-
-				/* Idea is that repos should be a file repository on this
-				*  server, so instantiate a FileRepos object for this command:
-				*/
-				open_local_repos_if_needed(nextRequest->repos_path);
-
-				/* Now use the local file repository to get the version
-				*  and write that back to the client via its socket:
-				*/
-				reply = reply_create(localRepos->GetVersion(localRepos), thisRequest->sockfd);
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				break;
-
-			    /*******************************************
-			     *   CREATE A BRANCH:
-			     *******************************************/
-			    case PCMS_OPCODE_CREATEBRANCH:
-
-				/* Idea is that repos should be a file repository on this
-				*  server, so instantiate a FileRepos object for this command:
-				*/
-				open_local_repos_if_needed(nextRequest->repos_path);
-				
-				/* This command requires a Project object and
-				   a Branch object as arguments.  */
-				if (vec_size(thisRequest->args) > 0) {
-				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
-
-				    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 1));
-
-				    /* Now just do what the File Repository object would do: */
-				    localRepos->CreateBranch(localRepos, proj_arg, branch_arg);
-
-				    reply = reply_create("Success: Branch Created.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, branch_arg);
-				} else {
-				    reply = reply_create("Error creating Branch.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, branch_arg);
-				} /* end if checking if arguments are present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-				break;
-
-			    /*******************************************
-			     *   CREATE A PROJECT:
-			     *******************************************/
-			    case PCMS_OPCODE_CREATEPROJECT:
-
-				/* Idea is that repos should be a file repository on this
-				*  server, so instantiate a FileRepos object for this command:
-				*/
-				open_local_repos_if_needed(nextRequest->repos_path);
-				
-				/* This command requires a Project object as an argument.
-				*  Make sure the argument is available
-				*/
-				if (vec_size(thisRequest->args) > 0) {
-				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
-
-				    /* Now just do what the File Repository object would do: */
-				    localRepos->CreateProject(localRepos, proj_arg);
-
-				    reply = reply_create("Success: Project created.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, proj_arg);
-
-				} else {
-				    reply = reply_create("Error creating Project.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, proj_arg);
-				} /* end if checking if argument is present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-				break;
-
-			    /**********************************************************
-			     *   GET A PROJECT BASED ON TRUE NAME PASSED AS PARAMETER:
-			     **********************************************************/
-			    case PCMS_OPCODE_GETPROJECT:
-
-				/* Idea is that repos should be a file repository on this
-				*  server, so instantiate a FileRepos object for this command:
-				*/
-				open_local_repos_if_needed(nextRequest->repos_path);
-				
-				/* This command requires a ServerStringArgument object as an argument.
-				*  Make sure the argument is available
-				*/
-				if (vec_size(thisRequest->args) > 0) {
-				    /* The ServerStringArgument that's part of this request contains
-				     * the trueName of the project that needs to be retrieved:
-				     */
-				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
-
-				    /* Now just do what the File Repository object would do: */
-				    proj_arg = localRepos->GetProject(localRepos, string_arg->data);
-
-				    reply = reply_create("Success: Project retrieved.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, proj_arg);
-
-				} else {
-				    reply = reply_create("Error retrieving Project.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, proj_arg);
-				} /* end if checking if argument is present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-				break;
-
-			    /**********************************************************
-			     *   GET A BRANCH BASED ON TRUE NAME PASSED AS PARAMETER:
-			     **********************************************************/
-			    case PCMS_OPCODE_GETBRANCH:
-
-				/* Idea is that repos should be a file repository on this
-				*  server, so instantiate a FileRepos object for this command:
-				*/
-				open_local_repos_if_needed(nextRequest->repos_path);
-				
-				/* This command requires a ServerStringArgument object as an argument.
-				*  Make sure the argument is available
-				*/
-				if (vec_size(thisRequest->args) > 0) {
-
-				    /*
-				     * First argument should be the Project object:
-				     */
-				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
-
-				    /* The ServerStringArgument that's part of this request contains
-				     * the trueName of the branch that needs to be retrieved:
-				     */
-				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
-
-				    /* Now just do what the File Repository object would do: */
-				    branch_arg = localRepos->GetBranch(localRepos, proj_arg, string_arg->data);
-
-				    reply = reply_create("Success: Branch retrieved.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, branch_arg);
-
-				} else {
-				    reply = reply_create("Error retrieving Branch.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, branch_arg);
-				} /* end if checking if argument is present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-
-				break;
-
-			    /**********************************************************
-			     *   REVISE A BRANCH (IN SUPPORT OF COMMIT COMMAND):
-			     **********************************************************/
-			    case PCMS_OPCODE_REVISEBRANCH:
-
-				/* Idea is that repos should be a file repository on this
-				*  server, so instantiate a FileRepos object for this command:
-				*/
-				open_local_repos_if_needed(nextRequest->repos_path);
-				
-				/* This command requires Project and Branch objects as arguments.
-				 * Make sure the arguments are available:
-				 */
-				if (vec_size(thisRequest->args) > 0) {
-
-				    /* First argument should be the Project object: */
-				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
-
-				    /* The Branch object should be next: */
-				    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 1));
-
-				    /* Now just do what the File Repository object would do: */
-				    localRepos->ReviseBranch(localRepos, proj_arg, branch_arg);
-
-				    reply = reply_create("Success: Branch updated.\n", thisRequest->sockfd);
-
-				} else {
-				    reply = reply_create("Error updating Branch.\n", thisRequest->sockfd);
-				} /* end if checking if argument is present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-
-				break;
-
-			    /**********************************************************
-			     *   RETURN AN ENTITY (IN SUPPORT OF UPDATE COMMAND):
-			     **********************************************************/
-			    case PCMS_OPCODE_GETENTITY:
-
-				/* Idea is that repos should be a file repository on this
-				*  server, so instantiate a FileRepos object for this command:
-				*/
-				open_local_repos_if_needed(nextRequest->repos_path);
-				
-				/* This command requires a ServerStringArgument object as an argument.
-				*  Make sure the argument is available
-				*/
-				if (vec_size(thisRequest->args) > 0) {
-				    /* The ServerStringArgument that's part of this request contains
-				     * the trueName of the entity that needs to be retrieved:
-				     */
-				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
-
-				    /* Now just do what the File Repository object would do: */
-				    ent_arg = localRepos->GetEntity(localRepos, string_arg->data);
-				    
-				    reply = reply_create("Success: Entity retrieved.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, ent_arg);
-
-				} else {
-				    reply = reply_create("Error retrieving Entity.\n", thisRequest->sockfd);
-				} /* end if checking if argument is present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-
-				break;
-
-			    /**********************************************************
-			     *   REVISE AN ENTITY (IN SUPPORT OF COMMIT COMMAND):
-			     **********************************************************/
-			    case PCMS_OPCODE_REVISEENTITY:
-
-				/* Idea is that repos should be a file repository on this
-				*  server, so instantiate a FileRepos object for this command:
-				*/
-				open_local_repos_if_needed(nextRequest->repos_path);
-				
-				/* This command requires a ServerStringArgument object as an argument.
-				*  Make sure the argument is available
-				*/
-				if (vec_size(thisRequest->args) > 0) {
-				    /* The Serializable object that's part of this request contains
-				     * the info for the entity that needs to be revised:
-				     */
-				    ser_arg = (void *)(vec_fetch(thisRequest->args, 0));
-
-				    /* Now just do what the File Repository object would do: */
-				    reply = reply_create(localRepos->ReviseEntity(localRepos, 0, ser_arg), thisRequest->sockfd);
-
-				} else {
-				    reply = reply_create("Error revising Entity.\n", thisRequest->sockfd);
-				} /* end if checking if argument is present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-
-				break;
-
-			    /**********************************************************
-			     *   GET A BRANCH BASED ON PET NAME PASSED AS PARAMETER:
-			     **********************************************************/
-			    case PCMS_OPCODE_PETGETBRANCH:
-
-				open_local_repos_if_needed(nextRequest->repos_path);
-				
-				/* This command requires two arguments: */
-				if (vec_size(thisRequest->args) > 0) {
-
-				    /* The ServerStringArgument that's part of this request contains
-				     * the pet name of the project that needs to be retrieved:
-				     */
-				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
-				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
-
-				    /* Now just do what the File Repository object would do: */
-				    branch_arg = localRepos->PetGetBranch(localRepos, proj_arg, string_arg->data);
-
-				    reply = reply_create("Success: Branch retrieved.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, branch_arg);
-
-				} else {
-				    reply = reply_create("Error retrieving Branch:(not enough arguments)\n", thisRequest->sockfd);
-				} /* end if checking if argument is present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-
-				break;
-
-			    /**********************************************************
-			     *   GET A PROJECT BASED ON PET NAME PASSED AS PARAMETER:
-			     **********************************************************/
-			    case PCMS_OPCODE_PETGETPROJECT:
-
-				open_local_repos_if_needed(nextRequest->repos_path);
-				
-				/* This command requires a ServerStringArgument object as an argument.
-				*  Make sure the argument is available
-				*/
-				if (vec_size(thisRequest->args) > 0) {
-				    /* The ServerStringArgument that's part of this request contains
-				     * the pet name of the project that needs to be retrieved:
-				     */
-				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
-
-				    /* Now just do what the File Repository object would do: */
-				    proj_arg = localRepos->PetGetProject(localRepos, string_arg->data);
-
-				    reply = reply_create("Success: Project retrieved.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, proj_arg);
-
-				} else {
-				    reply = reply_create("Error retrieving Project.\n", thisRequest->sockfd);
-				} /* end if checking if argument is present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-
-				break;
-				
-			    /**********************************************************************
-			     * RENAME A BRANCH:  NEEDS PROJECT, CURRENT NAME, NEW NAME AS ARGUMENTS:
-			     *********************************************************************/
-			    case PCMS_OPCODE_RENAMEBRANCH:
-
-				open_local_repos_if_needed(nextRequest->repos_path);
-
-				/* This command requires several objects as arguments. */
-				if (vec_size(thisRequest->args) > 0) {
-				    
-				    /* First is the Project of interest: */
-				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
-
-				    /* Second is the old name of the branch: */
-				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
-
-				    /* Second is the new name of the branch: */
-				    string_arg2 = (ServerStringArgument *)(vec_fetch(thisRequest->args, 2));
-
-				    /* Now just do what the File Repository object would do: */
-				    if (localRepos->PetRenameBranch (localRepos, proj_arg, string_arg->data, string_arg2->data) == -1)
-					reply = reply_create("Error renaming branch.\n", thisRequest->sockfd);
-				    else
-					reply = reply_create("Success: Branch renamed.\n", thisRequest->sockfd);
-
-				} else {
-				    reply = reply_create("Error renaming branch (Not enough arguments).\n", thisRequest->sockfd);
-				} /* end if checking if argument is present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-
-				break;
-
-			    /**********************************************************************
-			     * RENAME A PROJECT:  NEEDS CURRENT NAME, NEW NAME AS ARGUMENTS:
-			     *********************************************************************/
-			    case PCMS_OPCODE_RENAMEPROJECT:
-
-				open_local_repos_if_needed(nextRequest->repos_path);
-
-				/* This command requires several objects as arguments. */
-				if (vec_size(thisRequest->args) > 0) {
-				    
-				    /* First is the old name of the project: */
-				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));
-
-				    /* Second is the new name of the project: */
-				    string_arg2 = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
-
-				    /* Now just do what the File Repository object would do: */
-				    if (localRepos->PetRenameProject (localRepos, string_arg->data, string_arg2->data) == -1)
-					reply = reply_create("Error renaming Project:(name already exists).\n", thisRequest->sockfd);
-				    else
-					reply = reply_create("Success: Project renamed.\n", thisRequest->sockfd);
-
-				} else {
-				    reply = reply_create("Error renaming Project:(not enough arguments).\n", thisRequest->sockfd);
-				} /* end if checking if argument is present */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				thisRequest = NULL;
-
-				break;
-
-			    /*********************************************************
-			     * GENERATE A LIST OF ALL BRANCHES FOR A GIVEN PROJECT:
-			     ********************************************************/
-			    case PCMS_OPCODE_LISTBRANCHES:
-
-				open_local_repos_if_needed(nextRequest->repos_path);
-
-				/* This command requires a Project argument. */
-				if (vec_size(thisRequest->args) > 0) {
-				    
-				    /* First is the Project of interest: */
-				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
-
-				    /* Now just do what the File Repository object would do: */
-				    branch_list = NULL;
-				    branch_list = localRepos->ListBranches(localRepos, proj_arg);
-				    if (branch_list == NULL)
-					reply = reply_create("Error accessing Branch.\n", thisRequest->sockfd);
-				    else {
-					reply = reply_create("Success: Branches retrieved.\n", thisRequest->sockfd);
-					serverreply_AddArgument(reply, branch_list);
-				    } /* end if branch_list == NULL*/
-				} else {
-				    reply = reply_create("Error accessing Branch:(no Project specified as argument.)\n", thisRequest->sockfd);
-				} /* end if-else vec_size() > 0 */
-
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				break;
-
-			    /*********************************************************
-			     * GENERATE A LIST OF PET NAMES FOR A GIVEN BRANCH:
-			     ********************************************************/
-			    case PCMS_OPCODE_LISTBRANCHPETNAMES:
-
-				open_local_repos_if_needed(nextRequest->repos_path);
-
-				/* This command requires a Branch argument. */
-				if (vec_size(thisRequest->args) > 0) {
-				    
-				    /* First is the Project of interest: */
-				    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 0));
-
-				    /* Next is the true name of the Branch's Project: */
-				    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));
-
-				    /* Now just do what the File Repository object would do: */
-				    branch_list = NULL;
-				    branch_list = localRepos->ListBranchPetNames(localRepos, branch_arg, string_arg->data);
-				    if (branch_list == NULL)
-					reply = reply_create("Error retrieving nickname of Branch.\n", thisRequest->sockfd);
-				    else {
-					reply = reply_create("Success: Branch nickname retrieved.\n", thisRequest->sockfd);
-					serverreply_AddArgument(reply, branch_list);
-				    } /* end if branch_list == NULL*/
-				} else {
-				    reply = reply_create("Error retrieving nickname:(no Branch specified as argument.)\n", thisRequest->sockfd);
-				} /* end if-else vec_size() > 0 */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				break;
-
-			    /*********************************************************
-			     * GENERATE A LIST OF ALL PROJECTS FOR A GIVEN REPOSITORY:
-			     ********************************************************/
-			    case PCMS_OPCODE_LISTPROJECTS:
-
-				open_local_repos_if_needed(nextRequest->repos_path);
-
-				/* Now just do what the File Repository object would do: */
-				proj_list = NULL;
-				proj_list = localRepos->ListProjects(localRepos);
-				if (proj_list == NULL)
-				    reply = reply_create("Error trying to list Projects.\n", thisRequest->sockfd);
-				else {
-				    reply = reply_create("Success: Projects retrieved.\n", thisRequest->sockfd);
-				    serverreply_AddArgument(reply, proj_list);
-				} /* end if proj_list == NULL*/
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				break;
-
-			    /*********************************************************
-			     * GENERATE A LIST OF PET NAMES FOR A GIVEN PROJECT:
-			     ********************************************************/
-			    case PCMS_OPCODE_LISTPROJPETNAMES:
-
-				open_local_repos_if_needed(nextRequest->repos_path);
-
-				/* This command requires a Project argument. */
-				if (vec_size(thisRequest->args) > 0) {
-				    
-				    /* First is the Project of interest: */
-				    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
-
-				    /* Now just do what the File Repository object would do: */
-				    proj_list = NULL;
-				    proj_list = localRepos->ListProjPetNames(localRepos, proj_arg);
-				    if (proj_list == NULL)
-					reply = reply_create("Error trying to list Projects.\n", thisRequest->sockfd);
-				    else {
-					reply = reply_create("Success: Project pet names retrieved.\n", thisRequest->sockfd);
-					serverreply_AddArgument(reply, proj_list);
-				    } /* end if proj_list == NULL*/
-				} else {
-				    reply = reply_create("Error retrieving nickname:(no Project specified as argument.)\n", thisRequest->sockfd);
-				} /* end if-else vec_size() > 0 */
-
-				/* Add this reply to the write queue: */
-				AddToMsgQueue(writeq, reply);
-				FD_SET(reply->sockfd, &writeholder);
-
-				break;
-
-			    default:
-				break;
-			} /* end switch block */
-
+			AddToMsgQueue(writeq, dispatch_request(thisRequest));
+			FD_SET(thisRequest->sockfd, &writeholder);
 		    } /* end while not IsEmptyMsgQueue */
 
 	}  /* end while !quit */
@@ -832,38 +258,7 @@
 	return 0;
 }
 
-								
-							
 void quitter(int dummy) {
 	quit = 1;
 }
-
-/*
- * Trying to reduce amount of work on the server-side:  only create/open
- * a local file repository if the one we currently have is not the one
- * the user needs. (We're using a cached file repository for efficiency.)
- */
-void open_local_repos_if_needed(char *path) {
-
-    char *localURIstr = (char *)pcms_malloc(strlen(path) + 5);
-
-    localURIstr = xstrndup("file:",5);
-    localURIstr = xstrcat(localURIstr, path);
-
-    /* First check if local repository already exists: */
-    if (localRepos == NULL) {
-	localRepos = (Repository *)pcms_malloc(sizeof(Repository));
-	localRepos = repository_open(localURIstr, 0);
-	cachedfilerepository_init(localRepos);
-	storeReposURI = xstrdup(localURIstr);
-    /* If so, check if it points to one user wants: */
-    } else if (!nmequal(storeReposURI, localURIstr)) {
-	localRepos = (Repository *)pcms_malloc(sizeof(Repository));
-	localRepos = repository_open(localURIstr, 0);
-	cachedfilerepository_init(localRepos);
-	storeReposURI = xstrdup(localURIstr);
-    } /* end if-then-else */
-
-} /* end open_local_repository */
-
 




From shap@snocrash.cs.jhu.edu Wed Nov 21 16:59:00 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fALLx0V26450
	for <dcms-cvs@eros.cs.jhu.edu>; Wed, 21 Nov 2001 16:59:00 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id RAA00830;
	Wed, 21 Nov 2001 17:42:10 -0500
Received: (from shap@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fALLtCL28953;
	Wed, 21 Nov 2001 16:55:12 -0500
Date: Wed, 21 Nov 2001 16:55:12 -0500
From: "Jonathan S. Shapiro" <shap@snocrash.cs.jhu.edu>
Message-Id: <200111212155.fALLtCL28953@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common smsmalloc.c smsmalloc.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

shap        01/11/21 16:55:12

  Modified:    src/common smsmalloc.c smsmalloc.h
  Log:
  SMS now does conservative collection.
  
  Objects will be kept around as long as their pool remains
  live. Whenever there is an external pointer into a pool, use
  sms_incref() to indicate this. If object A in pool P has a non-zero
  reference count, then all objects B in pool P that are (transitively)
  reachable from A (considering only objects in pool P) will be
  retained.
  
  There is currently no advisory free mechanism, and there probably
  should be. A combination of
  
         sms_free(ob)	 // Object should be freed if unreachable from pool
         sms_gc(pool)	 // Nuke advisory freed objects if unreachable
  			    from pool
  
  seems like a good idea.

Revision  Changes    Path
1.3       +169 -36   pcms/src/common/smsmalloc.c

Index: smsmalloc.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/smsmalloc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- smsmalloc.c	2001/11/21 20:58:40	1.2
+++ smsmalloc.c	2001/11/21 21:55:12	1.3
@@ -1,54 +1,107 @@
 /* Copyright (C) 2001, Johns Hopkins University. */
 
-
 #include <malloc.h>
 #include <assert.h>
 
 #define SMS_IMPLEMENTATION
+#define CONSERVATIVE_GC
 
 /* Common header structure that will sit at the front of every object: */
+typedef struct pool pool;
+
 typedef struct obhdr obhdr;
 struct obhdr {
   obhdr *next;
   obhdr *prev;
+  pool  *pPool;
   unsigned refcount;
+#ifdef CONSERVATIVE_GC
+  unsigned mark;
+  size_t sz;
+  unsigned canary;
+#endif
 } ;
-typedef struct obhdr *sms_pool_t;
+
+struct pool {
+  struct obhdr hdr;		/* lame single inheritance */
+  unsigned isLive;		/* 1 iff pool has not been freed */
+  unsigned obcount;		/* number of remaining objects in pool */
+} ;
+
+typedef struct pool *sms_pool_t;
 
 #define HDR(ob) ((obhdr *) (((char *)ob) - sizeof(obhdr)))
-#define LIVEPOOL(hdr) (hdr->next != hdr)
 
 #include "smsmalloc.h"
 
+inline static void 
+sms_inithdr(obhdr * hdr, sms_pool_t pool, size_t sz)
+{
+  hdr->refcount = 0;
+  hdr->next = hdr;
+  hdr->prev = hdr;
+  hdr->pPool = pool;
+#ifdef CONSERVATIVE_GC
+  hdr->sz = sz;
+  hdr->canary = ~((unsigned) hdr);
+#endif
+}
+
+/* Used to keep track of the base and bound of the heap region that
+ * might contain SMS objects. It might, of course, contain other crud
+ * too, but by checking the base/bound we can at least know that the
+ * pointer we are considering points *somewhere* in the valid heap,
+ * and that dereferencing the pointer won't cause a page fault. */
+static char *sms_alloc_base = (char *) ~0u;
+static char *sms_alloc_bound = (char *) 0u;
+
+static void *
+sms_do_malloc(size_t sz)
+{
+  void *v = malloc(sz);
+  char *cv = v;
+  assert(v);
+  bzero(v, sz);
+
+  if ((cv - (char *)0) < (sms_alloc_base - (char *)0))
+    sms_alloc_base = cv;
+
+  if ((cv - (char *)0) > (sms_alloc_bound - (char *)0))
+    sms_alloc_bound = cv;
+
+  return v;
+}
+
 /* sms_mkpool simply returns a "zero-length" object whose header will
  * serve as the pool chain header for the object.
  */
 sms_pool_t 
 sms_mkpool()
 {
-  obhdr *hdr = malloc(sizeof(obhdr));
-  bzero(hdr, sizeof(obhdr));
-  assert(hdr);
+  pool *pPool = sms_do_malloc(sizeof(pool));
 
-  hdr->refcount = 0;
-  hdr->next = hdr;
-  hdr->prev = hdr;
+  sms_inithdr(&pPool->hdr, pPool, sizeof(pool));
+
+  pPool->isLive = 1;
+  pPool->obcount = 0;
 
-  return hdr;
+  return pPool;
 }
 
 void *
 sms_malloc(sms_pool_t pool, size_t sz)
 {
-  obhdr *hdr = malloc(sizeof(obhdr) + sz);
-  bzero(hdr, sizeof(obhdr) + sz);
-  assert(hdr);
+  obhdr *hdr = sms_do_malloc(sizeof(obhdr) + sz);
 
-  hdr->refcount = 0;
-  hdr->prev = pool;
-  hdr->next = pool->next;
-  pool->next->prev = hdr;
-  pool->next = hdr;
+  sms_inithdr(hdr, pool, sizeof(pool));
+
+  /* Link it into the pool: */
+  hdr->prev = &pool->hdr;
+  hdr->next = pool->hdr.next;
+  pool->hdr.next->prev = hdr;
+  pool->hdr.next = hdr;
+
+  pool->obcount++;
 
   return (void *) (((char *)hdr) + sizeof(obhdr));
 }
@@ -57,14 +110,26 @@
 sms_free(void *ob)
 {
   obhdr *hdr = HDR(ob);
+  pool *pPool = hdr->pPool;
 
-  if (LIVEPOOL(hdr)) {
-    /* pool is still alive, so remove this from the pool */
-    hdr->next->prev = hdr->prev;
-    hdr->prev->next = hdr->next;
-  }
+#ifdef CONSERVATIVE_GC
+  assert(hdr->mark == 0);
+#endif
+
+  /* Unlink this object from the pool chain */
+  hdr->next->prev = hdr->prev;
+  hdr->prev->next = hdr->next;
+
+#ifdef CONSERVATIVE_GC
+  /* Zap the canary, so that dangling pointers into this heap object
+   * won't satisfy the sms_valid_ptr() test: */
+  hdr->canary = 0;
+#endif
 
+  /* Release it */
   free(hdr);
+
+  pPool->obcount--;
 }
 
 void 
@@ -78,30 +143,98 @@
 sms_decref(void *ob)
 {
   obhdr *hdr = HDR(ob);
+  sms_pool_t pPool = hdr->pPool;
+
   hdr->refcount--;
 
-  if (hdr->refcount == 0 && !LIVEPOOL(hdr))
+  if (hdr->refcount == 0 && hdr->pPool->isLive == 0)
     sms_free(hdr);
+
+  if (pPool->isLive == 0)
+    sms_release(pPool);
 }
 
-/* sms_bulkfree(pool): Free all objects associated with /pool/ whose
+#ifdef CONSERVATIVE_GC
+inline static int
+sms_valid_ptr(sms_pool_t pool, void *v)
+{
+  obhdr *hdr = HDR(v);
+  char *cv = (char *)v;
+
+  if ((cv - (char *)0) < (sms_alloc_base - (char *)0))
+    return 0;
+
+  if ((cv - (char *)0) > (sms_alloc_bound - (char *)0))
+    return 0;
+
+  if (hdr->pPool != pool)
+    return 0;
+
+  if (hdr->canary != ~(unsigned)hdr)
+    return 0;
+
+  /* It could still be bad, but you would really really have to work
+   * at it. The only way I know to do better than this is to keep a
+   * hash table for live objects allocated by SMS. A secondary problem
+   * is that this code won't validate pointers into the middle of
+   * objects. */
+  return 1;
+}
+
+/* sms_mark() is an implementation of an (overly) conservative
+ * mark/sweep pass. The idea is to iterate through each word of the
+ * object, check if it might be a valid pointer to some object in the
+ * same pool, and if so mark that object as well. */
+static void
+sms_mark(obhdr *hdr)
+{
+  void **ptrs = (void **) (((char *)hdr) + sizeof(obhdr));
+  unsigned maxPtrs = hdr->sz / sizeof(void *);
+  unsigned i;
+
+  hdr->mark = 1;
+
+  for (i = 0; i < maxPtrs; i++) {
+    if (sms_valid_ptr(hdr->pPool, ptrs[i])) {
+      obhdr *ob = ptrs[i];
+      if (ob->mark == 0)
+	sms_mark(ob);
+    }
+  }
+}
+#endif
+
+/* sms_release(pool): Free all objects associated with /pool/ whose
  * reference count is zero. At the end of this operation, there will
  * be no objects in the pool. Objects in /pool/ whose reference counts
  * are non-zero will be moved to the null pool and freed when their
  * reference count goes to zero. */
 void
-sms_releasepool(sms_pool_t pool)
+sms_release(sms_pool_t pool)
 {
-  while (pool->next != pool) {
-    obhdr *ob = pool->next;
-    pool->next = ob->next;
+  obhdr *hdr;
 
-    ob->next = ob;
-    ob->prev = ob;
-
-    if (ob->refcount == 0)
-      free(ob);
-  }
+  /* From this point on, continued existance of this pool happens only
+   * because there remain residual reachable objects. */
+  pool->isLive = 0;
+
+#ifdef CONSERVATIVE_GC
+  for (hdr = pool->hdr.next; hdr != &pool->hdr; hdr = hdr->next)
+    hdr->mark = 0;
+
+  for (hdr = pool->hdr.next; hdr != &pool->hdr; hdr = hdr->next)
+    if (hdr->refcount && !hdr->mark)
+      sms_mark(hdr);
+
+  for (hdr = pool->hdr.next; hdr != &pool->hdr; hdr = hdr->next)
+    if (!hdr->mark)
+      sms_free(hdr);
+#else
+  for (hdr = pool->hdr.next; hdr != &pool->hdr; hdr = hdr->next)
+    if (!hdr->refcount)
+      sms_free(hdr);
+#endif
 
-  free(pool);
+  if (pool->obcount == 0)
+    free(pool);
 }



1.3       +2 -2      pcms/src/common/smsmalloc.h

Index: smsmalloc.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/smsmalloc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- smsmalloc.h	2001/11/21 20:58:40	1.2
+++ smsmalloc.h	2001/11/21 21:55:12	1.3
@@ -24,9 +24,9 @@
  * object will be freed. */
 extern void sms_decref(void *ob);
 
-/* sms_bulkfree(pool): Free all objects associated with /pool/ whose
+/* sms_release(pool): Free all objects associated with /pool/ whose
  * reference count is zero. At the end of this operation, there will
  * be no objects in the pool. Objects in /pool/ whose reference counts
  * are non-zero will be moved to the null pool and freed when their
  * reference count goes to zero. */
-extern void sms_releasepool(sms_pool_t pool);
+extern void sms_release(sms_pool_t pool);




From shap@snocrash.cs.jhu.edu Wed Nov 21 16:00:28 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fALL0SV26168
	for <dcms-cvs@eros.cs.jhu.edu>; Wed, 21 Nov 2001 16:00:28 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id QAA00696;
	Wed, 21 Nov 2001 16:43:37 -0500
Received: (from shap@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fALKuPV28550;
	Wed, 21 Nov 2001 15:56:25 -0500
Date: Wed, 21 Nov 2001 15:56:25 -0500
From: "Jonathan S. Shapiro" <shap@snocrash.cs.jhu.edu>
Message-Id: <200111212056.fALKuPV28550@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common smsmalloc.c smsmalloc.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

shap        01/11/21 15:56:25

  Modified:    src      .cvsignore pcmsrules.mk.in
  Added:       src/common smsmalloc.c smsmalloc.h
  Log:
  Added an (untested) pool malloc implementation. The general idea is
  that you first create a (logical) pool object, and you then perform a
  bunch of allocations associated with that pool. Later, you can reclaim
  the entire pool in a single operation.
  
  Objects need to survive the reclamation of a pool if there are
  pointers to them from other objects that will survive the death of the
  pool. Such objects include:
  
        Objects that were never in the pool in the first place, and
        Objects in the pool that will survive the death of the pool.
  
  Every object allocated through the SMS pool allocator has an
  associated reference count field manipulated through the
  incref()/decref() methods. These counts are supposed to track the
  number of *external* pointers to the object.
  
  Note that no attempt is made to do reachability analysis (which is
  probably a bug).  This means that if you want to keep an object, and
  if that object in turn references other objects, it is up to you to
  perform any recursive marking that may be necessary.
  
  "SMS" stands for server malloc system.

Revision  Changes    Path
1.8       +1 -0      pcms/src/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/.cvsignore,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- .cvsignore	2001/11/05 19:32:00	1.7
+++ .cvsignore	2001/11/21 20:56:25	1.8
@@ -1,4 +1,5 @@
 Makefile
 pcmsrules.mk
 .depend
+lib
 *.m



1.5       +1 -0      pcms/src/pcmsrules.mk.in

Index: pcmsrules.mk.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/pcmsrules.mk.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- pcmsrules.mk.in	2001/11/20 23:34:44	1.4
+++ pcmsrules.mk.in	2001/11/21 20:56:25	1.5
@@ -27,6 +27,7 @@
 	$(TOPDIR)/common/Project.o \
 	$(TOPDIR)/common/Serializable.o \
 	$(TOPDIR)/common/xmalloc.o \
+	$(TOPDIR)/common/smsmalloc.o \
 	$(TOPDIR)/common/os.o \
 	$(TOPDIR)/common/ServerRequest.o \
 	$(TOPDIR)/common/ServerReply.o \



1.1                  pcms/src/common/smsmalloc.c

Index: smsmalloc.c
===================================================================
/* Copyright (C) 2001, Johns Hopkins University. */


#include <malloc.h>
#include <assert.h>

#define SMS_IMPLEMENTATION

/* Common header structure that will sit at the front of every object: */
typedef struct obhdr obhdr;
struct obhdr {
  obhdr *next;
  obhdr *prev;
  unsigned refcount;
} ;
typedef struct obhdr *sms_pool_t;

#define HDR(ob) ((obhdr *) (((char *)ob) - sizeof(obhdr)))
#define LIVEPOOL(hdr) (hdr->next != hdr)

#include "smsmalloc.h"

/* sms_mkpool simply returns a "zero-length" object whose header will
 * serve as the pool chain header for the object.
 */
sms_pool_t 
sms_mkpool()
{
  obhdr *hdr = malloc(sizeof(obhdr));
  bzero(hdr, sizeof(obhdr));
  assert(hdr);

  hdr->refcount = 0;
  hdr->next = hdr;
  hdr->prev = hdr;

  return hdr;
}

void *
sms_malloc(sms_pool_t pool, size_t sz)
{
  obhdr *hdr = malloc(sizeof(obhdr) + sz);
  bzero(hdr, sizeof(obhdr) + sz);
  assert(hdr);

  hdr->refcount = 0;
  hdr->prev = pool;
  hdr->next = pool->next;
  pool->next->prev = hdr;
  pool->next = hdr;

  return (void *) (((char *)hdr) + sizeof(obhdr));
}

void
sms_free(void *ob)
{
  obhdr *hdr = HDR(ob);

  if (LIVEPOOL(hdr)) {
    /* pool is still alive, so remove this from the pool */
    hdr->next->prev = hdr->prev;
    hdr->prev->next = hdr->next;
  }

  free(hdr);
}

void 
sms_incref(void *ob)
{
  obhdr *hdr = HDR(ob);
  hdr->refcount++;
}

void 
sms_decref(void *ob)
{
  obhdr *hdr = HDR(ob);
  hdr->refcount--;

  if (hdr->refcount == 0 && !LIVEPOOL(hdr))
    sms_free(hdr);
}

/* sms_bulkfree(pool): Free all objects associated with /pool/ whose
 * reference count is zero. At the end of this operation, there will
 * be no objects in the pool. Objects in /pool/ whose reference counts
 * are non-zero will be moved to the null pool and freed when their
 * reference count goes to zero. */
void
sms_releasepool(sms_pool_t pool)
{
  while (pool->next != pool) {
    obhdr *ob = pool->next;
    pool->next = ob->next;

    ob->next = ob;
    ob->prev = ob;

    if (ob->refcount == 0)
      free(ob);
  }

  free(pool);
}



1.1                  pcms/src/common/smsmalloc.h

Index: smsmalloc.h
===================================================================
/* Copyright (C) 2001, Johns Hopkins University. */

#ifndef SMS_IMPLEMENTATION

/* Opaque type trick: */
typedef void *sms_pool_t;

#endif

/* Create a new pool from which objects can be allocated */
extern sms_pool_t sms_mkpool(void);

/* sms_malloc(tag,sz): allocate a new object of size /sz/, associated
 * with the specified bulk-reclaim pool /pool/. */
extern void *sms_malloc(sms_pool_t pool, size_t sz);

/* sms_free(ob): free the object pointed to by /ob/ */
extern void sms_free(void *ob);

/* sms_incref(ob): increment the reference count associated with /ob/,
 * preventing reclamation when its pool is released. */
extern void sms_incref(void *ob);

/* sms_defref(ob): decrement the reference count associated with /ob/,
 * possibly permitting reclamation. If the object reference count is
 * zero and the pool associated with its tag has been freed, the
 * object will be freed. */
extern void sms_decref(void *ob);

/* sms_bulkfree(pool): Free all objects associated with /pool/ whose
 * reference count is zero. At the end of this operation, there will
 * be no objects in the pool. Objects in /pool/ whose reference counts
 * are non-zero will be moved to the null pool and freed when their
 * reference count goes to zero. */
extern void sms_releasepool(sms_pool_t pool);




From shap@snocrash.cs.jhu.edu Wed Nov 21 16:02:28 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fALL2SV26210
	for <dcms-cvs@eros.cs.jhu.edu>; Wed, 21 Nov 2001 16:02:28 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id QAA00731;
	Wed, 21 Nov 2001 16:45:38 -0500
Received: (from shap@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fALKweb28596;
	Wed, 21 Nov 2001 15:58:40 -0500
Date: Wed, 21 Nov 2001 15:58:40 -0500
From: "Jonathan S. Shapiro" <shap@snocrash.cs.jhu.edu>
Message-Id: <200111212058.fALKweb28596@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common smsmalloc.c smsmalloc.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

shap        01/11/21 15:58:40

  Modified:    src/common smsmalloc.c smsmalloc.h
  Log:
  sms_free() is no longer a published entry point. Managed storage is
  implied by appropriate use of sms_decref(), but by eliminating
  sms_free() from the external interface the implementation is free to
  treat sms_decref() as advisory, allowing the possibility of garbage
  collection at a later time.

Revision  Changes    Path
1.2       +1 -1      pcms/src/common/smsmalloc.c

Index: smsmalloc.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/smsmalloc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- smsmalloc.c	2001/11/21 20:56:25	1.1
+++ smsmalloc.c	2001/11/21 20:58:40	1.2
@@ -53,7 +53,7 @@
   return (void *) (((char *)hdr) + sizeof(obhdr));
 }
 
-void
+static void
 sms_free(void *ob)
 {
   obhdr *hdr = HDR(ob);



1.2       +0 -3      pcms/src/common/smsmalloc.h

Index: smsmalloc.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/smsmalloc.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- smsmalloc.h	2001/11/21 20:56:25	1.1
+++ smsmalloc.h	2001/11/21 20:58:40	1.2
@@ -14,9 +14,6 @@
  * with the specified bulk-reclaim pool /pool/. */
 extern void *sms_malloc(sms_pool_t pool, size_t sz);
 
-/* sms_free(ob): free the object pointed to by /ob/ */
-extern void sms_free(void *ob);
-
 /* sms_incref(ob): increment the reference count associated with /ob/,
  * preventing reclamation when its pool is released. */
 extern void sms_incref(void *ob);




From vandy@snocrash.cs.jhu.edu Tue Nov 27 11:57:31 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fARGvUV23920
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 27 Nov 2001 11:57:30 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id MAA00707;
	Tue, 27 Nov 2001 12:39:53 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fARGquC12337;
	Tue, 27 Nov 2001 11:52:56 -0500
Date: Tue, 27 Nov 2001 11:52:56 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111271652.fARGquC12337@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server DispatchRequest.c pcmsserver.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/27 11:52:56

  Modified:    src      pcmsrules.mk.in
               src/client command.c command.h pcms.c
               src/common ServerReply.c ServerReply.h ServerRequest.c
                        ServerRequest.h
               src/repos/common Repository.c Repository.h
               src/repos/fs CachedFileRepos.c FileRepos.c FileRepos.h
               src/repos/net NetRepository.c
               src/server pcmsserver.c
  Added:       src/repos Channel.c Channel.h
               src/server DispatchRequest.c
  Log:
  More misc fixes...

Revision  Changes    Path
1.6       +2 -1      pcms/src/pcmsrules.mk.in

Index: pcmsrules.mk.in
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/pcmsrules.mk.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- pcmsrules.mk.in	2001/11/21 20:56:25	1.5
+++ pcmsrules.mk.in	2001/11/27 16:52:55	1.6
@@ -39,7 +39,8 @@
 	$(TOPDIR)/repos/net/NetRepository.o \
 	$(TOPDIR)/repos/common/Repository.o \
 	$(TOPDIR)/repos/common/EntityCache.o \
-	$(TOPDIR)/repos/common/URI.o
+	$(TOPDIR)/repos/common/URI.o \
+	$(TOPDIR)/repos/Channel.o
 
 CLIENTLIBOBJECTS=\
 	$(TOPDIR)/client/glob.o \



1.3       +7 -0      pcms/src/client/command.c

Index: command.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/command.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- command.c	2001/10/19 03:44:10	1.2
+++ command.c	2001/11/27 16:52:55	1.3
@@ -10,6 +10,12 @@
  * minimal completion logic won't work.
  */
 
+struct command copy_cmds[] = {
+  { "branch",      pcms_copy_branch,     2, 0 },
+  { "project",     pcms_copy_project,    2, 0 },
+  { (char *)0 }
+};
+
 struct command create_cmds[] = {
   /*   { "repos", 0, 0, repos_cmd }, */
   { "branch",      pcms_create_branch,     1, 0 },
@@ -57,6 +63,7 @@
   { "status",    pcms_status,     0, 0 },
   { "update",    pcms_update,     0, 0 }, /* eventually CS_MORE */
   { "version",   pcms_version,    0, 0 },
+  { "copy", 0, 0, copy_cmds },
   { (char *)0 }
 };
 



1.3       +4 -0      pcms/src/client/command.h

Index: command.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/command.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- command.h	2001/10/19 03:44:10	1.2
+++ command.h	2001/11/27 16:52:55	1.3
@@ -58,4 +58,8 @@
 extern void pcms_note(Repository *, int argc, char **argv);
 extern void pcms_show_notes(Repository *, int argc, char **argv);
 
+/* For replication: */
+extern void pcms_copy_project(Repository *, int argc, char **argv);
+extern void pcms_copy_branch(Repository *, int argc, char **argv);
+
 void list_commands(command *table);



1.8       +59 -3     pcms/src/client/pcms.c

Index: pcms.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/pcms.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- pcms.c	2001/11/20 23:34:44	1.7
+++ pcms.c	2001/11/27 16:52:55	1.8
@@ -701,6 +701,61 @@
   exit(0);
 }
 
+void
+pcms_copy_branch(Repository *fromR, int argc, char **argv)
+{
+    Project *p;
+    Branch *b;
+    Repository *toR;
+    char *petName;
+    char *branch;
+    char *proj;
+
+    /***
+    int x;
+    for (x = 0; x < argc; x++)
+	fprintf(stdout, "Argv[%d] = %s\n", x, argv[x]);
+    
+	***/
+
+  if (fromR == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+  
+  if (ws_haveProject)
+    report_error(EX_WorkSpace, "Workspace already has a project\n");
+    
+  petName = argv[0];
+  branch  = strchr(argv[0], ':');
+
+  if (branch == 0)
+    report_error(EX_Args, "command requires branch name\n");
+  
+  proj = xstrndup(argv[0], branch - argv[0]);
+  branch++;
+
+  p = repos_PetGetProject(fromR, proj);
+  b = repos_PetGetBranch(fromR, p, branch);
+
+  toR = repository_open(argv[1],0);
+  if (toR == 0)
+      report_error(EX_Args, "command requires a target repository URI\n");
+
+  /** repos_PutBranch(toR, p, b); **/
+  filerepository_PutBranch(toR, p, b);
+  
+  /* Now copy over the entities: */
+  pendingchange_Commit(ws_nextChange, toR, p, b);
+
+}
+
+void
+pcms_copy_project(Repository *r, int argc, char **argv)
+{
+    int x;
+    for (x = 0; x < argc; x++)
+	fprintf(stdout, "Argv[%d] = %s\n", x, argv[x]);
+}
+
 static void
 process_environment()
 {
@@ -737,10 +792,11 @@
   process_options(argc, argv);
 
   r = 0;
-  if (ServerURI)
+  if (ServerURI) {
     r = repository_open(ServerURI, 0);
-  
-  ws_Init(r);
+    ws_Init(r);
+  }
+
   /* Now chdir'd to project root directory IF THERE IS ONE */
 
   pcms_command(r, argc - optind, argv + optind);



1.5       +5 -1      pcms/src/common/ServerReply.c

Index: ServerReply.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerReply.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServerReply.c	2001/11/20 23:34:44	1.4
+++ ServerReply.c	2001/11/27 16:52:55	1.5
@@ -14,6 +14,7 @@
   sdr_w_ulong("rtype", strm, p->rtype);
   sdr_w_string("data", strm, p->data);
   sdr_w_ulong("sock", strm, p->sockfd);
+  sdr_w_ulong("reqid", strm, p->client_reqid);
   sdr_write("args", strm, p->return_objs);
   
 } /* end reply_serialize */
@@ -28,13 +29,14 @@
   p->rtype	    = sdr_r_ulong("rtype", strm);
   p->data           = sdr_r_string("data", strm);
   p->sockfd	    = sdr_r_ulong("sock", strm);
+  p->client_reqid   = sdr_r_ulong("reqid", strm);
   p->return_objs    = sdr_read("args", strm);
 
   return p;
 }
 
 ServerReply *
-reply_create(int type, const char *reply, int socket)
+reply_create(int type, const char *reply, int socket, unsigned int reqid)
 {
   ServerReply *p = (ServerReply *) pcms_malloc(sizeof(ServerReply));
 
@@ -43,6 +45,7 @@
   p->rtype = type;
   p->data = reply;
   p->sockfd = socket;
+  p->client_reqid = reqid;
   p->return_objs = obvec_create();
 
   return p;
@@ -57,6 +60,7 @@
   xprintf("Type       :     %d\n", p->rtype);
   xprintf("Data       :     %s\n", p->data);
   xprintf("Socket     :     %d\n", p->sockfd);
+  xprintf("Request ID :     %d\n", p->client_reqid);
 
   for (u = 0; u < vec_size(p->return_objs); u++)
       sdr_show(vec_fetch(p->return_objs, u));



1.5       +2 -1      pcms/src/common/ServerReply.h

Index: ServerReply.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerReply.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ServerReply.h	2001/11/20 23:34:44	1.4
+++ ServerReply.h	2001/11/27 16:52:55	1.5
@@ -9,12 +9,13 @@
   
   int rtype;  /* info-only, error, or successful reply */
   const char *data;
+  unsigned int client_reqid;
   int sockfd;
   ObVec *return_objs;
 
 } ServerReply;
 
-ServerReply *reply_create (int type, const char *reply, int socket);
+ServerReply *reply_create (int type, const char *reply, int socket, unsigned int reqid);
 
 /*
  * Need method to add return objects:



1.3       +4 -1      pcms/src/common/ServerRequest.c

Index: ServerRequest.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerRequest.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServerRequest.c	2001/11/13 17:02:33	1.2
+++ ServerRequest.c	2001/11/27 16:52:55	1.3
@@ -13,6 +13,7 @@
   sdr_w_string("serTrueName", strm, p->serTrueName);
   sdr_w_string("command", strm, p->command);
   sdr_w_ulong("opcode", strm, p->opcode);
+  sdr_w_ulong("reqid", strm, p->request_id);
   sdr_w_string("path", strm, p->repos_path);
   sdr_w_string("user", strm, p->username);
   sdr_w_ulong("sock", strm, p->sockfd);
@@ -29,6 +30,7 @@
   p->serTrueName    = sdr_r_string("serTrueName", strm);
   p->command        = sdr_r_string("command", strm);
   p->opcode         = sdr_r_ulong("opcode", strm);
+  p->request_id     = sdr_r_ulong("reqid", strm);
   p->repos_path     = sdr_r_string("path", strm);
   p->username       = sdr_r_string("user", strm);
   p->sockfd         = sdr_r_ulong("sock", strm);
@@ -38,7 +40,7 @@
 }
 
 ServerRequest *
-request_create(const char *aName, char *path, char *user, unsigned int ocode)
+request_create(const char *aName, char *path, char *user, unsigned int ocode, unsigned int reqid)
 {
   ServerRequest *p = (ServerRequest *) pcms_malloc(sizeof(ServerRequest));
 
@@ -47,6 +49,7 @@
 
   p->command = aName;
   p->opcode = ocode;
+  p->request_id = reqid;
   p->repos_path = path;
   p->username = user;
   p->sockfd = 0;  /* will be assigned by server */



1.3       +2 -1      pcms/src/common/ServerRequest.h

Index: ServerRequest.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerRequest.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServerRequest.h	2001/11/13 17:02:33	1.2
+++ ServerRequest.h	2001/11/27 16:52:55	1.3
@@ -6,6 +6,7 @@
   
   const char *command;
   unsigned int opcode;
+  unsigned int request_id;
   char *repos_path;
   char *username;
   int sockfd;
@@ -17,7 +18,7 @@
 
 } ServerRequest;
 
-ServerRequest *request_create (const char *aName, char *path, char *user, unsigned int ocode);
+ServerRequest *request_create (const char *aName, char *path, char *user, unsigned int ocode, unsigned int reqid);
 
 /* 
  * Need methods to add command arguments:



1.1                  pcms/src/repos/Channel.c

Index: Channel.c
===================================================================
#include <pcms.h>
#include <repos/pcmsrepos.h>
#include <repos/Channel.h>
#include <common/ServerRequest.h>
#include <common/ServerReply.h>
#include <common/ServerStringArgument.h>

#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>

#include "Channel.h"

#define PCMSPORT 3399

/* Method to ensure all bytes are read from socket, especially
   when socket buffer is exceeded */
char * read_entire_msg_from_socket(int, unsigned int);
/* 
 * Initialize a Channel object for plain/vanilla TCP/IP socket
 * connection:
 */
Channel *create_tcp_channel(int id) {
    Channel *c = (Channel *)pcms_malloc(sizeof(Channel));
    c->channelID = id;
    c->sockfd = 0;
    c->setup = tcp_setup;
    c->send = tcp_send;
    c->receive = tcp_receive;
    return c;
} /* end create_tcp_channel */

int tcp_setup(Channel *c, URI *uri) {
	
	struct sockaddr_in cliaddr;
	struct hostent *netlocaddr;
	struct in_addr **hostptr;
	int connsucceed;
	
	if ((netlocaddr = gethostbyname2(uri->netloc, AF_INET)) == NULL) {
		report("%s\n", hstrerror(h_errno));
		return -1;
	}
	
	hostptr = (struct in_addr **) netlocaddr->h_addr_list;

	c->sockfd = socket(AF_INET, SOCK_STREAM, 0);
	
	for (connsucceed = 0 ; *hostptr != NULL; hostptr++) {
	
		bzero(&cliaddr,sizeof(cliaddr));
		cliaddr.sin_family = AF_INET;
		cliaddr.sin_port = htons((uri->port == 0) ? PCMSPORT : uri->port);
		memcpy(&cliaddr.sin_addr, *hostptr, sizeof(struct in_addr));
		
		report("Connecting to %s: %s, port %d\n", uri->netloc, inet_ntoa(cliaddr.sin_addr), ntohs(cliaddr.sin_port)); 
	
		if (connect(c->sockfd, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
			report("Connect Error\n");
		}
		else {
			connsucceed = 1;
			break;
		}
	}
	if (!connsucceed) {
		return -1;
	}

	return 0;
}

int tcp_send(Channel *c, const void *messagebuf) {
	
	char* message;
	unsigned int msglen = strlen((char *)messagebuf);
	unsigned int finalsize;
	unsigned int numsent = 0;
	unsigned int tempnum = 0;

	finalsize = sizeof(msglen) + strlen((char *)messagebuf);
	message = (char *)pcms_malloc(finalsize);
	
	memcpy(message+sizeof(msglen), messagebuf, msglen);
	memcpy(message, &msglen, sizeof(msglen));
	
	numsent = write(c->sockfd, message, finalsize);
	if (numsent < 0) {
	    report_error (1, "TCP Socket Error when sending.\n");
	    return -1;
	} /* end if */

	while (numsent < finalsize) {
	    tempnum = write(c->sockfd, message+numsent, finalsize);
	    if (tempnum < 0) {
		report_error (1, "TCP Socket Error when sending.\n");
		return -1;
	    } /* end if */
	    numsent = numsent + tempnum;
	} /* end while */	    
	
	return 0;

} /* end tcp_send */

char *tcp_receive(Channel *c) {

    unsigned int incoming = 0;
    char *rawReply;

    if (read(c->sockfd, &incoming, sizeof(incoming)) <= 0)
	report_error(1, "Server not responding with any data.\n");

    if (incoming > 0) {
	rawReply = (char *)pcms_malloc(incoming);
	rawReply = read_entire_msg_from_socket(c->sockfd, incoming);
    } /* end if incoming > 0 */

    return rawReply;

} /* end tcp_receive */

/*
 * Purpose of this function is when the socket read buffer is
 * full, but the entire message hasn't been read, we need to
 * execute multiple read's. 
 */
char * read_entire_msg_from_socket(int socket, unsigned int expected) {

    char *entire_msg = (char *)pcms_malloc(expected);
    unsigned int numread = read(socket, entire_msg, expected);

    if (numread < 0)
	report_error (1, "Server connection error:  no data received.\n");

    if (numread < expected) {

	unsigned int tindex = 0;
	char *tmp_message = (char *)pcms_malloc(expected);
	tmp_message = xstrdup(entire_msg);

	/* Make sure we read entire message: */
	while (numread < expected) {
	    tindex = read(socket, entire_msg, expected);
	    if (tindex < 0)
		report_error(1, "Server connection terminated while reading reply.\n");
	    numread = numread + tindex;
	    entire_msg[tindex] = '\0';
	    tmp_message = xstrcat(tmp_message, entire_msg);
	} /* end while numread < lmess */

	/* Store the final (complete) message back in the
	 * "entire message" variable:
	 */
	entire_msg = xstrdup(tmp_message);
    
    } /* end if numread < expected */

    return entire_msg;

} /* end read_entire_msg_from_socket */





1.1                  pcms/src/repos/Channel.h

Index: Channel.h
===================================================================
#ifndef __CHANNEL_H__
#define __CHANNEL_H__

#include <repos/pcmsrepos.h>
/*
 * Encapsulation of all network protocol-specific variables.
 * (For plain TCP/IP sockets, this is just the socket variables.
 * Other protocols will require additional information.)
 */
typedef struct Channel Channel;
struct Channel {
    int channelID;
    int sockfd;
    int (*setup)(Channel *, URI *);
    int (*send)(Channel *, const void *);
    char *(*receive)(Channel *);
}; 

/*
 * Here are the prototypes for TCP/IP vanilla sockets:
 */
Channel *create_tcp_channel(int);
int tcp_setup(Channel *, URI *);
int tcp_send(Channel *, const void *);
char *tcp_receive(Channel *);

#endif




1.5       +3 -0      pcms/src/repos/common/Repository.c

Index: Repository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/Repository.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Repository.c	2001/11/13 17:06:12	1.4
+++ Repository.c	2001/11/27 16:52:55	1.5
@@ -83,6 +83,9 @@
   r->auth = ai;
   r->info = 0;
   
+  if (uri->path == NULL)
+      report_error(EX_NoServer, "No repository path specified\n");
+
   if (!uri->well_formed)
     report_error(EX_NoServer, "Malformed server URI\n");
 



1.8       +8 -0      pcms/src/repos/common/Repository.h

Index: Repository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/Repository.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Repository.h	2001/11/20 23:34:44	1.7
+++ Repository.h	2001/11/27 16:52:55	1.8
@@ -57,6 +57,10 @@
   /* Entity management: -- both 2nd args must be serializables */
   const char *(*ReviseEntity)(Repository *r, const char *prevTrueName, void *);
   void *(*GetEntity)(Repository *r, const char *trueName);
+  
+  /* Replication methods: */
+  void (*PutProject)(Repository *r, Project *p);
+  void (*PutBranch)(Repository *r, Project *p, Branch *b);
 };
 
 #define repos_CreateRepository(r)  r->CreateRepository(r)
@@ -89,6 +93,10 @@
 /* Entity management: -- 2nd arg to ReviseEntity must be Serializable */
 #define repos_ReviseEntity(r,ptn,ent) r->ReviseEntity(r,ptn,ent)
 #define repos_GetEntity(r,tn)         r->GetEntity(r,tn)
+
+/* Replication commands: */
+#define repos_PutProject(r,p) r->PutProject(r,p)
+#define repos_PutBranch(r,p,b) r->PutBranch(r,p,b)
 
 /** repository_open(): given a URI identifying a repository, perform the
     appropriate actions to open the repository and authenticate the



1.8       +9 -0      pcms/src/repos/fs/CachedFileRepos.c

Index: CachedFileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/CachedFileRepos.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CachedFileRepos.c	2001/11/20 23:34:44	1.7
+++ CachedFileRepos.c	2001/11/27 16:52:55	1.8
@@ -122,6 +122,15 @@
   return (char *)filerepository_ReviseEntity(r, prevTrueName, s);
 }
 
+/* Replication: */
+static void cachedfilerepository_PutProject (Repository *r, Project *p) {
+	filerepository_PutProject(r, p);
+}
+
+static void cachedfilerepository_PutBranch (Repository *r, Project *p, Branch *b) {
+	filerepository_PutBranch(r, p, b);
+}
+
  static void *
 cachedfilerepository_GetEntity(Repository *r,
 			  const char *trueName)



1.9       +82 -0     pcms/src/repos/fs/FileRepos.c

Index: FileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- FileRepos.c	2001/11/20 23:34:44	1.8
+++ FileRepos.c	2001/11/27 16:52:55	1.9
@@ -667,6 +667,84 @@
   return ent;
 }
 
+/* Replication: */
+void filerepository_PutProject(Repository *r, Project *p) 
+{
+    const char *relpath;
+    const char *path;
+    SDR_stream *strm;
+
+    /* paranoia checks: */
+    if (r == NULL)
+	report_error(EX_NoArgs, "No Repository specified.\n");
+
+    if (p == NULL)
+	report_error(EX_NoArgs, "No Project specified.\n");
+
+    /* simple create the given Project in the 'new' repository: */
+    relpath = path_tn_fixup(p->serTrueName);
+    relpath = path_join("projects", p->serTrueName);
+    path = path_join(r->uri->path, relpath);
+
+    if (path_smkdir(path) < 0)
+       report_error(EX_Server, "Problem copying the Project");
+
+    if (path_smkdir(path_join(path,"branches")) < 0)
+       report_error(EX_Server, "Problem copying the Project");
+
+    if (path_smkdir(path_join(path,"petnames")) < 0)
+       report_error(EX_Server, "Problem copying the Project");
+
+    strm = stream_openfile(path_join(path,"description"), WSTREAM, STREAM_XML);
+    sdr_write("PROJECT", strm, p);
+    stream_close(strm);
+
+    /* Finally, copy the petnames entry: */
+    p->petName = BindPetName(r, 0, p->nickname, p->serTrueName);
+
+} /* end filerepository_PutProject */
+
+void filerepository_PutBranch(Repository *r, Project *p, Branch *b)
+{
+    const char *projpath;
+    const char *relpath;
+    const char *path;
+    SDR_stream *strm;
+
+    /* paranoia checks: */
+    if (r == NULL)
+	report_error(EX_NoArgs, "No Repository specified.\n");
+
+    if (p == NULL)
+	report_error(EX_NoArgs, "No Project specified.\n");
+    
+    if (b == NULL)
+	report_error(EX_NoArgs, "No Branch specified.\n");
+
+    /* Ensure project path and all necessary subdirs exist: */
+    filerepository_PutProject(r, p);
+
+    /* Now generate the path for the branch: */
+    projpath = path_tn_fixup(p->serTrueName);
+    projpath = path_join("projects", projpath);
+
+    relpath = path_tn_fixup(b->serTrueName);
+    relpath = path_join("branches", relpath);
+
+    path = path_join(r->uri->path, projpath);
+    path = path_join(path, relpath);
+
+    strm = stream_openfile(path, WSTREAM, STREAM_XML);
+
+    /* Write out the actual branch info: */
+    sdr_write("BRANCH", strm, b);
+    stream_close(strm);
+
+    /* Finally, copy the petnames entry: */
+    b->petName = BindPetName(r, projpath, b->nickname, b->serTrueName);
+
+} /* end filerepository_PutBranch */
+
  void
 filerepository_init(Repository *r)
 {
@@ -698,6 +776,10 @@
   /* Entity management: -- both 2nd args must be serializables */
   r->ReviseEntity = filerepository_ReviseEntity;
   r->GetEntity = filerepository_GetEntity;
+
+  /* Replication: */
+  r->PutBranch = filerepository_PutBranch;
+  r->PutProject = filerepository_PutProject;
 
   r->cache = NULL;
   r->channel = NULL;



1.5       +21 -15    pcms/src/repos/fs/FileRepos.h

Index: FileRepos.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FileRepos.h	2001/11/16 18:02:02	1.4
+++ FileRepos.h	2001/11/27 16:52:55	1.5
@@ -2,7 +2,7 @@
 bool
 is_dot_or_dotdot(struct dirent *);
 
-  int
+int
 filerepository_connect(Repository *);
 
 const char *
@@ -17,55 +17,61 @@
 int
 filerepository_CreateRepository(Repository *);
 
-  int
+int
 filerepository_CreateProject(Repository *, Project *);
 
-  Project *
+Project *
 filerepository_GetProject(Repository *, const char *);
 
 Project *
 filerepository_PetGetProject(Repository *, const char *);
 
-  int 
+int 
 filerepository_PetRenameProject(Repository *,
 				const char *, const char *);
-  StrVec * 
+StrVec * 
 filerepository_ListProjects(Repository *);
 
-  StrVec * 
+StrVec * 
 filerepository_ListProjPetNames(Repository *, Project *);
 
-  StrVec * 
+StrVec * 
 filerepository_ListBranchPetNames(Repository *, Branch *, const char *);
 
-  int 
+int 
 filerepository_CreateBranch(Repository *, Project *, Branch *);
 
-  int
+int
 filerepository_PetRenameBranch(Repository *,
 			       Project *,
 			       const char *,
 			       const char *);
-  Branch *
+Branch *
 filerepository_GetBranch(Repository *, Project *,
 			 const char *);
-  Branch *
+Branch *
 filerepository_PetGetBranch(Repository *, Project *, const char *);
 
-  int 
+int 
 filerepository_ReviseBranch(Repository *, Project *, Branch *);
 
-  StrVec *
+StrVec *
 filerepository_ListBranches(Repository *, Project *);
 
-  const char *
+const char *
 filerepository_ReviseEntity(Repository *,
 			    const char *, void *);
 void *
 filerepository_GetEntity(Repository *,
 			 const char *);
- void
+void
 filerepository_init(Repository *);
+
+void
+filerepository_PutProject(Repository *r, Project *p);
+
+void
+filerepository_PutBranch(Repository *r, Project *p, Branch *b);
 
 
 



1.13      +143 -212  pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- NetRepository.c	2001/11/20 23:34:45	1.12
+++ NetRepository.c	2001/11/27 16:52:55	1.13
@@ -5,22 +5,7 @@
 #include <common/ServerReply.h>
 #include <common/ServerStringArgument.h>
 
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <errno.h>
-
-#define PCMSPORT 3399
-
-inline void sendStr(int connectfd, const char* messagebuf);
-/**  OLD:   inline void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen); */
-inline void sendBuff(int connectfd, const void* messagebuf);
-
-/* Method to ensure all bytes are read from socket, especially
-   when socket buffer is exceeded */
-char * read_entire_msg_from_socket(int, unsigned int);
+static unsigned int request_id = 0;
 
 /* Method to encapsulate all network protocol-specific details
    of sending request to the Server */
@@ -28,72 +13,10 @@
 
 int netrepository_connect(Repository *r) {
 	
-	struct sockaddr_in cliaddr;
-	struct hostent *netlocaddr;
-	struct in_addr **hostptr;
-	int connsucceed;
+    return (r->channel->setup(r->channel, r->uri));
 	
-	if ((netlocaddr = gethostbyname2(r->uri->netloc, AF_INET)) == NULL) {
-		printf("%s\n", hstrerror(h_errno));
-	}
-	
-	hostptr = (struct in_addr **) netlocaddr->h_addr_list;
-
-	r->channel->sockfd = socket(AF_INET, SOCK_STREAM, 0);
-	r->channel->channelID = 1;  
-	
-	for (connsucceed = 0 ; *hostptr != NULL; hostptr++) {
-	
-		bzero(&cliaddr,sizeof(cliaddr));
-		cliaddr.sin_family = AF_INET;
-		cliaddr.sin_port = htons((r->uri->port == 0) ? PCMSPORT : r->uri->port);
-		memcpy(&cliaddr.sin_addr, *hostptr, sizeof(struct in_addr));
-		
-		fprintf(stderr, "Connecting to %s: %s, port %d\n", r->uri->netloc, inet_ntoa(cliaddr.sin_addr), ntohs(cliaddr.sin_port)); 
-	
-		if (connect(r->channel->sockfd, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
-			fprintf(stderr, "Connect Error\n");
-		}
-		else {
-			connsucceed = 1;
-			break;
-		}
-	}
-	if (!connsucceed) {
-		exit(-1);
-	}
-
-	return 0;
-}
-
-void sendStr(int connectfd, const char* messagebuf) {
-	
-	/** OLD:   sendBuff(connectfd, messagebuf, strlen(messagebuf));  */
-	sendBuff(connectfd, messagebuf);
 }
 
-/** OLD:   void sendBuff(int connectfd, const void* messagebuf, unsigned int msglen) {  */
-void sendBuff(int connectfd, const void* messagebuf) {
-	
-	char* message;
-	unsigned int msglen = strlen((char *)messagebuf);
-	unsigned int finalsize;
-
-	finalsize = sizeof(msglen) + strlen((char *)messagebuf);
-	message = (char *)pcms_malloc(finalsize);
-	
-	/*  OLD:   memcpy(message+sizeof(msglen), messagebuf, msglen - sizeof(msglen));  */
-	memcpy(message+sizeof(msglen), messagebuf, msglen);
-	memcpy(message, &msglen, sizeof(msglen));
-	
-	/*  OLD:  if (write(connectfd, message, msglen) != msglen) { */
-	if (write(connectfd, message, finalsize) != finalsize) {
-		fprintf(stderr, "Not All Data Sent\n");
-	}
-	
-	return;
-}
-
 /*
  *  Create a Repository via a network repository.
  */
@@ -101,7 +24,7 @@
 	
         ServerReply *reply;
 	ServerRequest *sr = request_create(CREATEREPOSITORY, r->uri->path, 
-		                           r->uri->username, PCMS_OPCODE_CREATEREPOSITORY);
+		                           r->uri->username, PCMS_OPCODE_CREATEREPOSITORY, ++request_id);
 
 	reply = (ServerReply *)(invoke_server(r, sr));
 	report (reply->data);
@@ -118,7 +41,7 @@
 
 	ServerReply *reply;
 	ServerRequest *sr = request_create(GETVERSION, r->uri->path, 
-		                           r->uri->username, PCMS_OPCODE_GETVERSION);  
+		                           r->uri->username, PCMS_OPCODE_GETVERSION, ++request_id);  
 
 	reply = (ServerReply *)(invoke_server(r, sr));
 	return reply->data;  
@@ -134,17 +57,21 @@
 	
 	ServerReply *reply;
 	ServerRequest *sr = request_create(CREATEPROJECT, r->uri->path, 
-		                           r->uri->username, PCMS_OPCODE_CREATEPROJECT);
+		                           r->uri->username, PCMS_OPCODE_CREATEPROJECT, ++request_id);
 
 	/* Now add the Project argument to this request: */
 	serverrequest_AddArgument(sr, p);
 
 	reply = (ServerReply *)(invoke_server(r, sr));
 
-	/* We need the Project to come back in the reply so we can
-	   update the 'serTrueName' field: */
-	retProj = (Project *)(vec_fetch(reply->return_objs,0)); 
-	p->serTrueName = retProj->serTrueName;
+	if (reply->rtype == NET_ERROR)
+	    report_error(EX_Server, reply->data);
+	else {
+	    /* We need the Project to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    retProj = (Project *)(vec_fetch(reply->return_objs,0)); 
+	    p->serTrueName = retProj->serTrueName;
+	}
 
 	report(reply->data);
 
@@ -161,7 +88,7 @@
 	Project *retProj;
 	ServerReply *reply;
 	ServerRequest *sr = request_create(GETPROJECT, r->uri->path, 
-		                           r->uri->username, PCMS_OPCODE_GETPROJECT);
+		                           r->uri->username, PCMS_OPCODE_GETPROJECT, ++request_id);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -179,11 +106,16 @@
 	serverrequest_AddArgument(sr, ser_pName);
 
 	reply = (ServerReply *)(invoke_server(r, sr));
-
-	/* We need the Project to come back in the reply so we can
-	   update the 'serTrueName' field: */
-	retProj = (Project *)(vec_fetch(reply->return_objs,0)); 
-	return retProj;
+	if (reply->rtype == NET_ERROR)
+	    report_error(EX_Server, reply->data);
+	else {
+
+	    /* We need the Project to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    retProj = (Project *)(vec_fetch(reply->return_objs,0)); 
+	    return retProj;
+	}
+	return NULL;
 
 } /* end netrepository_GetProject */
 
@@ -198,7 +130,7 @@
 	Project *retProj;
 	ServerReply *reply;
 	ServerRequest *sr = request_create(PETGETPROJECT, r->uri->path, 
-		                           r->uri->username, PCMS_OPCODE_PETGETPROJECT);
+		                           r->uri->username, PCMS_OPCODE_PETGETPROJECT, ++request_id);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -217,10 +149,14 @@
 
 	reply = (ServerReply *)(invoke_server(r,sr));
 
-	/* We need the Project to come back in the reply so we can
-	   update the 'serTrueName' field: */
-	retProj = (Project *)(vec_fetch(reply->return_objs,0)); 
-	return retProj;
+	if (reply->rtype == NET_ERROR) {
+	    report_error(EX_Server, reply->data);
+	} else {
+	    /* We need the Project to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    retProj = (Project *)(vec_fetch(reply->return_objs,0)); 
+	    return retProj;
+	} /* end if-else */
 
     return NULL;
 } /* end netrepository_PetGetProject */
@@ -237,7 +173,7 @@
     ServerStringArgument *ser_newName;
     ServerReply *reply;
     ServerRequest *sr = request_create(RENAMEPROJECT, r->uri->path, 
-	                               r->uri->username, PCMS_OPCODE_RENAMEPROJECT);
+	                               r->uri->username, PCMS_OPCODE_RENAMEPROJECT, ++request_id);
     ser_oldName = serverarg_create(oldName);
     ser_newName = serverarg_create(newName);
 
@@ -261,17 +197,21 @@
     StrVec *retStrVec;
     ServerReply *reply;
     ServerRequest *sr = request_create(LISTPROJECTS, r->uri->path, 
-	                               r->uri->username, PCMS_OPCODE_LISTPROJECTS);
+	                               r->uri->username, PCMS_OPCODE_LISTPROJECTS, ++request_id);
 
     reply = (ServerReply *)(invoke_server(r,sr));
 	
-    /* Retrieve StrVec object from the reply in order to
-       update the Branch serTrueName field */
-    retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
-    report(reply->data);
-
-    return retStrVec;
+    if (reply->rtype == NET_ERROR) 
+	report_error(EX_Server, reply->data);
+    else {
+	/* Retrieve StrVec object from the reply in order to
+	   update the Branch serTrueName field */
+	retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
+	report(reply->data);
+	return retStrVec;
+    }
 
+    return NULL;
 } /* end netrepository_ListProjects */
 
 /*
@@ -285,18 +225,23 @@
     StrVec *retStrVec;
     ServerReply *reply;
     ServerRequest *sr = request_create(LISTPROJPETNAMES, r->uri->path, 
-	                               r->uri->username, PCMS_OPCODE_LISTPROJPETNAMES);
+	                               r->uri->username, PCMS_OPCODE_LISTPROJPETNAMES, ++request_id);
 
     /* Now add the Project as an argument to this request: */
     serverrequest_AddArgument(sr, p);
 
     reply = (ServerReply *)(invoke_server(r,sr));
 	
-    /* Retrieve StrVec object from the reply in order to
-       update the Branch serTrueName field */
-    retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
+    if (reply->rtype == NET_ERROR) 
+	report_error(EX_Server, reply->data);
+    else {
+	/* Retrieve StrVec object from the reply in order to
+	   update the Branch serTrueName field */
+	retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
+	return retStrVec;
+    }
 
-    return retStrVec;
+    return NULL;
 } /* end netrepository_ListProjPetNames */
 
 /*
@@ -309,21 +254,26 @@
     Branch *retBranch;
     ServerReply *reply;
     ServerRequest *sr = request_create(CREATEBRANCH, r->uri->path, 
-	                               r->uri->username, PCMS_OPCODE_CREATEBRANCH);
+	                               r->uri->username, PCMS_OPCODE_CREATEBRANCH, ++request_id);
 
     /* Now add the Project and Branch arguments to this request: */
     serverrequest_AddArgument(sr, p);
     serverrequest_AddArgument(sr, b);
 
     reply = (ServerReply *)(invoke_server(r,sr));
-	
-    /* Retrieve Branch object from the reply in order to
-       update the Branch serTrueName field */
-    retBranch = (Branch *)(vec_fetch(reply->return_objs,0)); 
-    b->serTrueName = retBranch->serTrueName;
-    report(reply->data);
+    if (reply->rtype == NET_ERROR) {
+	report_error(EX_Server, reply->data);
+    } else {
+	/* Retrieve Branch object from the reply in order to
+	   update the Branch serTrueName field */
+	retBranch = (Branch *)(vec_fetch(reply->return_objs,0)); 
+	b->serTrueName = retBranch->serTrueName;
+	report(reply->data);
     
-    return 0;
+	return 0;
+    }
+
+    return -1;
 
 } /* end netrepository_CreateBranch */
 
@@ -341,7 +291,7 @@
     ServerStringArgument *ser_newName;
     ServerReply *reply;
     ServerRequest *sr = request_create(RENAMEBRANCH, r->uri->path, 
-	                               r->uri->username, PCMS_OPCODE_RENAMEBRANCH);
+	                               r->uri->username, PCMS_OPCODE_RENAMEBRANCH, ++request_id);
     ser_oldName = serverarg_create(oldName);
     ser_newName = serverarg_create(newName);
 
@@ -370,7 +320,7 @@
 	Branch *retBranch = NULL;
 	ServerReply *reply;
 	ServerRequest *sr = request_create(GETBRANCH, r->uri->path, 
-		                           r->uri->username, PCMS_OPCODE_GETBRANCH);
+		                           r->uri->username, PCMS_OPCODE_GETBRANCH, ++request_id);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -394,13 +344,17 @@
 	serverrequest_AddArgument(sr, ser_bName);
 
 	reply = (ServerReply *)(invoke_server(r,sr));
-
-	/* We need the Branch to come back in the reply so we can
-	   update the 'serTrueName' field: */
-	retBranch = (Branch *)(vec_fetch(reply->return_objs,0)); 
-	retBranch->project = p;
+	if (reply->rtype == NET_ERROR)
+	    report_error(EX_Server, reply->data);
+	else {
+	    /* We need the Branch to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    retBranch = (Branch *)(vec_fetch(reply->return_objs,0)); 
+	    retBranch->project = p;
+	    return retBranch;
+	}
 
-	return retBranch;
+	return NULL;
 } /* end netrepository_GetBranch */
 
 /*
@@ -413,7 +367,7 @@
 	Branch *retBranch;
 	ServerReply *reply;
 	ServerRequest *sr = request_create(PETGETBRANCH, r->uri->path, 
-		                           r->uri->username, PCMS_OPCODE_PETGETBRANCH);
+		                           r->uri->username, PCMS_OPCODE_PETGETBRANCH, ++request_id);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -435,11 +389,16 @@
 	serverrequest_AddArgument(sr, ser_bName);
 
 	reply = (ServerReply *)(invoke_server(r,sr));
+	if (reply->rtype == NET_ERROR)
+	    report_error(EX_Server, reply->data);
+	else {
+	    /* We need the Branch to come back in the reply so we can
+	       update the 'serTrueName' field: */
+	    retBranch = (Branch *)(vec_fetch(reply->return_objs,0)); 
+	    return retBranch;
+	}
 
-	/* We need the Branch to come back in the reply so we can
-	   update the 'serTrueName' field: */
-	retBranch = (Branch *)(vec_fetch(reply->return_objs,0)); 
-	return retBranch;
+	return NULL;
 
 } /* end netrepository_PetGetBranch */
 
@@ -456,7 +415,7 @@
     
 	ServerReply *reply;
 	ServerRequest *sr = request_create(REVISEBRANCH, r->uri->path, 
-		                           r->uri->username, PCMS_OPCODE_REVISEBRANCH);
+		                           r->uri->username, PCMS_OPCODE_REVISEBRANCH, ++request_id);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -490,19 +449,23 @@
     StrVec *retStrVec;
     ServerReply *reply;
     ServerRequest *sr = request_create(LISTBRANCHPETNAMES, r->uri->path, 
-	                               r->uri->username, PCMS_OPCODE_LISTBRANCHPETNAMES);
+	                               r->uri->username, PCMS_OPCODE_LISTBRANCHPETNAMES, ++request_id);
 
     /* Now add the Branch as an argument to this request: */
     serverrequest_AddArgument(sr, b);
     serverrequest_AddArgument(sr, serverarg_create(pName));
 
     reply = (ServerReply *)(invoke_server(r,sr));
-	
-    /* Retrieve StrVec object from the reply in order to
-       update the Branch serTrueName field */
-    retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
+    if (reply->rtype == NET_ERROR)
+	report_error(EX_Server, reply->data);
+    else {    
+	/* Retrieve StrVec object from the reply in order to
+	   update the Branch serTrueName field */
+	retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
+	return retStrVec;
+    }
 
-    return retStrVec;
+    report NULL;
 
 } /* end netrepository_ListBranchPetNames */
 
@@ -512,19 +475,22 @@
     StrVec *retStrVec;
     ServerReply *reply;
     ServerRequest *sr = request_create(LISTBRANCHES, r->uri->path, 
-	                               r->uri->username, PCMS_OPCODE_LISTBRANCHES);
+	                               r->uri->username, PCMS_OPCODE_LISTBRANCHES, ++request_id);
 
     /* Now add the Project as an argument to this request: */
     serverrequest_AddArgument(sr, p);
 
     reply = (ServerReply *)(invoke_server(r,sr));
-	
-    /* Retrieve StrVec object from the reply in order to
-       update the Branch serTrueName field */
-    retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
-    report(reply->data);
-
-    return retStrVec;
+    if (reply->rtype == NET_ERROR) 
+	report_error(EX_Server, reply->data);
+    else {
+	/* Retrieve StrVec object from the reply in order to
+	   update the Branch serTrueName field */
+	retStrVec = (StrVec *)(vec_fetch(reply->return_objs,0)); 
+	report(reply->data);
+	return retStrVec;
+    }
+    return NULL;
 } /* end netrepository_ListBranches */
 
 const char *
@@ -533,7 +499,7 @@
     
 	ServerReply *reply;
 	ServerRequest *sr = request_create(REVISEENTITY, r->uri->path, 
-		                           r->uri->username, PCMS_OPCODE_REVISEENTITY);
+		                           r->uri->username, PCMS_OPCODE_REVISEENTITY, ++request_id);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -568,7 +534,7 @@
 	Serializable *retEnt;
 	ServerReply *reply;
 	ServerRequest *sr = request_create(GETENTITY, r->uri->path, 
-		                           r->uri->username, PCMS_OPCODE_GETENTITY);
+		                           r->uri->username, PCMS_OPCODE_GETENTITY, ++request_id);
 
 	/* Paranoia checks: */
 	if (r == NULL)
@@ -586,23 +552,28 @@
 	serverrequest_AddArgument(sr, ser_tName);
 
 	reply = (ServerReply *)(invoke_server(r,sr));
+	if (reply->rtype == NET_ERROR)
+	    report_error(EX_Server, reply->data);
+	else {
+	    /* retrieve the Entity/Change object from the reply: */
+	    retEnt = (Serializable *)(vec_fetch(reply->return_objs,0)); 
+		
+	    /* This next step is VERY IMPORTANT:  Realize that the entity
+	     * we're retrieving here can be an Entity or a Change object
+	     * (and others?) that do NOT serialize they're true name.  This
+	     * is because the true name is essentially the file name of the
+	     * entity and the entity itself doesn't need to store that.  Thus,
+	     * right before we send this entity back over the wire, we need
+	     * to set its true name accordingly.  Note that its true name
+	     * came as an input parameter to this function, so that makes it
+	     * easy.
+	     */
+	    retEnt->ser_trueName = tName;
 
-	/* retrieve the Entity/Change object from the reply: */
-	retEnt = (Serializable *)(vec_fetch(reply->return_objs,0)); 
-	    
-	/* This next step is VERY IMPORTANT:  Realize that the entity
-	 * we're retrieving here can be an Entity or a Change object
-	 * (and others?) that do NOT serialize they're true name.  This
-	 * is because the true name is essentially the file name of the
-	 * entity and the entity itself doesn't need to store that.  Thus,
-	 * right before we send this entity back over the wire, we need
-	 * to set its true name accordingly.  Note that its true name
-	 * came as an input parameter to this function, so that makes it
-	 * easy.
-	 */
-	retEnt->ser_trueName = tName;
+	    return retEnt;
+	}
 
-	return retEnt;
+	return NULL;
 
 } /* end netrepository_GetEntity */
 
@@ -637,43 +608,10 @@
   r->GetEntity = netrepository_GetEntity;
 
   r->cache = NULL;
-  r->channel = (Channel *)pcms_malloc(sizeof(Channel));
-}
-
-/*
- * Purpose of this function is when the socket read buffer is
- * full, but the entire message hasn't been read, we need to
- * execute multiple read's. 
- */
-char * read_entire_msg_from_socket(int socket, unsigned int expected) {
-
-    char *entire_msg = (char *)pcms_malloc(expected);
-    unsigned int numread = read(socket, entire_msg, expected);
-
-    if (numread < expected) {
-
-	unsigned int tindex = 0;
-	char *tmp_message = (char *)pcms_malloc(expected);
-	tmp_message = xstrdup(entire_msg);
 
-	/* Make sure we read entire message: */
-	while (numread < expected) {
-	    tindex = read(socket, entire_msg, expected);
-	    numread = numread + tindex;
-	    entire_msg[tindex] = '\0';
-	    tmp_message = xstrcat(tmp_message, entire_msg);
-	} /* end while numread < lmess */
-
-	/* Store the final (complete) message back in the
-	 * "entire message" variable:
-	 */
-	entire_msg = xstrdup(tmp_message);
-    
-    } /* end if numread < expected */
-
-    return entire_msg;
-
-} /* end read_entire_msg_from_socket */
+  /* Network protocol-specific: */
+  r->channel = create_tcp_channel(1);
+}
 
 Serializable * invoke_server (Repository *r, ServerRequest *request) {
 
@@ -691,21 +629,14 @@
 	/* Convert XML stream to char* to send over wire: */
 	net_buf = (char *)net_stream->data;
 	stream_close(net_stream);
-
-	/* Now send the data over the socket: */
-	sendBuff(r->channel->sockfd, net_buf);
-
-	/* Wait for the response: */
-	read (r->channel->sockfd, &incoming, sizeof(incoming));
-
-	if (incoming > 0) {
-	    rawReply = (char *)pcms_malloc(incoming);
 
-	    rawReply = read_entire_msg_from_socket(r->channel->sockfd, incoming);
+	/* Now send the data on the channel
+	   and wait for a reply: */
+	r->channel->send(r->channel, net_buf);
+	rawReply = r->channel->receive(r->channel);
 
-	    net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
-	    sreply = sdr_read(SERVERREPLY, net_stream);
-	} /* end if incoming > 0 */
+	net_stream = stream_fromstring(STREAM_XML, rawReply, strlen(rawReply));
+	sreply = sdr_read(SERVERREPLY, net_stream);
 	
 	return (Serializable *)sreply;
 } /* end invoke_Server */



1.12      +6 -3      pcms/src/server/pcmsserver.c

Index: pcmsserver.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/pcmsserver.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- pcmsserver.c	2001/11/20 23:34:45	1.11
+++ pcmsserver.c	2001/11/27 16:52:56	1.12
@@ -13,7 +13,7 @@
 #define SIZEOFREQUESTQUEUE 100
 
 void quitter(int);
-extern ServerReply *dispatch_request(ServerRequest *);
+extern void dispatch_request(ServerRequest *, MsgQueue *);
 
 int quit;
 
@@ -133,6 +133,9 @@
 				client_socket = accept(servfd, (struct sockaddr *) &cliaddr, &clientlen);
 				fprintf(stderr, "Processing request from %s\n", inet_ntoa(cliaddr.sin_addr)); 
 
+val = fcntl(client_socket, F_GETFL, 0);
+fcntl(client_socket, F_SETFL, val | O_NONBLOCK);
+
 				/* Save the client socket file descriptor in an "active" list: */
 				for (index = 0; index < MAX_CLIENTS; index++) {
 				    if (clients[index] < 0) {
@@ -176,7 +179,7 @@
 					    /* If we didn't read the entire socket stream the first time,
 					     * keep reading until we have the entire message.  
 					     */
-					    if (numread < lmess) {
+					    if (numread > 0 && numread < lmess) {
 
 						unsigned int tindex = 0;
 						char *tmp_message = (char *)pcms_malloc(lmess);
@@ -247,7 +250,7 @@
 		     ***********************************************/
 		    while (!IsEmptyMsgQueue(readq)) {
 			thisRequest = (ServerRequest *)GetFromMsgQueue(readq);
-			AddToMsgQueue(writeq, dispatch_request(thisRequest));
+			dispatch_request(thisRequest, writeq);
 			FD_SET(thisRequest->sockfd, &writeholder);
 		    } /* end while not IsEmptyMsgQueue */
 



1.1                  pcms/src/server/DispatchRequest.c

Index: DispatchRequest.c
===================================================================
#include <pcms.h>
#include "pcmsserver.h"
#include <./repos/pcmsrepos.h>
#include "MsgQueue.h"
#include <./common/ServerRequest.h>
#include <./common/ServerReply.h>
#include <./common/ServerStringArgument.h>

Repository *localRepos = NULL;
char *storeReposURI = NULL;

/* prototypes: */
void open_local_repos_if_needed(char *);
void dispatch_request (ServerRequest *, MsgQueue *);

void dispatch_request (ServerRequest *thisRequest, MsgQueue *q) {

    ServerReply *reply;
    Project *proj_arg;
    Branch *branch_arg;
    StrVec *proj_list;
    StrVec *branch_list;


    ServerStringArgument *string_arg;
    ServerStringArgument *string_arg2;
    void *ent_arg;
    void *ser_arg;


    if (!setjmp(jmp_buffer)) {

	switch (thisRequest->opcode) {

	    /*******************************************
	     *   CREATE A REPOSITORY:
	     *******************************************/
	    case PCMS_OPCODE_CREATEREPOSITORY:

		/* Idea is that repos should be a file repository on this
		*  server, so instantiate a FileRepos object for this command:
		*/
		open_local_repos_if_needed(thisRequest->repos_path);
		
		/* Now create a repository just like the File Repository: */
		localRepos->CreateRepository(localRepos);
		reply = reply_create(NET_REPLY,"Success.\n", thisRequest->sockfd, thisRequest->request_id);

		break;

	    /*******************************************
	     *   GET THE VERSION OF THIS SERVER:
	     *******************************************/
	    case PCMS_OPCODE_GETVERSION:

		/* Idea is that repos should be a file repository on this
		*  server, so instantiate a FileRepos object for this command:
		*/
		open_local_repos_if_needed(thisRequest->repos_path);

		/* Now use the local file repository to get the version
		*  and write that back to the client via its socket:
		*/
		reply = reply_create(NET_REPLY, localRepos->GetVersion(localRepos), thisRequest->sockfd, thisRequest->request_id);

		break;

	    /*******************************************
	     *   CREATE A BRANCH:
	     *******************************************/
	    case PCMS_OPCODE_CREATEBRANCH:

		/* Idea is that repos should be a file repository on this
		*  server, so instantiate a FileRepos object for this command:
		*/
		open_local_repos_if_needed(thisRequest->repos_path);
		
		/* This command requires a Project object and
		   a Branch object as arguments.  */
		if (vec_size(thisRequest->args) > 0) {
		    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));

		    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 1));

		    /* Now just do what the File Repository object would do: */
		    localRepos->CreateBranch(localRepos, proj_arg, branch_arg);

		    reply = reply_create(NET_REPLY,"Success: Branch Created.\n", thisRequest->sockfd, thisRequest->request_id);
		    serverreply_AddArgument(reply, branch_arg);
		} else {
		    reply = reply_create(NET_ERROR,"Error creating Branch: (no parent Branch specified).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if arguments are present */

		break;

	    /*******************************************
	     *   CREATE A PROJECT:
	     *******************************************/
	    case PCMS_OPCODE_CREATEPROJECT:

		/* Idea is that repos should be a file repository on this
		*  server, so instantiate a FileRepos object for this command:
		*/
		open_local_repos_if_needed(thisRequest->repos_path);
		
		/* This command requires a Project object as an argument.
		*  Make sure the argument is available
		*/
		if (vec_size(thisRequest->args) > 0) {
		    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));

		    /* Now just do what the File Repository object would do: */
		    localRepos->CreateProject(localRepos, proj_arg);

		    reply = reply_create(NET_REPLY,"Success: Project created.\n", thisRequest->sockfd, thisRequest->request_id);
		    serverreply_AddArgument(reply, proj_arg);

		} else {
		    reply = reply_create(NET_ERROR,"Error creating Project: (no argument specified).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if argument is present */

		break;

	    /**********************************************************
	     *   GET A PROJECT BASED ON TRUE NAME PASSED AS PARAMETER:
	     **********************************************************/
	    case PCMS_OPCODE_GETPROJECT:

		/* Idea is that repos should be a file repository on this
		*  server, so instantiate a FileRepos object for this command:
		*/
		open_local_repos_if_needed(thisRequest->repos_path);
		
		/* This command requires a ServerStringArgument object as an argument.
		*  Make sure the argument is available
		*/
		if (vec_size(thisRequest->args) > 0) {
		    /* The ServerStringArgument that's part of this request contains
		     * the trueName of the project that needs to be retrieved:
		     */
		    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));

		    /* Now just do what the File Repository object would do: */
		    proj_arg = localRepos->GetProject(localRepos, string_arg->data);

		    reply = reply_create(NET_REPLY,"Success: Project retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
		    serverreply_AddArgument(reply, proj_arg);

		} else {
		    reply = reply_create(NET_ERROR,"Error retrieving Project: (no proj name specified).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if argument is present */

		break;

	    /**********************************************************
	     *   GET A BRANCH BASED ON TRUE NAME PASSED AS PARAMETER:
	     **********************************************************/
	    case PCMS_OPCODE_GETBRANCH:

		/* Idea is that repos should be a file repository on this
		*  server, so instantiate a FileRepos object for this command:
		*/
		open_local_repos_if_needed(thisRequest->repos_path);
		
		/* This command requires a ServerStringArgument object as an argument.
		*  Make sure the argument is available
		*/
		if (vec_size(thisRequest->args) > 0) {

		    /*
		     * First argument should be the Project object:
		     */
		    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));

		    /* The ServerStringArgument that's part of this request contains
		     * the trueName of the branch that needs to be retrieved:
		     */
		    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));

		    /* Now just do what the File Repository object would do: */
		    branch_arg = localRepos->GetBranch(localRepos, proj_arg, string_arg->data);

		    reply = reply_create(NET_REPLY,"Success: Branch retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
		    serverreply_AddArgument(reply, branch_arg);

		} else {
		    reply = reply_create(NET_ERROR,"Error retrieving Branch: (no proj:branch specified).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if argument is present */

		break;

	    /**********************************************************
	     *   REVISE A BRANCH (IN SUPPORT OF COMMIT COMMAND):
	     **********************************************************/
	    case PCMS_OPCODE_REVISEBRANCH:

		/* Idea is that repos should be a file repository on this
		*  server, so instantiate a FileRepos object for this command:
		*/
		open_local_repos_if_needed(thisRequest->repos_path);
		
		/* This command requires Project and Branch objects as arguments.
		 * Make sure the arguments are available:
		 */
		if (vec_size(thisRequest->args) > 0) {

		    /* First argument should be the Project object: */
		    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));

		    /* The Branch object should be next: */
		    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 1));

		    /* Now just do what the File Repository object would do: */
		    localRepos->ReviseBranch(localRepos, proj_arg, branch_arg);

		    reply = reply_create(NET_REPLY,"Success: Branch updated.\n", thisRequest->sockfd, thisRequest->request_id);

		} else {
		    reply = reply_create(NET_ERROR,"Error updating Branch: (no proj:branch specified).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if argument is present */

		break;

	    /**********************************************************
	     *   RETURN AN ENTITY (IN SUPPORT OF UPDATE COMMAND):
	     **********************************************************/
	    case PCMS_OPCODE_GETENTITY:

		/* Idea is that repos should be a file repository on this
		*  server, so instantiate a FileRepos object for this command:
		*/
		open_local_repos_if_needed(thisRequest->repos_path);
		
		/* This command requires a ServerStringArgument object as an argument.
		*  Make sure the argument is available
		*/
		if (vec_size(thisRequest->args) > 0) {
		    /* The ServerStringArgument that's part of this request contains
		     * the trueName of the entity that needs to be retrieved:
		     */
		    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));

		    /* Now just do what the File Repository object would do: */
		    ent_arg = localRepos->GetEntity(localRepos, string_arg->data);
		    
		    reply = reply_create(NET_REPLY,"Success: Entity retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
		    serverreply_AddArgument(reply, ent_arg);

		} else {
		    reply = reply_create(NET_ERROR,"Error retrieving Entity: (no name specified).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if argument is present */

		break;

	    /**********************************************************
	     *   REVISE AN ENTITY (IN SUPPORT OF COMMIT COMMAND):
	     **********************************************************/
	    case PCMS_OPCODE_REVISEENTITY:

		/* Idea is that repos should be a file repository on this
		*  server, so instantiate a FileRepos object for this command:
		*/
		open_local_repos_if_needed(thisRequest->repos_path);
		
		/* This command requires a ServerStringArgument object as an argument.
		*  Make sure the argument is available
		*/
		if (vec_size(thisRequest->args) > 0) {
		    /* The Serializable object that's part of this request contains
		     * the info for the entity that needs to be revised:
		     */
		    ser_arg = (void *)(vec_fetch(thisRequest->args, 0));

		    /* Now just do what the File Repository object would do: */
		    reply = reply_create(NET_REPLY, localRepos->ReviseEntity(localRepos, 0, ser_arg), thisRequest->sockfd, thisRequest->request_id);

		} else {
		    reply = reply_create(NET_ERROR,"Error revising Entity: (no entity specified).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if argument is present */

		break;

	    /**********************************************************
	     *   GET A BRANCH BASED ON PET NAME PASSED AS PARAMETER:
	     **********************************************************/
	    case PCMS_OPCODE_PETGETBRANCH:

		open_local_repos_if_needed(thisRequest->repos_path);
		
		/* This command requires two arguments: */
		if (vec_size(thisRequest->args) > 0) {

		    /* The ServerStringArgument that's part of this request contains
		     * the pet name of the project that needs to be retrieved:
		     */
		    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));
		    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));

		    /* Now just do what the File Repository object would do: */
		    branch_arg = localRepos->PetGetBranch(localRepos, proj_arg, string_arg->data);

		    reply = reply_create(NET_REPLY,"Success: Branch retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
		    serverreply_AddArgument(reply, branch_arg);

		} else {
		    reply = reply_create(NET_ERROR,"Error retrieving Branch: (Not enough arguments passed to server).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if argument is present */

		break;

	    /**********************************************************
	     *   GET A PROJECT BASED ON PET NAME PASSED AS PARAMETER:
	     **********************************************************/
	    case PCMS_OPCODE_PETGETPROJECT:

		open_local_repos_if_needed(thisRequest->repos_path);
		
		/* This command requires a ServerStringArgument object as an argument.
		*  Make sure the argument is available
		*/
		if (vec_size(thisRequest->args) > 0) {
		    /* The ServerStringArgument that's part of this request contains
		     * the pet name of the project that needs to be retrieved:
		     */
		    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));

		    /* Now just do what the File Repository object would do: */
		    proj_arg = localRepos->PetGetProject(localRepos, string_arg->data);

		    reply = reply_create(NET_REPLY,"Success: Project retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
		    serverreply_AddArgument(reply, proj_arg);

		} else {
		    reply = reply_create(NET_ERROR,"Error retrieving Project: (Not enough arguments passed to server).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if argument is present */

		break;
		
	    /**********************************************************************
	     * RENAME A BRANCH:  NEEDS PROJECT, CURRENT NAME, NEW NAME AS ARGUMENTS:
	     *********************************************************************/
	    case PCMS_OPCODE_RENAMEBRANCH:

		open_local_repos_if_needed(thisRequest->repos_path);

		/* This command requires several objects as arguments. */
		if (vec_size(thisRequest->args) == 3) {
		    
		    /* First is the Project of interest: */
		    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));

		    /* Second is the old name of the branch: */
		    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));

		    /* Second is the new name of the branch: */
		    string_arg2 = (ServerStringArgument *)(vec_fetch(thisRequest->args, 2));

		    /* Now just do what the File Repository object would do: */
		    if (localRepos->PetRenameBranch (localRepos, proj_arg, string_arg->data, string_arg2->data) == -1)
			reply = reply_create(NET_REPLY,"Error renaming branch.\n", thisRequest->sockfd, thisRequest->request_id);
		    else
			reply = reply_create(NET_REPLY,"Success: Branch renamed.\n", thisRequest->sockfd, thisRequest->request_id);

		} else {
		    reply = reply_create(NET_ERROR,"Error renaming branch: (Not enough arguments passed to server).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if argument is present */

		break;

	    /**********************************************************************
	     * RENAME A PROJECT:  NEEDS CURRENT NAME, NEW NAME AS ARGUMENTS:
	     *********************************************************************/
	    case PCMS_OPCODE_RENAMEPROJECT:

		open_local_repos_if_needed(thisRequest->repos_path);

		/* This command requires several objects as arguments. */
		if (vec_size(thisRequest->args) == 2) {
		    
		    /* First is the old name of the project: */
		    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 0));

		    /* Second is the new name of the project: */
		    string_arg2 = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));

		    /* Now just do what the File Repository object would do: */
		    if (localRepos->PetRenameProject (localRepos, string_arg->data, string_arg2->data) == -1)
			reply = reply_create(NET_REPLY,"Error renaming Project:(name already exists).\n", thisRequest->sockfd, thisRequest->request_id);
		    else
			reply = reply_create(NET_REPLY,"Success: Project renamed.\n", thisRequest->sockfd, thisRequest->request_id);

		} else {
		    reply = reply_create(NET_ERROR,"Error renaming Project: (Not enough arguments passed to server).\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if checking if argument is present */

		break;

	    /*********************************************************
	     * GENERATE A LIST OF ALL BRANCHES FOR A GIVEN PROJECT:
	     ********************************************************/
	    case PCMS_OPCODE_LISTBRANCHES:

		open_local_repos_if_needed(thisRequest->repos_path);

		/* This command requires a Project argument. */
		if (vec_size(thisRequest->args) == 1) {
		    
		    /* First is the Project of interest: */
		    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));

		    /* Now just do what the File Repository object would do: */
		    branch_list = NULL;
		    branch_list = localRepos->ListBranches(localRepos, proj_arg);
		    if (branch_list == NULL)
			reply = reply_create(NET_REPLY,"Error accessing Branch.\n", thisRequest->sockfd, thisRequest->request_id);
		    else {
			reply = reply_create(NET_REPLY,"Success: Branches retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
			serverreply_AddArgument(reply, branch_list);
		    } /* end if branch_list == NULL*/
		} else {
		    reply = reply_create(NET_ERROR,"Error accessing Branch: (Not enough arguments passed to server.)\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if-else vec_size() > 0 */


		break;

	    /*********************************************************
	     * GENERATE A LIST OF PET NAMES FOR A GIVEN BRANCH:
	     ********************************************************/
	    case PCMS_OPCODE_LISTBRANCHPETNAMES:

		open_local_repos_if_needed(thisRequest->repos_path);

		/* This command requires a Branch argument. */
		if (vec_size(thisRequest->args) == 2) {
		    
		    /* First is the Project of interest: */
		    branch_arg = (Branch *)(vec_fetch(thisRequest->args, 0));

		    /* Next is the true name of the Branch's Project: */
		    string_arg = (ServerStringArgument *)(vec_fetch(thisRequest->args, 1));

		    /* Now just do what the File Repository object would do: */
		    branch_list = NULL;
		    branch_list = localRepos->ListBranchPetNames(localRepos, branch_arg, string_arg->data);
		    if (branch_list == NULL)
			reply = reply_create(NET_REPLY,"Error retrieving nickname of Branch.\n", thisRequest->sockfd, thisRequest->request_id);
		    else {
			reply = reply_create(NET_REPLY,"Success: Branch nickname retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
			serverreply_AddArgument(reply, branch_list);
		    } /* end if branch_list == NULL*/
		} else {
		    reply = reply_create(NET_ERROR,"Error retrieving nickname: (Not enough arguments passed to server.)\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if-else vec_size() > 0 */

		break;

	    /*********************************************************
	     * GENERATE A LIST OF ALL PROJECTS FOR A GIVEN REPOSITORY:
	     ********************************************************/
	    case PCMS_OPCODE_LISTPROJECTS:

		open_local_repos_if_needed(thisRequest->repos_path);

		/* Now just do what the File Repository object would do: */
		proj_list = NULL;
		proj_list = localRepos->ListProjects(localRepos);
		if (proj_list == NULL)
		    reply = reply_create(NET_REPLY,"Error trying to list Projects.\n", thisRequest->sockfd, thisRequest->request_id);
		else {
		    reply = reply_create(NET_REPLY,"Success: Projects retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
		    serverreply_AddArgument(reply, proj_list);
		} /* end if proj_list == NULL*/

		break;

	    /*********************************************************
	     * GENERATE A LIST OF PET NAMES FOR A GIVEN PROJECT:
	     ********************************************************/
	    case PCMS_OPCODE_LISTPROJPETNAMES:

		open_local_repos_if_needed(thisRequest->repos_path);

		/* This command requires a Project argument. */
		if (vec_size(thisRequest->args) == 1) {
		    
		    /* First is the Project of interest: */
		    proj_arg = (Project *)(vec_fetch(thisRequest->args, 0));

		    /* Now just do what the File Repository object would do: */
		    proj_list = NULL;
		    proj_list = localRepos->ListProjPetNames(localRepos, proj_arg);
		    if (proj_list == NULL)
			reply = reply_create(NET_REPLY,"Error trying to list Projects.\n", thisRequest->sockfd, thisRequest->request_id);
		    else {
			reply = reply_create(NET_REPLY,"Success: Project pet names retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
			serverreply_AddArgument(reply, proj_list);
		    } /* end if proj_list == NULL*/
		} else {
		    reply = reply_create(NET_REPLY,"Error retrieving nickname: (Not enough arguments passed to server.)\n", thisRequest->sockfd, thisRequest->request_id);
		} /* end if-else vec_size() > 0 */

		break;

	    default:
		break;
	} /* end switch block */

    /*****************************************
     * EXCEPTIONS ARE HANDLED HERE VIA LONGJMP:
     ****************************************/
    } else { 
	reply = reply_create(NET_ERROR, server_err_msg, thisRequest->sockfd, thisRequest->request_id);
    } /* end if setjmmp block */

    /* Now add reply to queue.  We do this here because
     * we may need to queue more than one ServerReply per
     * request.  
     */
    AddToMsgQueue(q, reply);

} /* end dispatch_request */

/*
 * Trying to reduce amount of work on the server-side:  only create/open
 * a local file repository if the one we currently have is not the one
 * the user needs. (We're using a cached file repository for efficiency.)
 */
void open_local_repos_if_needed(char *path) {

    char *localURIstr = (char *)pcms_malloc(strlen(path) + 5);

    localURIstr = xstrndup("file:",5);
    localURIstr = xstrcat(localURIstr, path);

    /* First check if local repository already exists: */
    if (localRepos == NULL) {
	localRepos = (Repository *)pcms_malloc(sizeof(Repository));
	localRepos = repository_open(localURIstr, 0);
	cachedfilerepository_init(localRepos);
	storeReposURI = xstrdup(localURIstr);
    /* If so, check if it points to one user wants: */
    } else if (!nmequal(storeReposURI, localURIstr)) {
	localRepos = (Repository *)pcms_malloc(sizeof(Repository));
	localRepos = repository_open(localURIstr, 0);
	cachedfilerepository_init(localRepos);
	storeReposURI = xstrdup(localURIstr);
    } /* end if-then-else */

} /* end open_local_repository */





From vandy@snocrash.cs.jhu.edu Tue Nov 27 11:59:21 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fARGxLV23948
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 27 Nov 2001 11:59:21 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id MAA00730;
	Tue, 27 Nov 2001 12:41:44 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fARGslR12384;
	Tue, 27 Nov 2001 11:54:47 -0500
Date: Tue, 27 Nov 2001 11:54:47 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200111271654.fARGslR12384@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server ReportError.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/11/27 11:54:47

  Added:       src/client ReportError.c
               src/server ReportError.c
  Log:
  

Revision  Changes    Path
1.1                  pcms/src/client/ReportError.c

Index: ReportError.c
===================================================================
#include <pcms.h>

/*
 * Client-side version of report-error.  This one
 * reports diagnostics and exits on fatal errors.
 */
void report_error(int isFatal, const char *fmt, ...)
{
  int the_errno = errno;
  va_list	args;
  va_start(args, fmt);

  fprintf(stderr, "PCMS: ");
  vfprintf(stderr, fmt, args);
  
  va_end(args);
  if (the_errno > 0) {
      if (the_errno < sys_nerr)
	fprintf(stderr, "PCMS: %s\n", sys_errlist[the_errno]);
      else
	fprintf(stderr, "PCMS: Errno was %d (no description available)\n", the_errno);
  }

  if (isFatal) {
    if (CurTmpFile)
      path_remove(CurTmpFile);
  
    exit(isFatal);
  }

} /* end report_error */




1.1                  pcms/src/server/ReportError.c

Index: ReportError.c
===================================================================
#include <pcms.h>
/*
 * This is the server's version of report-error. 
 * This version implements an exception handling
 * capability to properly capture and propagate
 * server-side errors back to the client.
 */
void
report_error(int isFatal, const char *fmt, ...)
{
    va_list   args;
    int num = 0;
    char dummy[150];

    va_start(args, fmt);
    va_end(args);

    num = vsnprintf(dummy, strlen(dummy), fmt, args);
    if (num > 0) {
	server_err_msg = (char *)pcms_malloc(num);
	vsprintf(server_err_msg, fmt, args);
    } /* end if num > 0 */

    longjmp(jmp_buffer, 1);

} /* end report_error */





From vandy@snocrash.cs.jhu.edu Tue Dec  4 09:52:34 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fB4EqY517299
	for <dcms-cvs@eros.cs.jhu.edu>; Tue, 4 Dec 2001 09:52:34 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id KAA00821;
	Tue, 4 Dec 2001 10:49:34 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fB4F2dN07828;
	Tue, 4 Dec 2001 10:02:39 -0500
Date: Tue, 4 Dec 2001 10:02:39 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200112041502.fB4F2dN07828@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/server DispatchRequest.c pcmsserver.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/12/04 10:02:39

  Modified:    src      globals.h pcms.h
               src/client pcms.c
               src/common ServerReply.c ServerReply.h ServerRequest.c
                        ServerRequest.h smsmalloc.c smsmalloc.h xmalloc.c
               src/repos Channel.c Channel.h
               src/repos/net NetRepository.c
               src/server DispatchRequest.c pcmsserver.c
  Log:
  Misc changes:  non-blocking server sockets; preliminary garbage collection framework with misc
  fixes to SMS package

Revision  Changes    Path
1.15      +1 -0      pcms/src/globals.h

Index: globals.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/globals.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- globals.h	2001/11/20 23:34:44	1.14
+++ globals.h	2001/12/04 15:02:38	1.15
@@ -35,6 +35,7 @@
 
 jmp_buf jmp_buffer;
 char *server_err_msg;
+sms_pool_t memory_pool;
 
 #define DBG_STARTUP  0x1u
 #define DBG_PATH     0x2u



1.14      +1 -0      pcms/src/pcms.h

Index: pcms.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/pcms.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- pcms.h	2001/11/20 23:34:44	1.13
+++ pcms.h	2001/12/04 15:02:38	1.14
@@ -47,6 +47,7 @@
 #include "common/EntityBits.h"
 #include "common/Entity.h"
 #include "common/TrueName.h"
+#include "common/smsmalloc.h"
 
 #include "globals.h"
 #include "common/path.h"



1.9       +2 -0      pcms/src/client/pcms.c

Index: pcms.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/pcms.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- pcms.c	2001/11/27 16:52:55	1.8
+++ pcms.c	2001/12/04 15:02:38	1.9
@@ -777,6 +777,8 @@
 
   top_of_stack = &dummy;
 
+  memory_pool = sms_mkpool(); 
+
 #ifdef MALLOC_DEBUG
   mcheck(0);
 #endif



1.6       +6 -9      pcms/src/common/ServerReply.c

Index: ServerReply.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerReply.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ServerReply.c	2001/11/27 16:52:55	1.5
+++ ServerReply.c	2001/12/04 15:02:38	1.6
@@ -8,12 +8,11 @@
 static void
 reply_serialize(SDR_stream *strm, const void *ob)
 {
-  const ServerReply *p = ob;
+  const ServerReply *p = (ServerReply *)ob;
   
   sdr_w_string("serTrueName", strm, p->serTrueName);
   sdr_w_ulong("rtype", strm, p->rtype);
   sdr_w_string("data", strm, p->data);
-  sdr_w_ulong("sock", strm, p->sockfd);
   sdr_w_ulong("reqid", strm, p->client_reqid);
   sdr_write("args", strm, p->return_objs);
   
@@ -27,26 +26,25 @@
   p->serType	    = &ServerReply_SerType;
   p->serTrueName    = sdr_r_string("serTrueName", strm);
   p->rtype	    = sdr_r_ulong("rtype", strm);
-  p->data           = sdr_r_string("data", strm);
-  p->sockfd	    = sdr_r_ulong("sock", strm);
+  p->data           = sdr_r_string("data", strm); 
   p->client_reqid   = sdr_r_ulong("reqid", strm);
-  p->return_objs    = sdr_read("args", strm);
+  p->return_objs = sdr_read("args", strm); 
 
   return p;
 }
 
 ServerReply *
-reply_create(int type, const char *reply, int socket, unsigned int reqid)
+reply_create(int type, const char *reply, unsigned int reqid)
 {
   ServerReply *p = (ServerReply *) pcms_malloc(sizeof(ServerReply));
 
   p->serType = &ServerReply_SerType;
   p->serTrueName = 0;
   p->rtype = type;
-  p->data = reply;
-  p->sockfd = socket;
+  p->data = reply; 
   p->client_reqid = reqid;
   p->return_objs = obvec_create();
+  p->channel = create_tcp_channel(2);;
 
   return p;
 } /* end reply_create */
@@ -59,7 +57,6 @@
   xprintf("SerTrueName:     %s\n", p->serTrueName);
   xprintf("Type       :     %d\n", p->rtype);
   xprintf("Data       :     %s\n", p->data);
-  xprintf("Socket     :     %d\n", p->sockfd);
   xprintf("Request ID :     %d\n", p->client_reqid);
 
   for (u = 0; u < vec_size(p->return_objs); u++)



1.6       +4 -3      pcms/src/common/ServerReply.h

Index: ServerReply.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerReply.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ServerReply.h	2001/11/27 16:52:55	1.5
+++ ServerReply.h	2001/12/04 15:02:38	1.6
@@ -1,7 +1,7 @@
 /* Copyright (C) 2000, The EROS Group, LLC. */
 #ifndef __SERVERREPLY_H__
 #define __SERVERREPLY_H__
-
+#include <repos/pcmsrepos.h>
 #include "pcms_opcode.h"
 
 typedef struct ServerReply {
@@ -10,12 +10,13 @@
   int rtype;  /* info-only, error, or successful reply */
   const char *data;
   unsigned int client_reqid;
-  int sockfd;
   ObVec *return_objs;
 
+  /* This part is NOT serialized: */
+  Channel *channel;
 } ServerReply;
 
-ServerReply *reply_create (int type, const char *reply, int socket, unsigned int reqid);
+ServerReply *reply_create (int type, const char *reply, unsigned int reqid);
 
 /*
  * Need method to add return objects:



1.4       +1 -4      pcms/src/common/ServerRequest.c

Index: ServerRequest.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerRequest.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServerRequest.c	2001/11/27 16:52:55	1.3
+++ ServerRequest.c	2001/12/04 15:02:38	1.4
@@ -16,7 +16,6 @@
   sdr_w_ulong("reqid", strm, p->request_id);
   sdr_w_string("path", strm, p->repos_path);
   sdr_w_string("user", strm, p->username);
-  sdr_w_ulong("sock", strm, p->sockfd);
   sdr_write("args", strm, p->args);
   
 } /* end request_serialize */
@@ -33,7 +32,6 @@
   p->request_id     = sdr_r_ulong("reqid", strm);
   p->repos_path     = sdr_r_string("path", strm);
   p->username       = sdr_r_string("user", strm);
-  p->sockfd         = sdr_r_ulong("sock", strm);
   p->args	    = sdr_read("args", strm);
 
   return p;
@@ -52,7 +50,7 @@
   p->request_id = reqid;
   p->repos_path = path;
   p->username = user;
-  p->sockfd = 0;  /* will be assigned by server */
+  p->channel = NULL;  /* will be assigned by server */
 
   p->args = obvec_create();
 
@@ -70,7 +68,6 @@
   xprintf("SerTrueName:     %s\n", p->serTrueName);
   xprintf("Repos Path:      %s\n", p->repos_path);
   xprintf("Username:        %s\n", p->username);
-  xprintf("Socket:          %d\n", p->sockfd);
 
   for (u = 0; u < vec_size(p->args); u++)
       sdr_show(vec_fetch(p->args, u));



1.4       +4 -1      pcms/src/common/ServerRequest.h

Index: ServerRequest.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/ServerRequest.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServerRequest.h	2001/11/27 16:52:55	1.3
+++ ServerRequest.h	2001/12/04 15:02:38	1.4
@@ -1,4 +1,5 @@
 /* Copyright (C) 2000, The EROS Group, LLC. */
+#include <repos/pcmsrepos.h>
 #include "pcms_opcode.h"
 
 typedef struct ServerRequest {
@@ -9,12 +10,14 @@
   unsigned int request_id;
   char *repos_path;
   char *username;
-  int sockfd;
 
   /* Some commands take arguments.  Store
    * any such arguments here:
    */
   ObVec *args;
+
+  /* This part is NOT serialized: */
+  Channel *channel;
 
 } ServerRequest;
 



1.4       +72 -15    pcms/src/common/smsmalloc.c

Index: smsmalloc.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/smsmalloc.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- smsmalloc.c	2001/11/21 21:55:12	1.3
+++ smsmalloc.c	2001/12/04 15:02:38	1.4
@@ -63,7 +63,8 @@
   assert(v);
   bzero(v, sz);
 
-  if ((cv - (char *)0) < (sms_alloc_base - (char *)0))
+  /*  if ((cv - (char *)0) < (sms_alloc_base - (char *)0)) */
+  if (sms_alloc_base  > cv) 
     sms_alloc_base = cv;
 
   if ((cv - (char *)0) > (sms_alloc_bound - (char *)0))
@@ -93,7 +94,7 @@
 {
   obhdr *hdr = sms_do_malloc(sizeof(obhdr) + sz);
 
-  sms_inithdr(hdr, pool, sizeof(pool));
+  sms_inithdr(hdr, pool, sizeof(obhdr) + sz);
 
   /* Link it into the pool: */
   hdr->prev = &pool->hdr;
@@ -147,10 +148,12 @@
 
   hdr->refcount--;
 
-  if (hdr->refcount == 0 && hdr->pPool->isLive == 0)
-    sms_free(hdr);
+  if (hdr->refcount == 0 && hdr->pPool->isLive == 0) {
+    hdr->mark = 0;
+    sms_free(((char *)hdr) + sizeof(obhdr));
+  }
 
-  if (pPool->isLive == 0)
+  if (pPool->isLive == 0 && pPool->obcount == 0)
     sms_release(pPool);
 }
 
@@ -158,10 +161,17 @@
 inline static int
 sms_valid_ptr(sms_pool_t pool, void *v)
 {
-  obhdr *hdr = HDR(v);
-  char *cv = (char *)v;
+  obhdr *hdr;
+  char *cv;
+
+  if (v == NULL)
+      return 0;
+
+  hdr = HDR(v);
+  cv = (char *)v;
 
-  if ((cv - (char *)0) < (sms_alloc_base - (char *)0))
+  /* if ((cv - (char *)0) < (sms_alloc_base - (char *)0)) */
+  if ((sms_alloc_base - (char *)0) > (cv - (char *)0))
     return 0;
 
   if ((cv - (char *)0) > (sms_alloc_bound - (char *)0))
@@ -196,7 +206,7 @@
 
   for (i = 0; i < maxPtrs; i++) {
     if (sms_valid_ptr(hdr->pPool, ptrs[i])) {
-      obhdr *ob = ptrs[i];
+      obhdr *ob = ptrs[i] - sizeof(obhdr);
       if (ob->mark == 0)
 	sms_mark(ob);
     }
@@ -226,15 +236,62 @@
     if (hdr->refcount && !hdr->mark)
       sms_mark(hdr);
 
-  for (hdr = pool->hdr.next; hdr != &pool->hdr; hdr = hdr->next)
-    if (!hdr->mark)
-      sms_free(hdr);
+  /* Problem with using a for-loop here is that the memory is
+     freed before returning to the for loop to compute the next
+     iterator. */
+/*  for (hdr = pool->hdr.next; hdr != &pool->hdr; hdr = hdr->next) */
+    hdr = pool->hdr.next;
+    do {
+	hdr = hdr->next;
+	if (!hdr->prev->mark)
+	  sms_free(((char *)(hdr->prev)) + sizeof(obhdr));
+    } while(hdr != &pool->hdr);
 #else
-  for (hdr = pool->hdr.next; hdr != &pool->hdr; hdr = hdr->next)
-    if (!hdr->refcount)
-      sms_free(hdr);
+    hdr = pool->hdr.next;
+    do {
+	hdr = hdr->next;
+	if (!hdr->prev->refcount)
+	  sms_free(((char *)(hdr->prev)) + sizeof(obhdr));
+    } while(hdr != &pool->hdr);
 #endif
 
   if (pool->obcount == 0)
     free(pool);
 }
+
+unsigned 
+sms_pool_alive(sms_pool_t pool) {
+    return (pool->isLive);
+}
+
+/* sms_realloc(pool, ob, sz): Resize a memory block for a pointer that has 
+ * already been assigned via sms_malloc.  This is just the 'sms' wrapper
+ * to the realloc() call. */
+void *
+sms_realloc(sms_pool_t pool, void *ob, size_t sz) {
+    
+  obhdr *hdr;
+
+  /* Make sure size is positive:*/
+  sz = sz ? sz : 1;
+
+  /* If obj ptr is null, just call the malloc function:*/
+  if (ob == NULL)
+      return (sms_malloc(pool, sz));
+
+  /* hdr should already exist in the pool:*/
+  hdr = HDR(ob);
+  ob = (void *)realloc(ob, sz);
+
+  /* zero out any new memory: */
+  if (sz + sizeof(obhdr) > hdr->sz) {
+      size_t newsize = sz + sizeof(obhdr) - hdr->sz;
+      memset((char *)(ob + hdr->sz - sizeof(obhdr)), 0, newsize);
+  } 
+
+  /* Now update header with new size: */
+  hdr->sz = sizeof(obhdr) + sz;
+  
+  return (void *) (((char *)hdr) + sizeof(obhdr));
+}
+



1.4       +12 -0     pcms/src/common/smsmalloc.h

Index: smsmalloc.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/smsmalloc.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- smsmalloc.h	2001/11/21 21:55:12	1.3
+++ smsmalloc.h	2001/12/04 15:02:38	1.4
@@ -1,3 +1,6 @@
+#ifndef __SMSMALLOC_H__
+#define __SMSMALLOC_H__
+
 /* Copyright (C) 2001, Johns Hopkins University. */
 
 #ifndef SMS_IMPLEMENTATION
@@ -14,6 +17,10 @@
  * with the specified bulk-reclaim pool /pool/. */
 extern void *sms_malloc(sms_pool_t pool, size_t sz);
 
+/* sms_realloc(tag, ob, sz): reallocate memory for previously 
+ * assigned pointer. */
+extern void *sms_realloc(sms_pool_t pool, void *ob, size_t sz);
+
 /* sms_incref(ob): increment the reference count associated with /ob/,
  * preventing reclamation when its pool is released. */
 extern void sms_incref(void *ob);
@@ -30,3 +37,8 @@
  * are non-zero will be moved to the null pool and freed when their
  * reference count goes to zero. */
 extern void sms_release(sms_pool_t pool);
+
+extern unsigned sms_pool_alive(sms_pool_t pool);
+
+#endif
+



1.3       +4 -2      pcms/src/common/xmalloc.c

Index: xmalloc.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/xmalloc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- xmalloc.c	2001/10/19 03:44:10	1.2
+++ xmalloc.c	2001/12/04 15:02:38	1.3
@@ -12,7 +12,8 @@
    * allocates empty storage. */
   size = size ? size : 1;
   
-  vp = malloc(size);
+  vp = malloc(size); 
+/*  vp = sms_malloc(memory_pool, size); */
 
   bzero(vp, size);
 
@@ -38,7 +39,8 @@
 #endif
 
   if (vp)
-    vp = realloc(vp, size);
+    vp = realloc(vp, size); 
+/*    vp = sms_realloc(memory_pool, vp, size); */
   else
     vp = pcms_malloc(size);
 



1.2       +12 -0     pcms/src/repos/Channel.c

Index: Channel.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/Channel.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Channel.c	2001/11/27 16:52:55	1.1
+++ Channel.c	2001/12/04 15:02:38	1.2
@@ -30,6 +30,7 @@
     c->setup = tcp_setup;
     c->send = tcp_send;
     c->receive = tcp_receive;
+    c->memory_pool = NULL;
     return c;
 } /* end create_tcp_channel */
 
@@ -163,4 +164,15 @@
 
 } /* end read_entire_msg_from_socket */
 
+void SetMemoryPool (Channel *c, sms_pool_t p) {
+    c->memory_pool = p;
+} /* end SetMemoryPool */
+
+void FlushMemoryPool (Channel *c) {
+    sms_release(c->memory_pool);
+} /* end FlushMemoryPool */
+
+sms_pool_t GetMemoryPool(Channel *c) {
+   return c->memory_pool;
+} /* end GetMemoryPool */
 



1.2       +4 -0      pcms/src/repos/Channel.h

Index: Channel.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/Channel.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Channel.h	2001/11/27 16:52:55	1.1
+++ Channel.h	2001/12/04 15:02:38	1.2
@@ -11,6 +11,7 @@
 struct Channel {
     int channelID;
     int sockfd;
+    sms_pool_t memory_pool;
     int (*setup)(Channel *, URI *);
     int (*send)(Channel *, const void *);
     char *(*receive)(Channel *);
@@ -23,6 +24,9 @@
 int tcp_setup(Channel *, URI *);
 int tcp_send(Channel *, const void *);
 char *tcp_receive(Channel *);
+void SetMemoryPool(Channel *, sms_pool_t);
+void FlushMemoryPool(Channel *);
+sms_pool_t GetMemoryPool(Channel *);
 
 #endif
 



1.14      +2 -1      pcms/src/repos/net/NetRepository.c

Index: NetRepository.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/net/NetRepository.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- NetRepository.c	2001/11/27 16:52:55	1.13
+++ NetRepository.c	2001/12/04 15:02:38	1.14
@@ -75,6 +75,7 @@
 
 	report(reply->data);
 
+	return 0;
 } /* end netrepository_CreateProject */
 
 /*
@@ -465,7 +466,7 @@
 	return retStrVec;
     }
 
-    report NULL;
+    return NULL;
 
 } /* end netrepository_ListBranchPetNames */
 



1.2       +42 -38    pcms/src/server/DispatchRequest.c

Index: DispatchRequest.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/DispatchRequest.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DispatchRequest.c	2001/11/27 16:52:56	1.1
+++ DispatchRequest.c	2001/12/04 15:02:38	1.2
@@ -30,6 +30,8 @@
 
     if (!setjmp(jmp_buffer)) {
 
+	memory_pool = GetMemoryPool(thisRequest->channel);
+
 	switch (thisRequest->opcode) {
 
 	    /*******************************************
@@ -44,7 +46,7 @@
 		
 		/* Now create a repository just like the File Repository: */
 		localRepos->CreateRepository(localRepos);
-		reply = reply_create(NET_REPLY,"Success.\n", thisRequest->sockfd, thisRequest->request_id);
+		reply = reply_create(NET_REPLY,"Success.\n", thisRequest->request_id);
 
 		break;
 
@@ -61,7 +63,7 @@
 		/* Now use the local file repository to get the version
 		*  and write that back to the client via its socket:
 		*/
-		reply = reply_create(NET_REPLY, localRepos->GetVersion(localRepos), thisRequest->sockfd, thisRequest->request_id);
+		reply = reply_create(NET_REPLY, localRepos->GetVersion(localRepos), thisRequest->request_id);
 
 		break;
 
@@ -85,10 +87,10 @@
 		    /* Now just do what the File Repository object would do: */
 		    localRepos->CreateBranch(localRepos, proj_arg, branch_arg);
 
-		    reply = reply_create(NET_REPLY,"Success: Branch Created.\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Success: Branch Created.\n", thisRequest->request_id);
 		    serverreply_AddArgument(reply, branch_arg);
 		} else {
-		    reply = reply_create(NET_ERROR,"Error creating Branch: (no parent Branch specified).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error creating Branch: (no parent Branch specified).\n", thisRequest->request_id);
 		} /* end if checking if arguments are present */
 
 		break;
@@ -112,11 +114,11 @@
 		    /* Now just do what the File Repository object would do: */
 		    localRepos->CreateProject(localRepos, proj_arg);
 
-		    reply = reply_create(NET_REPLY,"Success: Project created.\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Success: Project created.\n", thisRequest->request_id);
 		    serverreply_AddArgument(reply, proj_arg);
 
 		} else {
-		    reply = reply_create(NET_ERROR,"Error creating Project: (no argument specified).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error creating Project: (no argument specified).\n", thisRequest->request_id);
 		} /* end if checking if argument is present */
 
 		break;
@@ -143,11 +145,11 @@
 		    /* Now just do what the File Repository object would do: */
 		    proj_arg = localRepos->GetProject(localRepos, string_arg->data);
 
-		    reply = reply_create(NET_REPLY,"Success: Project retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Success: Project retrieved.\n", thisRequest->request_id);
 		    serverreply_AddArgument(reply, proj_arg);
 
 		} else {
-		    reply = reply_create(NET_ERROR,"Error retrieving Project: (no proj name specified).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error retrieving Project: (no proj name specified).\n", thisRequest->request_id);
 		} /* end if checking if argument is present */
 
 		break;
@@ -180,11 +182,11 @@
 		    /* Now just do what the File Repository object would do: */
 		    branch_arg = localRepos->GetBranch(localRepos, proj_arg, string_arg->data);
 
-		    reply = reply_create(NET_REPLY,"Success: Branch retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Success: Branch retrieved.\n", thisRequest->request_id);
 		    serverreply_AddArgument(reply, branch_arg);
 
 		} else {
-		    reply = reply_create(NET_ERROR,"Error retrieving Branch: (no proj:branch specified).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error retrieving Branch: (no proj:branch specified).\n", thisRequest->request_id);
 		} /* end if checking if argument is present */
 
 		break;
@@ -213,10 +215,10 @@
 		    /* Now just do what the File Repository object would do: */
 		    localRepos->ReviseBranch(localRepos, proj_arg, branch_arg);
 
-		    reply = reply_create(NET_REPLY,"Success: Branch updated.\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Success: Branch updated.\n", thisRequest->request_id);
 
 		} else {
-		    reply = reply_create(NET_ERROR,"Error updating Branch: (no proj:branch specified).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error updating Branch: (no proj:branch specified).\n", thisRequest->request_id);
 		} /* end if checking if argument is present */
 
 		break;
@@ -243,11 +245,11 @@
 		    /* Now just do what the File Repository object would do: */
 		    ent_arg = localRepos->GetEntity(localRepos, string_arg->data);
 		    
-		    reply = reply_create(NET_REPLY,"Success: Entity retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Success: Entity retrieved.\n", thisRequest->request_id);
 		    serverreply_AddArgument(reply, ent_arg);
 
 		} else {
-		    reply = reply_create(NET_ERROR,"Error retrieving Entity: (no name specified).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error retrieving Entity: (no name specified).\n", thisRequest->request_id);
 		} /* end if checking if argument is present */
 
 		break;
@@ -272,10 +274,10 @@
 		    ser_arg = (void *)(vec_fetch(thisRequest->args, 0));
 
 		    /* Now just do what the File Repository object would do: */
-		    reply = reply_create(NET_REPLY, localRepos->ReviseEntity(localRepos, 0, ser_arg), thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY, localRepos->ReviseEntity(localRepos, 0, ser_arg), thisRequest->request_id);
 
 		} else {
-		    reply = reply_create(NET_ERROR,"Error revising Entity: (no entity specified).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error revising Entity: (no entity specified).\n", thisRequest->request_id);
 		} /* end if checking if argument is present */
 
 		break;
@@ -299,11 +301,11 @@
 		    /* Now just do what the File Repository object would do: */
 		    branch_arg = localRepos->PetGetBranch(localRepos, proj_arg, string_arg->data);
 
-		    reply = reply_create(NET_REPLY,"Success: Branch retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Success: Branch retrieved.\n", thisRequest->request_id);
 		    serverreply_AddArgument(reply, branch_arg);
 
 		} else {
-		    reply = reply_create(NET_ERROR,"Error retrieving Branch: (Not enough arguments passed to server).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error retrieving Branch: (Not enough arguments passed to server).\n", thisRequest->request_id);
 		} /* end if checking if argument is present */
 
 		break;
@@ -327,11 +329,11 @@
 		    /* Now just do what the File Repository object would do: */
 		    proj_arg = localRepos->PetGetProject(localRepos, string_arg->data);
 
-		    reply = reply_create(NET_REPLY,"Success: Project retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Success: Project retrieved.\n", thisRequest->request_id);
 		    serverreply_AddArgument(reply, proj_arg);
 
 		} else {
-		    reply = reply_create(NET_ERROR,"Error retrieving Project: (Not enough arguments passed to server).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error retrieving Project: (Not enough arguments passed to server).\n", thisRequest->request_id);
 		} /* end if checking if argument is present */
 
 		break;
@@ -357,12 +359,12 @@
 
 		    /* Now just do what the File Repository object would do: */
 		    if (localRepos->PetRenameBranch (localRepos, proj_arg, string_arg->data, string_arg2->data) == -1)
-			reply = reply_create(NET_REPLY,"Error renaming branch.\n", thisRequest->sockfd, thisRequest->request_id);
+			reply = reply_create(NET_REPLY,"Error renaming branch.\n", thisRequest->request_id);
 		    else
-			reply = reply_create(NET_REPLY,"Success: Branch renamed.\n", thisRequest->sockfd, thisRequest->request_id);
+			reply = reply_create(NET_REPLY,"Success: Branch renamed.\n", thisRequest->request_id);
 
 		} else {
-		    reply = reply_create(NET_ERROR,"Error renaming branch: (Not enough arguments passed to server).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error renaming branch: (Not enough arguments passed to server).\n", thisRequest->request_id);
 		} /* end if checking if argument is present */
 
 		break;
@@ -385,12 +387,12 @@
 
 		    /* Now just do what the File Repository object would do: */
 		    if (localRepos->PetRenameProject (localRepos, string_arg->data, string_arg2->data) == -1)
-			reply = reply_create(NET_REPLY,"Error renaming Project:(name already exists).\n", thisRequest->sockfd, thisRequest->request_id);
+			reply = reply_create(NET_REPLY,"Error renaming Project:(name already exists).\n", thisRequest->request_id);
 		    else
-			reply = reply_create(NET_REPLY,"Success: Project renamed.\n", thisRequest->sockfd, thisRequest->request_id);
+			reply = reply_create(NET_REPLY,"Success: Project renamed.\n", thisRequest->request_id);
 
 		} else {
-		    reply = reply_create(NET_ERROR,"Error renaming Project: (Not enough arguments passed to server).\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error renaming Project: (Not enough arguments passed to server).\n", thisRequest->request_id);
 		} /* end if checking if argument is present */
 
 		break;
@@ -412,13 +414,13 @@
 		    branch_list = NULL;
 		    branch_list = localRepos->ListBranches(localRepos, proj_arg);
 		    if (branch_list == NULL)
-			reply = reply_create(NET_REPLY,"Error accessing Branch.\n", thisRequest->sockfd, thisRequest->request_id);
+			reply = reply_create(NET_REPLY,"Error accessing Branch.\n", thisRequest->request_id);
 		    else {
-			reply = reply_create(NET_REPLY,"Success: Branches retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
+			reply = reply_create(NET_REPLY,"Success: Branches retrieved.\n", thisRequest->request_id);
 			serverreply_AddArgument(reply, branch_list);
 		    } /* end if branch_list == NULL*/
 		} else {
-		    reply = reply_create(NET_ERROR,"Error accessing Branch: (Not enough arguments passed to server.)\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error accessing Branch: (Not enough arguments passed to server.)\n", thisRequest->request_id);
 		} /* end if-else vec_size() > 0 */
 
 
@@ -444,13 +446,13 @@
 		    branch_list = NULL;
 		    branch_list = localRepos->ListBranchPetNames(localRepos, branch_arg, string_arg->data);
 		    if (branch_list == NULL)
-			reply = reply_create(NET_REPLY,"Error retrieving nickname of Branch.\n", thisRequest->sockfd, thisRequest->request_id);
+			reply = reply_create(NET_REPLY,"Error retrieving nickname of Branch.\n", thisRequest->request_id);
 		    else {
-			reply = reply_create(NET_REPLY,"Success: Branch nickname retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
+			reply = reply_create(NET_REPLY,"Success: Branch nickname retrieved.\n", thisRequest->request_id);
 			serverreply_AddArgument(reply, branch_list);
 		    } /* end if branch_list == NULL*/
 		} else {
-		    reply = reply_create(NET_ERROR,"Error retrieving nickname: (Not enough arguments passed to server.)\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_ERROR,"Error retrieving nickname: (Not enough arguments passed to server.)\n", thisRequest->request_id);
 		} /* end if-else vec_size() > 0 */
 
 		break;
@@ -466,9 +468,9 @@
 		proj_list = NULL;
 		proj_list = localRepos->ListProjects(localRepos);
 		if (proj_list == NULL)
-		    reply = reply_create(NET_REPLY,"Error trying to list Projects.\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Error trying to list Projects.\n", thisRequest->request_id);
 		else {
-		    reply = reply_create(NET_REPLY,"Success: Projects retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Success: Projects retrieved.\n", thisRequest->request_id);
 		    serverreply_AddArgument(reply, proj_list);
 		} /* end if proj_list == NULL*/
 
@@ -491,13 +493,13 @@
 		    proj_list = NULL;
 		    proj_list = localRepos->ListProjPetNames(localRepos, proj_arg);
 		    if (proj_list == NULL)
-			reply = reply_create(NET_REPLY,"Error trying to list Projects.\n", thisRequest->sockfd, thisRequest->request_id);
+			reply = reply_create(NET_REPLY,"Error trying to list Projects.\n", thisRequest->request_id);
 		    else {
-			reply = reply_create(NET_REPLY,"Success: Project pet names retrieved.\n", thisRequest->sockfd, thisRequest->request_id);
+			reply = reply_create(NET_REPLY,"Success: Project pet names retrieved.\n", thisRequest->request_id);
 			serverreply_AddArgument(reply, proj_list);
 		    } /* end if proj_list == NULL*/
 		} else {
-		    reply = reply_create(NET_REPLY,"Error retrieving nickname: (Not enough arguments passed to server.)\n", thisRequest->sockfd, thisRequest->request_id);
+		    reply = reply_create(NET_REPLY,"Error retrieving nickname: (Not enough arguments passed to server.)\n", thisRequest->request_id);
 		} /* end if-else vec_size() > 0 */
 
 		break;
@@ -510,13 +512,15 @@
      * EXCEPTIONS ARE HANDLED HERE VIA LONGJMP:
      ****************************************/
     } else { 
-	reply = reply_create(NET_ERROR, server_err_msg, thisRequest->sockfd, thisRequest->request_id);
+	reply = reply_create(NET_ERROR, server_err_msg, thisRequest->request_id);
     } /* end if setjmmp block */
 
     /* Now add reply to queue.  We do this here because
      * we may need to queue more than one ServerReply per
      * request.  
      */
+    reply->channel = thisRequest->channel;
+    SetMemoryPool(reply->channel, memory_pool);
     AddToMsgQueue(q, reply);
 
 } /* end dispatch_request */



1.13      +100 -58   pcms/src/server/pcmsserver.c

Index: pcmsserver.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/server/pcmsserver.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- pcmsserver.c	2001/11/27 16:52:56	1.12
+++ pcmsserver.c	2001/12/04 15:02:39	1.13
@@ -35,6 +35,14 @@
 *   -- dequeue, parse, and execute
 *   -- add result to reply queue
 ****************************************************/
+#define close_client(i)  close(sockfd); \
+			FD_CLR(sockfd, &readholder); \
+			clients[i] = -1; \
+			lmess[i] = 0; \
+			so_far[i] = 0; \
+			message[i] = NULL; \
+			have_length[i] = FALSE; 
+
 int main() {
 	struct sockaddr_in servaddr, cliaddr;
 	int servfd;
@@ -43,11 +51,14 @@
 	int clients[MAX_CLIENTS];
 	int index;
 	int select_ready;
-	char *message;
-	unsigned int lmess;
+	char *message[MAX_CLIENTS];
+	char *tmp_mess;
+	unsigned int lmess[MAX_CLIENTS];
 	int i, readres,clientlen;
 	struct sigaction quit_action;
 	struct timeval tv;
+	bool have_length[MAX_CLIENTS];
+	unsigned int so_far[MAX_CLIENTS];
 	
 int val;
 unsigned int numread;
@@ -71,6 +82,7 @@
 int max_index_into_clients;
 int max_sockfd_so_far;
 char *tooManyClients = "Connection refused... too many clients.";
+sms_pool_t nextPool;
 
 	quit_action.sa_handler = (&quitter);
 	
@@ -80,17 +92,15 @@
 	
 	for (i = 0; i < MAX_CLIENTS; i++) {
 	    clients[i] = -1;
+	    have_length[i] = FALSE;
+	    lmess[i] = 0;
+	    so_far[i] = 0;
 	}
 
 	if ((servfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
 		fprintf(stderr, "Socket Creation Error\n");
 		exit(errno);
 	}
-/* Need non-blocking I/O for the sockets created by accept: */
-	/***
-val = fcntl(servfd, F_GETFL, 0);
-fcntl(servfd, F_SETFL, val | O_NONBLOCK);
-***/
 
 	bzero(&servaddr, sizeof(servaddr));
 	bzero(&cliaddr, sizeof(cliaddr));
@@ -116,6 +126,7 @@
 	max_sockfd_so_far = servfd;
 	max_index_into_clients = -1;
 	
+	/*  memory_pool = sms_mkpool(); */
 	while(!quit) {
 		incomingset = readholder;
 		outgoingset = writeholder;
@@ -133,8 +144,9 @@
 				client_socket = accept(servfd, (struct sockaddr *) &cliaddr, &clientlen);
 				fprintf(stderr, "Processing request from %s\n", inet_ntoa(cliaddr.sin_addr)); 
 
-val = fcntl(client_socket, F_GETFL, 0);
-fcntl(client_socket, F_SETFL, val | O_NONBLOCK);
+				/* Make the client socket non-blocking to prevent DOS attacks: */
+				val = fcntl(client_socket, F_GETFL, 0);
+				fcntl(client_socket, F_SETFL, val | O_NONBLOCK);
 
 				/* Save the client socket file descriptor in an "active" list: */
 				for (index = 0; index < MAX_CLIENTS; index++) {
@@ -164,80 +176,110 @@
 
 			/* After accepting a client's connect, check if there's still other pending events: */
 			if (select_ready > 0) {  
+
 			    for (i = 0; i <= max_index_into_clients; i++) {
 				if ( (sockfd = clients[i]) >= 0) {
 				    if (FD_ISSET(sockfd, &incomingset)) {
-					if ( (readres = read(sockfd, &lmess, sizeof(lmess))) == 0) { 
-					    close(sockfd);
-					    FD_CLR(sockfd, &readholder);
-					    clients[i] = -1;
-					} else {
-					    /* Allocate just enough space to read incoming message: */
-					    message = (char *)pcms_malloc(lmess);
-					    numread = read(sockfd, message, lmess);
-
-					    /* If we didn't read the entire socket stream the first time,
-					     * keep reading until we have the entire message.  
-					     */
-					    if (numread > 0 && numread < lmess) {
-
-						unsigned int tindex = 0;
-						char *tmp_message = (char *)pcms_malloc(lmess);
-						tmp_message = xstrdup(message);
-
-						/* Make sure we read entire message: */
-						while (numread < lmess) {
-						    tindex = read(sockfd, message, lmess);
-						    numread = numread + tindex;
-						    message[tindex] = '\0';
-						    tmp_message = xstrcat(tmp_message, message);
-						} /* end while numread < lmess */
-
-						/* Store the final (complete) message back in the
-						 * "message" variable:
-						 */
-						message = xstrdup(tmp_message);
+
+				      if (!have_length[i]) {
+					    numread = read(sockfd, &lmess[i], sizeof(lmess[i]));
+					    if (numread <= 0 || numread < sizeof(lmess[i])) {
+						close_client(i);
+						continue;
+					    }
+					    have_length[i] = TRUE;
+
+					    /* Create a new memory pool for this request: */
+					    nextPool = sms_mkpool();
+					    memory_pool = nextPool;
+
+					    message[i] = (char *)pcms_malloc(lmess[i]); 
+					    message[i][0] = '\0';
+				      } /* end if not have_length */
+
+				      tmp_mess = (char *)pcms_malloc(lmess[i]);  
+				      tmp_mess[0] = '\0';
+				    /*  tmp_mess = (char *)sms_malloc(memory_pool, lmess[i]); */
+				      numread = read(sockfd, tmp_mess, lmess[i]);
+
+				      if (numread == 0) {
+					    close_client(i);
+					    continue;
+				      } /* end if numread == 0 */
+
+				      if (numread > 0) {
+					    so_far[i] = so_far[i] + numread;
+
+					    /* Check for bad message length: */
+					    if (so_far[i] > lmess[i]) {
+						close_client(i);
+						continue;
+					    }
+
+					    /* For partial reads, we need to manually place an end-of-string marker: */
+					    if (numread  < lmess[i]) 
+						tmp_mess[numread] = '\0';
 					    
-					    } /* end if numread < lmess */
+					    /* message[i] = xstrcat(message[i], tmp_mess); */
+					    (void *) strcat(message[i], tmp_mess);
+
+					    /* check if we have the entire message: */
+					    if (so_far[i] == lmess[i]) {
+
+						/* Read the request: */
+						strm = stream_fromstring(STREAM_XML, message[i], strlen(message[i]));
+						nextRequest = sdr_read(SERVERREQUEST, strm);
 
-					    /* Read the request: */
-					    strm = stream_fromstring(STREAM_XML, message, strlen(message));
-					    nextRequest = sdr_read(SERVERREQUEST, strm);
+						/* Make one last error check.  If sdr_read returns NULL
+						   then we don't have a well-formed message from the client
+						   so terminate this client: */
+						if (nextRequest == NULL) {
+						    close_client(i);
+						    continue;
+						}
 
-					    /* Be sure to store the specific socket for this request: */
-					    nextRequest->sockfd = sockfd;
+						/* Be sure to store the specific socket for this request: */
+						nextRequest->channel = create_tcp_channel(1);
+						nextRequest->channel->sockfd = sockfd;
+						SetMemoryPool(nextRequest->channel, nextPool);
 
-					    /* Now add it to the queue: */
-					    AddToMsgQueue(readq, nextRequest);  
-					    stream_close(strm);
+						/* Now add it to the queue: */
+						AddToMsgQueue(readq, nextRequest);  
+						stream_close(strm);
 
-					    if (--select_ready <= 0)
-						break;
+						have_length[i] = FALSE;
+						so_far[i] = 0;
 
-					} /* end if-else socket still active */
+					    } /* end if so_far == lmess */
 
+				      } /* end if numread > 0 */
+
+				    if (--select_ready <= 0)
+					break;
+
 				    } /* end if FD_ISSET on sockfd */
 				} /* end if checking if valid sockfd in list  */
 			    } /* end for-loop into all active clients  */
 
 			}  /* end if select_ready > 0 */
 
+
 			/********************************************
 		 	 * Now process outgoing replies:
 			 ********************************************/ 
 			while (!IsEmptyMsgQueue(writeq)) {
 			    thisReply = (ServerReply *)GetFromMsgQueue(writeq);
-			    if (FD_ISSET(thisReply->sockfd, &outgoingset)) {
+			    if (FD_ISSET(thisReply->channel->sockfd, &outgoingset)) {
+				memory_pool = GetMemoryPool(thisReply->channel);
 				reply_strm = stream_openstring(STREAM_XML);
 				sdr_write(SERVERREPLY, reply_strm, thisReply);
 				raw_reply = (char *)reply_strm->data;
-				len = strlen(raw_reply);
-				write (thisReply->sockfd, &len, sizeof(len));  
-				write (thisReply->sockfd, raw_reply, len);
+				thisReply->channel->send(thisReply->channel, raw_reply);
 				stream_close(reply_strm);
-				FD_CLR(thisReply->sockfd, &writeholder);
+				FD_CLR(thisReply->channel->sockfd, &writeholder);
 
-				/* free the thisReply memory here? */
+				/* free the thisReply memory here: */
+				FlushMemoryPool(thisReply->channel);
 
 			    } /* end if FD_ISSET */
 
@@ -251,7 +293,7 @@
 		    while (!IsEmptyMsgQueue(readq)) {
 			thisRequest = (ServerRequest *)GetFromMsgQueue(readq);
 			dispatch_request(thisRequest, writeq);
-			FD_SET(thisRequest->sockfd, &writeholder);
+			FD_SET(thisRequest->channel->sockfd, &writeholder);
 		    } /* end while not IsEmptyMsgQueue */
 
 	}  /* end while !quit */




From vandy@snocrash.cs.jhu.edu Wed Dec  5 16:47:09 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fB5Ll8525178
	for <dcms-cvs@eros.cs.jhu.edu>; Wed, 5 Dec 2001 16:47:09 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id RAA00813;
	Wed, 5 Dec 2001 17:43:57 -0500
Received: (from vandy@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fB5Luvm18141;
	Wed, 5 Dec 2001 16:56:57 -0500
Date: Wed, 5 Dec 2001 16:56:57 -0500
From: John Vanderburgh <vandy@snocrash.cs.jhu.edu>
Message-Id: <200112052156.fB5Luvm18141@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/repos/fs CachedFileRepos.c FileRepos.c FileRepos.h
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

vandy       01/12/05 16:56:57

  Modified:    src/client FilterSet.c Merge.c WorkSpace.c WorkSpace.h
                        command.c pcms.c
               src/common path.c smsmalloc.c xmalloc.c
               src/repos Channel.c
               src/repos/common Repository.h
               src/repos/fs CachedFileRepos.c FileRepos.c FileRepos.h
  Log:
  Misc changes

Revision  Changes    Path
1.3       +4 -4      pcms/src/client/FilterSet.c

Index: FilterSet.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/FilterSet.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FilterSet.c	2001/10/19 03:44:10	1.2
+++ FilterSet.c	2001/12/05 21:56:57	1.3
@@ -23,7 +23,7 @@
 filterset_append(FilterSet *fs, Filter *f)
 {
   fs->filters = (Filter **) pcms_realloc(fs->filters,
-				     (fs->size + 1) * sizeof(Filter *));
+				     (fs->size + 1) * sizeof(Filter *)); 
   fs->filters[fs->size] = f;
   fs->size++;
 }
@@ -33,7 +33,7 @@
 {
   Filter *list = global_filter_list;
   
-  GlobalFilters = (FilterSet *) pcms_malloc(sizeof(FilterSet));
+  GlobalFilters = (FilterSet *) pcms_malloc(sizeof(FilterSet)); 
   GlobalFilters->filters = 0;
   GlobalFilters->size = 0;
   
@@ -67,7 +67,7 @@
   const char *filtfile;
   FILE *f;
   
-  FilterSet *fs = (FilterSet *) pcms_malloc(sizeof(FilterSet));
+  FilterSet *fs = (FilterSet *) pcms_malloc(sizeof(FilterSet)); 
   fs->filters = 0;
   fs->size = 0;
 
@@ -120,7 +120,7 @@
 
 	len = bufp - start;
 
-	filt = (Filter *) pcms_malloc(sizeof(Filter));
+	filt = (Filter *) pcms_malloc(sizeof(Filter)); 
 	filt->exclude = exclude;
 	filt->pattern = xstrndup(start, len);
 



1.5       +2 -0      pcms/src/client/Merge.c

Index: Merge.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/Merge.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Merge.c	2001/11/13 16:57:39	1.4
+++ Merge.c	2001/12/05 21:56:57	1.5
@@ -391,6 +391,8 @@
   obvec_append(mergePreds, merge);
 
   common = change_find_common_ancestor(r, basePreds, mergePreds);
+  if (!common)
+      report_error(EX_Unsync, "No common ancestor from which to merge.\n");
 
   /* Now we have to extract the entity vectors and make up a bunch of
    * triples.



1.3       +25 -6     pcms/src/client/WorkSpace.c

Index: WorkSpace.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/WorkSpace.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WorkSpace.c	2001/10/19 03:44:10	1.2
+++ WorkSpace.c	2001/12/05 21:56:57	1.3
@@ -87,7 +87,22 @@
 #endif
 }
 
+/*
+ * This one is used by the import command to initialize just the basic
+ * WorkSpace variables needed in the case where a .pcms directory already
+ * exists.  (Scenario:  user checks out branch from repository A but needs
+ * to do disconnected development.  User creates repository B (locally) and
+ * imports branch into repos B.  The .pcms directory will then be overwritten
+ * with repos B-specific info.
+ */
 void
+ws_miniInit(Repository *r)
+{
+    ws_startDir = path_current_directory();
+    ws_FindProjectRoot();
+} /* end ws_miniInit */
+
+void
 ws_Init(Repository *r)
 {
   ws_startDir = path_current_directory();
@@ -227,9 +242,15 @@
 
     entpath = path_join(dirpath, ent->d_name);
     
-    if (filter && (filterset_ShouldExclude(GlobalFilters, entpath) ||
-		   filterset_ShouldExclude(localFilters, entpath) ||
-		   filter(entpath)))
+    /* Check user-specified filter: */
+    if (filter) {
+	if (filter(entpath))
+	    continue;
+    }
+
+    /* Check global filter list: */
+    if (filterset_ShouldExclude(GlobalFilters, entpath) ||
+	filterset_ShouldExclude(localFilters, entpath)) 
       continue;
   
     if (path_isdir(entpath)) {
@@ -331,7 +352,7 @@
 {
   unsigned i;
   
-  StrVec *names = ws_Enumerate(0);
+  StrVec *names = ws_Enumerate(0); 
 
   for (i = 0; i < vec_size(names); i++) {
     const char *relpath = vec_fetch(names,i);
@@ -369,8 +390,6 @@
 
   old = path_canonical(old);
   new = path_canonical(new);
-  
-
   
   if (!path_exists(old))
     report_error(1, "Can't find \"%s\".\n", orig_old);



1.2       +1 -0      pcms/src/client/WorkSpace.h

Index: WorkSpace.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/WorkSpace.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WorkSpace.h	2001/10/10 22:07:20	1.1
+++ WorkSpace.h	2001/12/05 21:56:57	1.2
@@ -10,6 +10,7 @@
 extern PendingChange *ws_nextChange;
 
 void ws_Init(Repository *r);
+void ws_miniInit(Repository *r);
 
 void ws_RewriteWorkspace(void);
 WsEntity *ws_Lookup(const char *);



1.4       +1 -1      pcms/src/client/command.c

Index: command.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/command.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- command.c	2001/11/27 16:52:55	1.3
+++ command.c	2001/12/05 21:56:57	1.4
@@ -50,7 +50,7 @@
   { "enumerate", pcms_enumerate,  CS_NMLIST, 0 },
   { "import",    pcms_import,     0, 0 },
   { "list",      0,               0, list_cmds },
-  { "merge",     pcms_merge,      2, 0 },
+  { "merge",     pcms_merge,      1, 0 },
   { "mv",        pcms_rename_entity,      2, 0 }, /* shortcut! */
   { "note",      pcms_note,       0, 0 },
   { "notes",     pcms_show_notes, 0, 0 },



1.10      +239 -74   pcms/src/client/pcms.c

Index: pcms.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/client/pcms.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- pcms.c	2001/12/04 15:02:38	1.9
+++ pcms.c	2001/12/05 21:56:57	1.10
@@ -97,52 +97,76 @@
    */
 }
   
+/*
+ * Format of this command should be:
+ * pcms --server <scheme>:<repos path> merge <new branch>
+ *
+ * where <new branch> is specified as <proj:branch> and
+ * is the "remote" or "other" branch with which you want
+ * to merge the configuration specified in your workspace.
+ */
 void
 pcms_merge(Repository *r, int argc, char **argv)
 {
-#if 0
-  if (r == 0)
-    report_error(EX_NoServer, "Cannot locate repository\n");
-  
+#if 1
+    
+#define workSpaceBranchName  ws_nextChange->branchTrueName
+#define workSpaceProjName  ws_nextChange->projTrueName
+
+  const char *c1_tn;
+  const char *c2_tn;
+
+  char *otherProjName;
   char *petName1 = argv[0];
-  char *petName2 = argv[1];
-  
-  char *branch1 = strchr(argv[0], ':');
-  char *branch2 = strchr(argv[1], ':');
+  char *otherBranchName = strchr(argv[0], ':');
+  Project *workSpaceProj, *otherProj;
+  Branch *workSpaceBranch, *otherBranch;
+  void *e1, *e2;
 
-  if (branch1 == 0)
-    report_error(EX_Args, "merge requires two branch names\n");
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
   
-  if (branch2 == 0)
-    report_error(EX_Args, "merge requires two branch names\n");
+  if (otherBranchName == 0)
+    report_error(EX_Args, "merge requires a branch name\n");
   
-  char *proj1 = xstrndup(argv[0], branch1 - argv[0]);
-  branch1++;
-  char *proj2 = xstrndup(argv[1], branch2 - argv[1]);
-  branch2++;
-
-  Project *p1 = repos_PetGetProject(r, proj1);
-  Branch *b1 = repos_PetGetBranch(r, p1, branch1);
-
-  Project *p2 = repos_PetGetProject(r, proj2);
-  Branch *b2 = repos_PetGetBranch(r, p1, branch2);
-
-  xprintf("Merging: %s:%s\n", proj1, branch1);
-  b1->Show();
+  ws_Init(r);
 
-  xprintf("\nWith: %s:%s\n", proj2, branch2);
-  b2->Show();
+  otherProjName = xstrndup(argv[0], otherBranchName - argv[0]);
+  otherBranchName++;
 
-  const char *c1_tn = b1->GetTopChange();
-  const char *c2_tn = b2->GetTopChange();
+  workSpaceProj = repos_GetProject(r, workSpaceProjName);
+  workSpaceBranch = repos_GetBranch(r, workSpaceProj, workSpaceBranchName);
+
+  otherProj = repos_PetGetProject(r, otherProjName);
+  otherBranch = repos_PetGetBranch(r, otherProj, otherBranchName);
+
+  xprintf("Merging: %s:%s", workSpaceProj->nickname, workSpaceBranch->nickname);
+  xprintf("\tWith: %s:%s...\n", otherProjName, otherBranchName);
+
+  /* Make sure the workspace is up to date with its branch: */
+  if (branch_TopChangeNdx(workSpaceBranch) != ws_nextChange->topChange)
+      report_error(EX_Unsync,
+	      "Your workspace branch has been modified.  Please run \"pcms update\" before trying to merge.\n");
+
+
+  /* From here on, we're essentially doing the equivalent of the 'update' command:
+   * We have three configurations of interest here:
+   *   1) PendingChange specified by WorkSpace
+   *   2) TopChange of "other branch"
+   *   3) Mandatory common ancestor of the two above
+   * Extract the three, perform a 'diff3' on each Entity in the Changes and then
+   * write the result to the local workspace.
+   *
+   * User must do a 'commit' in order for the new result to be appended to the
+   * workspace's branch.
+   */
+  c2_tn = branch_GetTopChange(otherBranch);
+  e2 = repos_GetEntity(r, c2_tn);
 
-  Change *c1 = new Change();
-  Change *c2 = new Change();
+  pendingchange_mergeFromX(ws_nextChange, r, e2);
 
-  repos_GetEntity(r, c1_tn, c1);
-  repos_GetEntity(r, c2_tn, c2);
+  /* Need to rewrite workspace? */
 
-  (void) Change::Merge(r, c1, c2);
 #else
   unimplemented("pcms merge is not yet implemented.\n");
 #endif
@@ -157,6 +181,13 @@
   if (r == 0)
     report_error(EX_NoServer, "Cannot locate repository\n");
   
+  /* This call is necessary to initialize some basic
+   * WorkSpace variables.  We don't want to do the entire
+   * ws_Init() here in case we already have a WorkSpace but
+   * we're importing to a new Repository. 
+   */
+  ws_miniInit(r);
+
   p = CreateNewProject();
   
   repos_CreateProject(r, p);
@@ -184,6 +215,11 @@
 {
   int i;
   
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+  
+  ws_Init(r);
+
   for (i = 0; i < argc; i++) {
     Entity *ent = repos_GetEntity(r, argv[i]);
 
@@ -206,6 +242,8 @@
   if (r == 0)
     report_error(EX_NoServer, "Cannot locate repository\n");
   
+  ws_Init(r);
+
   if (branch) {
     proj = xstrndup(proj, branch - proj);
     branch++;
@@ -250,6 +288,10 @@
   
   StrVec *sv = repos_ListProjects(r);
 
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+
+
   for(u = 0; u < vec_size(sv); u++) {
     StrVec *petNames;
     unsigned pn;
@@ -276,6 +318,9 @@
   StrVec *sv;
   unsigned u;
 
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+
   if (branch != 0)
     report_error(1, "The \"list branches\" command takes only a project name.\n");
 
@@ -338,6 +383,11 @@
 void
 pcms_dump(Repository *r, int argc, char **argv)
 {
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+
+  ws_Init(r);
+
   if (!ws_haveProject) {
     report("No project found.\n");
     return;
@@ -349,6 +399,11 @@
 void
 pcms_revert(Repository *r, int argc, char **argv)
 {
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+
+  ws_Init(r);
+
   if (!ws_haveProject) {
     report("No project found.\n");
     return;
@@ -376,8 +431,22 @@
 {
   int i;
   StrVec *names;
+  Project *p;
+  Branch *b;
 
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+
+  ws_Init(r);
+
   pendingchange_RecomputeStatus(ws_nextChange);
+  
+  p = repos_GetProject(r, ws_nextChange->projTrueName);
+  b = repos_GetBranch(r, p, ws_nextChange->branchTrueName);
+
+  xprintf("\nPROJECT: %s\n", p->nickname);
+  xprintf("BRANCH : %s\n", b->nickname);
+
   pendingchange_ReportStatus(ws_nextChange);
 
   names = ws_Enumerate(is_known_entity);
@@ -391,6 +460,11 @@
 void
 pcms_status(Repository *r, int argc, char **argv)
 {
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+
+  ws_Init(r);
+
   if (!ws_haveProject) {
     report("No project found.\n");
     return;
@@ -409,14 +483,16 @@
   int i;
   StrVec *names;
 
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+
+  ws_Init(r);
+
   if (!ws_haveProject) {
     report("No project found.\n");
     return;
   }
 
-  if (r == 0)
-    report_error(EX_NoServer, "Cannot locate repository\n");
-  
   projTrueName = ws_nextChange->projTrueName;
   branchTrueName = ws_nextChange->branchTrueName;
   
@@ -445,6 +521,12 @@
 void
 pcms_show_notes(Repository *r, int argc, char **argv)
 {
+  
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+
+  ws_Init(r);
+
   if (!ws_haveProject) {
     report("No project found.\n");
     return;
@@ -460,6 +542,11 @@
 void
 pcms_note(Repository *r, int argc, char **argv)
 {
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+
+  ws_Init(r);
+
   if (!ws_haveProject) {
     report("No project found.\n");
     return;
@@ -477,14 +564,16 @@
   Project *p;
   Branch *b;  
 
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+  
+  ws_Init(r);
+
   if (!ws_haveProject) {
     report("No project found.\n");
     return;
   }
 
-  if (r == 0)
-    report_error(EX_NoServer, "Cannot locate repository\n");
-  
   projTrueName = ws_nextChange->projTrueName;
   branchTrueName = ws_nextChange->branchTrueName;
   
@@ -522,14 +611,16 @@
   int i;
   WsEntity *e;
   
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+  
+  ws_Init(r);
+
   if (!ws_haveProject) {
     report("No project found.\n");
     return;
   }
 
-  if (r == 0)
-    report_error(EX_NoServer, "Cannot locate repository\n");
-  
   /* This is trickier than it looks, because argv[x] is always
    * relative to the startup directory, not the root directory.
    */
@@ -570,6 +661,11 @@
 void
 pcms_populate(Repository *r, int argc, char **argv)
 {
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+  
+  ws_Init(r);
+
   if (!ws_haveProject)
     report_error(EX_WorkSpace, "Workspace already has a project\n");
 
@@ -585,6 +681,11 @@
    * relative to the startup directory, not the root directory.
    */
 
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+  
+  ws_Init(r);
+
   for (i = 0; i < argc; i++) {
     const char *relpath = path_join(ws_relStartDir, argv[i]);
     relpath = path_canonical(relpath);
@@ -612,6 +713,11 @@
   StrVec *names;
   StrVec *nmlist = nmlist_create(argc, argv);
 
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+  
+  ws_Init(r);
+
   names = ws_Enumerate(is_not_ignored);
 
   for (i = 0; i < vec_size(names); i++) {
@@ -631,14 +737,16 @@
 
   StrVec *nmlist = nmlist_create(argc, argv);
 
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+  
+  ws_Init(r);
+
   if (!ws_haveProject) {
     report("No project found.\n");
     return;
   }
 
-  if (r == 0)
-    report_error(EX_NoServer, "Cannot locate repository\n");
-  
   projTrueName = ws_nextChange->projTrueName;
   branchTrueName = ws_nextChange->branchTrueName;
   
@@ -674,14 +782,16 @@
   const char *old = argv[0];
   const char *new = argv[1];
 
+  if (r == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+  
+  ws_Init(r);
+
   if (!ws_haveProject) {
     report("No project found.\n");
     return;
   }
 
-  if (r == 0)
-    report_error(EX_NoServer, "Cannot locate repository\n");
-  
   ws_RenameFile(old, new);
 
   ws_RewriteWorkspace();
@@ -701,6 +811,38 @@
   exit(0);
 }
 
+static void
+copy_entities(Repository *fromR, Repository *toR, Branch *b) 
+{
+    int u,v;
+    void *change;
+    void *commitInfo;
+    void *entitySet;
+    void *entity;
+    void *bits;
+
+    assert(fromR);
+    assert(toR);
+    assert(b);
+
+    /* Now, we need to copy over all the Changes, CommitInfoRecords, EntitySets, and Entities: */
+    for (u = 0; u < vec_size(b->changes); u++) {
+	change = repos_GetEntity(fromR, vec_fetch(b->changes, u));
+	repos_PutEntity(toR, change);
+	commitInfo = repos_GetEntity(fromR, ((Change *)change)->commitInfoTrueName);
+	repos_PutEntity(toR, commitInfo);
+	entitySet = repos_GetEntity(fromR, ((Change *)change)->entSetTrueName);
+	repos_PutEntity(toR, entitySet);
+	for (v = 0; v < vec_size(((EntitySet *)entitySet)->entNames); v++) {
+	   entity = repos_GetEntity(fromR,vec_fetch(((EntitySet *)entitySet)->entNames, v));
+	   repos_PutEntity(toR, entity);
+	   bits = repos_GetEntity(fromR, ((Entity *)entity)->contentTrueName);
+	   repos_PutEntity(toR, bits);
+	} /* end for loop */
+    } /* end for loop */	
+
+} /* end copy_entities */
+
 void
 pcms_copy_branch(Repository *fromR, int argc, char **argv)
 {
@@ -710,25 +852,16 @@
     char *petName;
     char *branch;
     char *proj;
-
-    /***
-    int x;
-    for (x = 0; x < argc; x++)
-	fprintf(stdout, "Argv[%d] = %s\n", x, argv[x]);
-    
-	***/
+    int u;
 
   if (fromR == 0)
     report_error(EX_NoServer, "Cannot locate repository\n");
   
-  if (ws_haveProject)
-    report_error(EX_WorkSpace, "Workspace already has a project\n");
-    
   petName = argv[0];
   branch  = strchr(argv[0], ':');
 
   if (branch == 0)
-    report_error(EX_Args, "command requires branch name\n");
+    report_error(EX_Args, "Command requires branch name\n");
   
   proj = xstrndup(argv[0], branch - argv[0]);
   branch++;
@@ -738,23 +871,53 @@
 
   toR = repository_open(argv[1],0);
   if (toR == 0)
-      report_error(EX_Args, "command requires a target repository URI\n");
+      report_error(EX_Args, "Error opening target repository [%s].\n",argv[1]);
 
-  /** repos_PutBranch(toR, p, b); **/
-  filerepository_PutBranch(toR, p, b);
-  
-  /* Now copy over the entities: */
-  pendingchange_Commit(ws_nextChange, toR, p, b);
+  /* Create all the necessary directories, etc.:*/
+  repos_PutBranch(toR, p, b);
 
-}
+  /* This must be done here, because the two repositories are most likely
+   * different:
+   */
+  copy_entities(fromR, toR, b); 
+  
+} /* end pcms_copy_branch */
 
 void
-pcms_copy_project(Repository *r, int argc, char **argv)
+pcms_copy_project(Repository *fromR, int argc, char **argv)
 {
-    int x;
-    for (x = 0; x < argc; x++)
-	fprintf(stdout, "Argv[%d] = %s\n", x, argv[x]);
-}
+    Project *p, *saveP;
+    Branch *b;
+    Repository *toR;
+    char *petName;
+    char *proj;
+    StrVec *branches;
+    int u;
+
+  if (fromR == 0)
+    report_error(EX_NoServer, "Cannot locate repository\n");
+  
+  petName = argv[0];
+
+  p = repos_PetGetProject(fromR, proj);
+  saveP = repos_PetGetProject(fromR, proj);
+
+  toR = repository_open(argv[1],0);
+  if (toR == 0)
+      report_error(EX_Args, "Error opening target repository [%s].\n",argv[1]);
+
+  /* Make sure the necessary directories exist or are created: */
+  repos_PutProject(toR, p);
+
+    /* Now copy every branch over to new project: */
+    branches = repos_ListBranches(fromR, saveP);
+    for (u = 0; u < vec_size(branches); u++) {
+	b = repos_GetBranch(fromR, saveP, vec_fetch(branches, u));
+	repos_PutBranch(toR, p, b);
+        copy_entities(fromR, toR, b); 
+    } /* end for loop */
+
+} /* end pcms_copy_project */
 
 static void
 process_environment()
@@ -794,9 +957,11 @@
   process_options(argc, argv);
 
   r = 0;
-  if (ServerURI) {
+  if (!ServerURI)
+      report_error(EX_NoServer, "You must specify a repository via the --server option or PCMS_REPOSITORY environment variable.\n");
+  else {
     r = repository_open(ServerURI, 0);
-    ws_Init(r);
+  /*  ws_Init(r); */
   }
 
   /* Now chdir'd to project root directory IF THERE IS ONE */



1.3       +8 -6      pcms/src/common/path.c

Index: path.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/path.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- path.c	2001/10/19 03:44:10	1.2
+++ path.c	2001/12/05 21:56:57	1.3
@@ -70,7 +70,8 @@
 path_join(const char *dir, const char *tail)
 {
   char *s =
-    (char *) pcms_malloc(sizeof(char) * (strlen(dir) + strlen(tail) + 2));
+     (char *) pcms_malloc(sizeof(char) * (strlen(dir) + strlen(tail) + 2)); 
+/*     (char *) sms_malloc(memory_pool, sizeof(char) * (strlen(dir) + strlen(tail) + 2)); */
   strcpy(s, dir);
   strcat(s, "/");
   strcat(s, tail);
@@ -97,7 +98,8 @@
 
   len++;			/* for trailing null */
 
-  s = (char *) pcms_malloc (sizeof(char) * len);
+    s = (char *) pcms_malloc (sizeof(char) * len); 
+/*  s = (char *) sms_malloc (memory_pool, sizeof(char) * len); */
   sptr = s;
   p = path;
 
@@ -281,8 +283,8 @@
 path_current_directory()
 {
 #ifdef __unix__
-  int len = PATH_MAX;
-  char * dir = (char *) pcms_malloc(sizeof(char) * len);
+  int len = PATH_MAX; 
+  char * dir = (char *) pcms_malloc(sizeof(char) * len); 
   char *cwd;
 
   do {
@@ -290,8 +292,8 @@
     if (cwd == NULL) {
       if (errno == ERANGE) {
 	len *= 2;
-	pcms_free(dir);
-	dir = (char *) pcms_malloc(sizeof(char) * len);
+	 pcms_free(dir); 
+	 dir = (char *) pcms_malloc(sizeof(char) * len); 
       }
       else
 	return NULL;



1.5       +8 -4      pcms/src/common/smsmalloc.c

Index: smsmalloc.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/smsmalloc.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- smsmalloc.c	2001/12/04 15:02:38	1.4
+++ smsmalloc.c	2001/12/05 21:56:57	1.5
@@ -63,8 +63,8 @@
   assert(v);
   bzero(v, sz);
 
-  /*  if ((cv - (char *)0) < (sms_alloc_base - (char *)0)) */
-  if (sms_alloc_base  > cv) 
+  /* if ((cv - (char *)0) < (sms_alloc_base - (char *)0))  */
+  if (sms_alloc_base  > cv)  
     sms_alloc_base = cv;
 
   if ((cv - (char *)0) > (sms_alloc_bound - (char *)0))
@@ -92,7 +92,11 @@
 void *
 sms_malloc(sms_pool_t pool, size_t sz)
 {
-  obhdr *hdr = sms_do_malloc(sizeof(obhdr) + sz);
+  obhdr *hdr;
+
+  sz = sz ? sz : 1;
+
+  hdr = sms_do_malloc(sizeof(obhdr) + sz);
 
   sms_inithdr(hdr, pool, sizeof(obhdr) + sz);
 
@@ -171,7 +175,7 @@
   cv = (char *)v;
 
   /* if ((cv - (char *)0) < (sms_alloc_base - (char *)0)) */
-  if ((sms_alloc_base - (char *)0) > (cv - (char *)0))
+  if (sms_alloc_base > cv)
     return 0;
 
   if ((cv - (char *)0) > (sms_alloc_bound - (char *)0))



1.4       +4 -3      pcms/src/common/xmalloc.c

Index: xmalloc.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/xmalloc.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- xmalloc.c	2001/12/04 15:02:38	1.3
+++ xmalloc.c	2001/12/05 21:56:57	1.4
@@ -13,7 +13,6 @@
   size = size ? size : 1;
   
   vp = malloc(size); 
-/*  vp = sms_malloc(memory_pool, size); */
 
   bzero(vp, size);
 
@@ -23,15 +22,17 @@
   printf("Malloc returns 0x%08x, %u\n", vp, size);
 #endif
 
-  return vp;
+  return vp; 
 }
 
 void *
 pcms_realloc(void *vp, size_t size)
 {
+
   /* This workaround needed for libdiff library, which sometimes
    * allocates empty storage. */
   void *ovp = vp;
+
   size = size ? size : 1;
   
 #ifdef MALLOC_DEBUG
@@ -40,7 +41,6 @@
 
   if (vp)
     vp = realloc(vp, size); 
-/*    vp = sms_realloc(memory_pool, vp, size); */
   else
     vp = pcms_malloc(size);
 
@@ -54,6 +54,7 @@
 #endif
   
   return vp;
+
 }
 
 void



1.3       +2 -2      pcms/src/repos/Channel.c

Index: Channel.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/Channel.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Channel.c	2001/12/04 15:02:38	1.2
+++ Channel.c	2001/12/05 21:56:57	1.3
@@ -30,7 +30,7 @@
     c->setup = tcp_setup;
     c->send = tcp_send;
     c->receive = tcp_receive;
-    c->memory_pool = NULL;
+    c->memory_pool = memory_pool;
     return c;
 } /* end create_tcp_channel */
 
@@ -41,7 +41,7 @@
 	struct in_addr **hostptr;
 	int connsucceed;
 	
-	if ((netlocaddr = gethostbyname2(uri->netloc, AF_INET)) == NULL) {
+	if ((netlocaddr = gethostbyname2(uri->netloc, AF_INET)) == NULL) { 
 		report("%s\n", hstrerror(h_errno));
 		return -1;
 	}



1.9       +4 -2      pcms/src/repos/common/Repository.h

Index: Repository.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/common/Repository.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Repository.h	2001/11/27 16:52:55	1.8
+++ Repository.h	2001/12/05 21:56:57	1.9
@@ -57,6 +57,7 @@
   /* Entity management: -- both 2nd args must be serializables */
   const char *(*ReviseEntity)(Repository *r, const char *prevTrueName, void *);
   void *(*GetEntity)(Repository *r, const char *trueName);
+  void (*PutEntity)(Repository *r, void *);
   
   /* Replication methods: */
   void (*PutProject)(Repository *r, Project *p);
@@ -93,10 +94,11 @@
 /* Entity management: -- 2nd arg to ReviseEntity must be Serializable */
 #define repos_ReviseEntity(r,ptn,ent) r->ReviseEntity(r,ptn,ent)
 #define repos_GetEntity(r,tn)         r->GetEntity(r,tn)
+#define repos_PutEntity(r,ent)        r->PutEntity(r,ent)
 
 /* Replication commands: */
-#define repos_PutProject(r,p) r->PutProject(r,p)
-#define repos_PutBranch(r,p,b) r->PutBranch(r,p,b)
+#define repos_PutProject(r,p) 	r->PutProject(r,p)
+#define repos_PutBranch(r,p,b) 	r->PutBranch(r,p,b)
 
 /** repository_open(): given a URI identifying a repository, perform the
     appropriate actions to open the repository and authenticate the



1.9       +11 -6     pcms/src/repos/fs/CachedFileRepos.c

Index: CachedFileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/CachedFileRepos.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CachedFileRepos.c	2001/11/27 16:52:55	1.8
+++ CachedFileRepos.c	2001/12/05 21:56:57	1.9
@@ -115,7 +115,7 @@
 }
 
 /* Entity management: */
- static const char *
+static const char *
 cachedfilerepository_ReviseEntity(Repository *r,
 			    const char *prevTrueName, void *s)
 {
@@ -123,15 +123,19 @@
 }
 
 /* Replication: */
-static void cachedfilerepository_PutProject (Repository *r, Project *p) {
-	filerepository_PutProject(r, p);
+static void cachedfilerepository_PutProject (Repository *to, Project *p) {
+	filerepository_PutProject(to, p);
 }
 
-static void cachedfilerepository_PutBranch (Repository *r, Project *p, Branch *b) {
-	filerepository_PutBranch(r, p, b);
+static void cachedfilerepository_PutBranch (Repository *to, Project *p, Branch *b) {
+	filerepository_PutBranch(to, p, b);
 }
 
- static void *
+static void cachedfilerepository_PutEntity(Repository *r, void *ent) {
+	filerepository_PutEntity(r, ent);
+}
+
+static void *
 cachedfilerepository_GetEntity(Repository *r,
 			  const char *trueName)
 {
@@ -259,6 +263,7 @@
   /* Entity management: -- both 2nd args must be serializables */
   r->ReviseEntity = cachedfilerepository_ReviseEntity;
   r->GetEntity = cachedfilerepository_GetEntity;
+  r->PutEntity = cachedfilerepository_PutEntity;
 
   r->cache = createEntityCache();
   r->channel = NULL;



1.10      +84 -62    pcms/src/repos/fs/FileRepos.c

Index: FileRepos.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FileRepos.c	2001/11/27 16:52:55	1.9
+++ FileRepos.c	2001/12/05 21:56:57	1.10
@@ -72,14 +72,14 @@
 
 } /* end filerepository_CreateRepository */
 
- int
+int
 filerepository_connect(Repository *r)
 {
   /* no connection is needed. */
   return 0;
 }
 
- const char *
+const char *
 filerepository_GetVersion(Repository *r)
 {
   FILE *f;
@@ -144,7 +144,7 @@
   return xstrcat(nickname, buf);
 }
 
-  int
+int
 filerepository_CreateProject(Repository *r, Project *p)
 {
   /* Entity name: on some systems this needs to be converted to a
@@ -184,7 +184,7 @@
   return 0;
 }
 
-  Project *
+Project *
 filerepository_GetProject(Repository *r, const char *trueName)
 {
   Project *p;
@@ -220,7 +220,7 @@
 
   f = fopen(path, "r");
   if (f == NULL)
-    report_error(EX_Server, "Pet name not found\n");
+    report_error(EX_Server, "Project %s not found\n", petName);
 
   len = path_file_length(path);
   tn = pcms_malloc(len+1);
@@ -237,7 +237,7 @@
   return p;
 }
 
-  int 
+int 
 filerepository_PetRenameProject(Repository *r,
 				const char *oldname, const char *newname)
 {
@@ -263,7 +263,7 @@
   return FALSE;
 }
 
-  StrVec * 
+StrVec * 
 filerepository_ListProjects(Repository *r)
 {
   const char *path;
@@ -292,7 +292,7 @@
   return vec;
 }
 
-  StrVec * 
+StrVec * 
 filerepository_ListProjPetNames(Repository *r, Project *p)
 {
   DIR* dir;
@@ -320,7 +320,7 @@
 
       f = fopen(petpath, "r");
       if (f == NULL)
-	report_error(EX_Server, "Pet name not found\n");
+	report_error(EX_Server, "Path %s not found.\n", petpath);
 
       if (fread(tn, 1, len, f) < len)
 	report_error(EX_Server, "Couldn't extract true name\n");
@@ -337,7 +337,7 @@
   return vec;
 }
 
-  StrVec * 
+StrVec * 
 filerepository_ListBranchPetNames(Repository *r, Branch *b, const char *pName)
 {
   DIR* dir;
@@ -373,7 +373,7 @@
 
       f = fopen(petpath, "r");
       if (f == NULL)
-	report_error(EX_Server, "Pet name not found\n");
+	report_error(EX_Server, "Branch %s not found\n", pName);
 
       if (fread(tn, 1, len, f) < len)
 	report_error(EX_Server, "Couldn't extract true name\n");
@@ -391,7 +391,7 @@
 }
 
 /* Manipulation of branches: */
-  int 
+int 
 filerepository_CreateBranch(Repository *r, Project *p, Branch *b)
 {
   const char *projpath;
@@ -422,7 +422,7 @@
   return 0;
 }
 
-  int
+int
 filerepository_PetRenameBranch(Repository *r,
 				Project *p,
 				const char *oldname,
@@ -494,7 +494,7 @@
 
   f = fopen(petpath, "r");
   if (f == NULL)
-    report_error(EX_Server, "Pet name not found\n");
+    report_error(EX_Server, "Branch %s not found\n", petName);
 
   len = path_file_length(petpath);
   tn = pcms_malloc(len+1);
@@ -538,7 +538,7 @@
 }
 
 /* Provide a list of branch pet names */
-  StrVec *
+StrVec *
 filerepository_ListBranches(Repository *r, Project *p)
 {
   const char *path;
@@ -667,53 +667,67 @@
   return ent;
 }
 
-/* Replication: */
-void filerepository_PutProject(Repository *r, Project *p) 
-{
+/*
+ * This is needed for replicating (copying) Branch objects
+ * to other repositories.
+ */
+void
+filerepository_PutEntity(Repository *r, void *ent) {
+    
     const char *relpath;
     const char *path;
     SDR_stream *strm;
 
     /* paranoia checks: */
     if (r == NULL)
-	report_error(EX_NoArgs, "No Repository specified.\n");
+	report_error(EX_NoArgs, "No target Repository specified.\n");
 
-    if (p == NULL)
-	report_error(EX_NoArgs, "No Project specified.\n");
+    if (ent == NULL)
+	report_error(EX_NoArgs, "No Entity specified.\n");
 
-    /* simple create the given Project in the 'new' repository: */
-    relpath = path_tn_fixup(p->serTrueName);
-    relpath = path_join("projects", p->serTrueName);
-    path = path_join(r->uri->path, relpath);
-
-    if (path_smkdir(path) < 0)
-       report_error(EX_Server, "Problem copying the Project");
+    path = path_join(r->uri->path, "entities");
+    if (!path_exists(path))
+	report_error(EX_NoServer, "Target repository is corrupted.\n");
 
-    if (path_smkdir(path_join(path,"branches")) < 0)
-       report_error(EX_Server, "Problem copying the Project");
+    path = path_join(path, ((Serializable *)ent)->ser_trueName);
+    strm = stream_openfile(path, WSTREAM, STREAM_XML);
+    sdr_write("ENTITY", strm, ent);
+    stream_close(strm);
 
-    if (path_smkdir(path_join(path,"petnames")) < 0)
-       report_error(EX_Server, "Problem copying the Project");
+} /* end filerepository_PutEntity */
 
-    strm = stream_openfile(path_join(path,"description"), WSTREAM, STREAM_XML);
-    sdr_write("PROJECT", strm, p);
-    stream_close(strm);
+/* Replication: */
+void filerepository_PutProject(Repository *toR, Project *p) 
+{
+    const char *path;
 
-    /* Finally, copy the petnames entry: */
-    p->petName = BindPetName(r, 0, p->nickname, p->serTrueName);
+    /* paranoia checks: */
+    if (toR == NULL)
+	report_error(EX_NoArgs, "No target Repository specified.\n");
+
+    if (p == NULL)
+	report_error(EX_NoArgs, "No Project specified.\n");
 
+    /* Check if project nickname already exists:
+     * If it does, we'll append _new onto the nickname
+     * and create a new one.
+     */
+    path = path_join(toR->uri->path, "petnames");
+    path = path_join(path, p->nickname);
+    if (path_exists(path)) {
+	p->nickname = xstrcat(p->nickname, "_new");
+    } /* end if path_exists for branch */
+    filerepository_CreateProject(toR, p);
+
 } /* end filerepository_PutProject */
 
 void filerepository_PutBranch(Repository *r, Project *p, Branch *b)
 {
-    const char *projpath;
-    const char *relpath;
     const char *path;
-    SDR_stream *strm;
 
     /* paranoia checks: */
     if (r == NULL)
-	report_error(EX_NoArgs, "No Repository specified.\n");
+	report_error(EX_NoArgs, "No target Repository specified.\n");
 
     if (p == NULL)
 	report_error(EX_NoArgs, "No Project specified.\n");
@@ -721,31 +735,38 @@
     if (b == NULL)
 	report_error(EX_NoArgs, "No Branch specified.\n");
 
-    /* Ensure project path and all necessary subdirs exist: */
-    filerepository_PutProject(r, p);
-
-    /* Now generate the path for the branch: */
-    projpath = path_tn_fixup(p->serTrueName);
-    projpath = path_join("projects", projpath);
-
-    relpath = path_tn_fixup(b->serTrueName);
-    relpath = path_join("branches", relpath);
-
-    path = path_join(r->uri->path, projpath);
-    path = path_join(path, relpath);
-
-    strm = stream_openfile(path, WSTREAM, STREAM_XML);
-
-    /* Write out the actual branch info: */
-    sdr_write("BRANCH", strm, b);
-    stream_close(strm);
+    /* Check if project nickname already exists:
+     * If it doesn't, simply create a new project (but
+     * let the target repository assign a trueName). If
+     * the nickname/petName already exists on the target
+     * repository, just return a pointer to that Project.
+     */
+    path = path_join(r->uri->path, "petnames");
+    path = path_join(path, p->nickname);
+    if (!path_exists(path)) {
+	filerepository_CreateProject(r, p);
+    } else {
+	p = filerepository_PetGetProject(r, p->nickname);
+    } /* end if-else project exists */
+
+    /* Need to do same for the branch: 
+     * However, if branch nickname already exists
+     * we need to make up a new nickname, so just
+     * append "_new" onto it. 
+     */
+    path = path_join(r->uri->path, "projects");
+    path = path_join(path, p->serTrueName);
+    path = path_join(path, "petnames");
+    path = path_join(path, b->nickname);
+    if (path_exists(path)) {
+	b->nickname = xstrcat(b->nickname, "_new");
+    } /* end if path_exists for branch */
 
-    /* Finally, copy the petnames entry: */
-    b->petName = BindPetName(r, projpath, b->nickname, b->serTrueName);
+    filerepository_CreateBranch(r,p,b);
 
 } /* end filerepository_PutBranch */
 
- void
+void
 filerepository_init(Repository *r)
 {
   r->CreateRepository = filerepository_CreateRepository;
@@ -776,6 +797,7 @@
   /* Entity management: -- both 2nd args must be serializables */
   r->ReviseEntity = filerepository_ReviseEntity;
   r->GetEntity = filerepository_GetEntity;
+  r->PutEntity = filerepository_PutEntity;
 
   /* Replication: */
   r->PutBranch = filerepository_PutBranch;



1.6       +3 -0      pcms/src/repos/fs/FileRepos.h

Index: FileRepos.h
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/repos/fs/FileRepos.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FileRepos.h	2001/11/27 16:52:55	1.5
+++ FileRepos.h	2001/12/05 21:56:57	1.6
@@ -73,6 +73,9 @@
 void
 filerepository_PutBranch(Repository *r, Project *p, Branch *b);
 
+void
+filerepository_PutEntity(Repository *r, void *entity);
+
 
 
 




From shap@snocrash.cs.jhu.edu Wed Dec  5 17:49:08 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fB5Mn7525492
	for <dcms-cvs@eros.cs.jhu.edu>; Wed, 5 Dec 2001 17:49:08 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA00912;
	Wed, 5 Dec 2001 18:45:57 -0500
Received: (from shap@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fB5Mx2g18657;
	Wed, 5 Dec 2001 17:59:02 -0500
Date: Wed, 5 Dec 2001 17:59:02 -0500
From: "Jonathan S. Shapiro" <shap@snocrash.cs.jhu.edu>
Message-Id: <200112052259.fB5Mx2g18657@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src .cvsignore
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

shap        01/12/05 17:59:02

  Modified:    src      .cvsignore
  Log:
  Don't check in the output binaries by mistake...

Revision  Changes    Path
1.9       +2 -0      pcms/src/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/.cvsignore,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- .cvsignore	2001/11/21 20:56:25	1.8
+++ .cvsignore	2001/12/05 22:59:02	1.9
@@ -1,3 +1,5 @@
+pcms
+pcmsserver
 Makefile
 pcmsrules.mk
 .depend




From shap@snocrash.cs.jhu.edu Wed Dec  5 17:50:11 2001
Received: from mail.eros-os.org (IDENT:root@EROS.CIS.UPENN.EDU [158.130.6.119])
	by eros.cs.jhu.edu (8.11.0/8.11.0) with ESMTP id fB5MoB525526
	for <dcms-cvs@eros.cs.jhu.edu>; Wed, 5 Dec 2001 17:50:11 -0500
Received: from snocrash.cs.jhu.edu (snocrash.cs.jhu.edu [128.220.223.246])
	by mail.eros-os.org (8.9.3/8.9.3) with ESMTP id SAA00943;
	Wed, 5 Dec 2001 18:47:01 -0500
Received: (from shap@localhost)
	by snocrash.cs.jhu.edu (8.11.0/8.11.0) id fB5N06D18708;
	Wed, 5 Dec 2001 18:00:06 -0500
Date: Wed, 5 Dec 2001 18:00:06 -0500
From: "Jonathan S. Shapiro" <shap@snocrash.cs.jhu.edu>
Message-Id: <200112052300.fB5N06D18708@snocrash.cs.jhu.edu>
To: dcms-cvs@eros-os.org, shap@eros-os.org
Subject: [dcms-cvs] cvs commit: pcms/src/common smsmalloc.c xmalloc.c
Sender: dcms-cvs-admin@mail.eros-os.org
Errors-To: dcms-cvs-admin@mail.eros-os.org
X-BeenThere: dcms-cvs@mail.eros-os.org
X-Mailman-Version: 2.0beta5
Precedence: bulk
List-Id:  <dcms-cvs.mail.eros-os.org>

shap        01/12/05 18:00:06

  Modified:    src/common smsmalloc.c xmalloc.c
  Log:
  Patch xmalloc to conditionally (ifdef) use sms logic. Currently
  enabled.
  
  Fix sms_realloc to use the right pointer and size, and to update the
  neighbor link pointer.
  
  Pretty sure pcms will now barf in some new and creative way, but not
  *this* way anymore. :-)

Revision  Changes    Path
1.6       +26 -17    pcms/src/common/smsmalloc.c

Index: smsmalloc.c
===================================================================
RCS file: /users/bigdisk/cvs/pcms/src/common/smsmalloc.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- smsmalloc.c	2001/12/05 21:56:57	1.5
+++ smsmalloc.c	2001/12/05 23:00:06	1.6
@@ -31,7 +31,9 @@
 typedef struct pool *sms_pool_t;
 
 #define HDR(ob) ((obhdr *) (((char *)ob) - sizeof(obhdr)))
+#define OBPTR(hdr) ((void *) (((char *)hdr) + sizeof(obhdr)))
 
+
 #include "smsmalloc.h"
 
 inline static void 
@@ -63,12 +65,11 @@
   assert(v);
   bzero(v, sz);
 
-  /* if ((cv - (char *)0) < (sms_alloc_base - (char *)0))  */
-  if (sms_alloc_base  > cv)  
+  if ((unsigned) sms_alloc_base  > (unsigned)cv)  
     sms_alloc_base = cv;
 
-  if ((cv - (char *)0) > (sms_alloc_bound - (char *)0))
-    sms_alloc_bound = cv;
+  if ((unsigned)cv > (unsigned)sms_alloc_bound)
+    sms_alloc_bound = cv + sz;
 
   return v;
 }
@@ -108,7 +109,7 @@
 
   pool->obcount++;
 
-  return (void *) (((char *)hdr) + sizeof(obhdr));
+  return OBPTR(hdr);
 }
 
 static void
@@ -174,11 +175,10 @@
   hdr = HDR(v);
   cv = (char *)v;
 
-  /* if ((cv - (char *)0) < (sms_alloc_base - (char *)0)) */
-  if (sms_alloc_base > cv)
+  if ((unsigned) cv < (unsigned) sms_alloc_base)
     return 0;
 
-  if ((cv - (char *)0) > (sms_alloc_bound - (char *)0))
+  if ((unsigned) cv >= (unsigned) sms_alloc_bound)
     return 0;
 
   if (hdr->pPool != pool)
@@ -272,30 +272,39 @@
  * already been assigned via sms_malloc.  This is just the 'sms' wrapper
  * to the realloc() call. */
 void *
-sms_