From owner-cvs-all@FreeBSD.ORG Wed Feb 22 21:27:01 2006 Return-Path: X-Original-To: cvs-all@FreeBSD.org Delivered-To: cvs-all@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D065716A420; Wed, 22 Feb 2006 21:27:01 +0000 (GMT) (envelope-from mux@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8EB1043D45; Wed, 22 Feb 2006 21:27:01 +0000 (GMT) (envelope-from mux@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k1MLR1wh087061; Wed, 22 Feb 2006 21:27:01 GMT (envelope-from mux@repoman.freebsd.org) Received: (from mux@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k1MLR1Hc087060; Wed, 22 Feb 2006 21:27:01 GMT (envelope-from mux) Message-Id: <200602222127.k1MLR1Hc087060@repoman.freebsd.org> From: Maxime Henrion Date: Wed, 22 Feb 2006 21:27:01 +0000 (UTC) To: projects-committers@FreeBSD.org, cvs-projects@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Cc: Subject: cvs commit: projects/csup detailer.c lister.c main.c misc.h mux.c mux.h proto.c proto.h status.c threads.c threads.h updater.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Feb 2006 21:27:02 -0000 mux 2006-02-22 21:27:01 UTC FreeBSD projects repository Modified files: csup detailer.c lister.c main.c misc.h mux.c mux.h proto.c proto.h status.c threads.c threads.h updater.c Log: Many changes which allow csup to properly handle any synchronous or asynchronous error and to print meaningful messages nearly all the time. Hangs should not happen anymore, even in case of an error. We also correctly handle being sent some signals such as SIGINT, by correctly updating the status file and cleaning after us. Finally, csup now returns a proper exit code: 0 in case of success or 1 in case of an error, similarly to CVSup. Detailed list of changes: - Move the fattr_init() and fattr_fini() calls earlier to avoid calling them several times during a run. - When printing the "Connected to" message, print the actual address we are connected. This makes us deviate slightly from CVSup, but since csup tries any address returned by a host (including IPv6 addresses), we really need to know where we connected. - Make the errors/error messages handling much nicer in the status file API. Nearly all the asprintf() calls are centralized now. - Before entering multi-threaded mode, starts a "killer" thread that will spend most of his time blocking in sigwait() and will call mux_shutdown() to nicely abort the run in case we get a fatal signal. - Remove the need for the "closing" condition variable in mux_shutdown(), we are now handling the race it protected against much more sanely. We just disable cancellation in the "killer" thread before calling mux_shutdown() and re-enable it afterwards. This way, we can stop the killer thread at any time and after having joined it we know it is safe to call mux_close() since there are no more references to it but us. - We now pass a "status" parameter to mux_shutdown() indicating wether this is a normal call, a call because of a transient failure or hard failure, or a call because of a signal interruption. The "status" parameter of the very first mux_shutdown() is retained and returned later by mux_close, so that the main thread knows what happened. - We also pass an optional error message to mux_shutdown(), that will only be printed in the first call to mux_shutdown() and before doing the actual work. - Update the lister, detailer and updater threads to correctly check for error on read/write/parsing. Generate a proper error message in each case and return it back to the main thread, along with a status code indicating either success, failure or a transient failure. - Always call status_close() in the updater thread, to ensure that the status file is properly updated even if we are being interrupted by an error. - Slightly tweak the threads API to make it match our needs more closely. - Add a few useful comments here and there. - Rename proto_init() to the more correct proto_run() name. - Use the status code returned by the worker thread to only retry a run when we had a transient error, and to return a proper exit code at the end of the program's execution. Revision Changes Path 1.40 +151 -67 projects/csup/detailer.c 1.24 +195 -98 projects/csup/lister.c 1.32 +11 -7 projects/csup/main.c 1.23 +19 -1 projects/csup/misc.h 1.68 +63 -57 projects/csup/mux.c 1.25 +3 -3 projects/csup/mux.h 1.74 +161 -35 projects/csup/proto.c 1.12 +2 -2 projects/csup/proto.h 1.13 +119 -65 projects/csup/status.c 1.8 +10 -15 projects/csup/threads.c 1.6 +2 -2 projects/csup/threads.h 1.76 +214 -148 projects/csup/updater.c