diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2005-02-04 18:16:41 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2005-02-04 18:16:41 +0000 |
commit | ceecd565b80a1479e250cee3b13e788a01ec64ce (patch) | |
tree | 21b2c9a32753dc25d0d6561f410f47cb0595bb36 /usr.bin/cvs | |
parent | 2f8cad3759e0ff15be0fece2efed9ba8eaa4230e (diff) |
cleanup and additional error checking on connection setup
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/proto.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/usr.bin/cvs/proto.c b/usr.bin/cvs/proto.c index ceb8c558d60..74cba257e07 100644 --- a/usr.bin/cvs/proto.c +++ b/usr.bin/cvs/proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proto.c,v 1.39 2005/01/14 20:58:43 jfb Exp $ */ +/* $OpenBSD: proto.c,v 1.40 2005/02/04 18:16:40 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -279,14 +279,6 @@ cvs_connect(struct cvsroot *root) return (-1); } -#if 0 - root->cr_srverr = fdopen(errfd[0], "r"); - if (root->cr_srverr == NULL) { - cvs_log(LP_ERR, "failed to create pipe stream"); - return (-1); - } -#endif - /* make the streams line-buffered */ (void)setvbuf(root->cr_srvin, NULL, _IOLBF, 0); (void)setvbuf(root->cr_srvout, NULL, _IOLBF, 0); @@ -298,13 +290,15 @@ cvs_connect(struct cvsroot *root) * requests. */ - vresp = cvs_resp_getvalid(); - if (vresp == NULL) { + if ((vresp = cvs_resp_getvalid()) == NULL) { cvs_log(LP_ERR, "can't generate list of valid responses"); return (-1); } if (cvs_sendreq(root, CVS_REQ_VALIDRESP, vresp) < 0) { + cvs_log(LP_ERR, "failed to get valid responses"); + free(vresp); + return (-1); } free(vresp); @@ -313,21 +307,24 @@ cvs_connect(struct cvsroot *root) return (-1); } + /* don't fail if this request doesn't work */ if (cvs_sendreq(root, CVS_REQ_VERSION, NULL) < 0) - cvs_log(LP_ERR, "failed to get remote version"); + cvs_log(LP_WARN, "failed to get remote version"); /* now share our global options with the server */ - if (verbosity == 1) - cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-q"); - else if (verbosity == 0) - cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-Q"); - - if (cvs_nolog) - cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-l"); - if (cvs_readonly) - cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-r"); - if (cvs_trace) - cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-t"); + if ((verbosity == 1) && + (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-q") < 0)) + return (-1); + else if ((verbosity == 0) && + (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-Q") < 0)) + return (-1); + + if (cvs_nolog && (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-l") < 0)) + return (-1); + if (cvs_readonly && (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-r") < 0)) + return (-1); + if (cvs_trace && (cvs_sendreq(root, CVS_REQ_GLOBALOPT, "-t") < 0)) + return (-1); /* now send the CVSROOT to the server unless it's an init */ if ((cvs_cmdop != CVS_OP_INIT) && @@ -338,10 +335,6 @@ cvs_connect(struct cvsroot *root) if (cvs_sendreq(root, CVS_REQ_USEUNCHANGED, NULL) < 0) return (-1); -#ifdef CVS_ZLIB - /* if compression was requested, initialize it */ -#endif - cvs_log(LP_DEBUG, "connected to %s", root->cr_host); root->cr_flags |= CVS_ROOT_CONNECTED; |