From owner-p4-projects@FreeBSD.ORG Sat Aug 20 21:04:56 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 609AF16A421; Sat, 20 Aug 2005 21:04:56 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2A9ED16A41F for ; Sat, 20 Aug 2005 21:04:56 +0000 (GMT) (envelope-from soc-tyler@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id E125A43D45 for ; Sat, 20 Aug 2005 21:04:55 +0000 (GMT) (envelope-from soc-tyler@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 j7KL4t13074521 for ; Sat, 20 Aug 2005 21:04:55 GMT (envelope-from soc-tyler@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j7KL4tL2074518 for perforce@freebsd.org; Sat, 20 Aug 2005 21:04:55 GMT (envelope-from soc-tyler@freebsd.org) Date: Sat, 20 Aug 2005 21:04:55 GMT Message-Id: <200508202104.j7KL4tL2074518@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-tyler@freebsd.org using -f From: soc-tyler To: Perforce Change Reviews Cc: Subject: PERFORCE change 82337 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Aug 2005 21:04:57 -0000 http://perforce.freebsd.org/chv.cgi?CH=82337 Change 82337 by soc-tyler@soc-tyler_launchd on 2005/08/20 21:04:45 Use fprintf() to ensure nothing gets lost in buffers &stuff. Document launch_get_fd() according to zarzycki@'s description, as to why it's there, but never called Affected files ... .. //depot/projects/soc2005/launchd/liblaunch.c#10 edit Differences ... ==== //depot/projects/soc2005/launchd/liblaunch.c#10 (text+ko) ==== @@ -124,7 +124,7 @@ int r, dfd, lfd = -1, tries; #ifdef _LAUNCHD_ - printf("starting launch_client_init() in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"starting launch_client_init() in liblaunch.c:%d\n", __LINE__); #endif _lc = calloc(1, sizeof(struct _launch_client)); @@ -133,7 +133,7 @@ if (_lc == NULL) return; #ifdef _LAUNCHD_ - printf("calling pthread_mutex_init() in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"calling pthread_mutex_init() in liblaunch.c:%d\n", __LINE__); #endif pthread_mutex_init(&_lc->mtx, NULL); @@ -149,7 +149,8 @@ } #ifdef _LAUNCHD_ - printf("Reached liblaunch.c:%d and continuing with execution from here\n", __LINE__); + fprintf(stderr,"Reached liblaunch.c:%d and continuing with execution from here\n", + __LINE__); #endif if (lfd == -1) { @@ -162,12 +163,14 @@ snprintf(sun.sun_path, sizeof(sun.sun_path), "%s/%u/sock", LAUNCHD_SOCK_PREFIX, getuid()); #ifdef _LAUNCHD_ - printf("Successfully gotten the socket's path in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"Successfully gotten the socket's path in liblaunch.c:%d\n", + __LINE__); #endif if ((lfd = _fd(socket(AF_UNIX, SOCK_STREAM, 0))) == -1) { #ifdef _LAUNCHD_ - printf("_fd() call didn't succeed in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"_fd() call didn't succeed in liblaunch.c:%d\n", + __LINE__); #endif goto out_bad; } @@ -186,7 +189,7 @@ if (r == -1) { close(lfd); #ifdef _LAUNCHD_ - printf("r was equal to -1 in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"r was equal to -1 in liblaunch.c:%d\n", __LINE__); #endif goto out_bad; } @@ -195,14 +198,14 @@ if (!(_lc->l = launchd_fdopen(lfd))) { close(lfd); #ifdef _LAUNCHD_ - printf("launchd_fdopen() failed in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"launchd_fdopen() failed in liblaunch.c:%d\n", __LINE__); #endif goto out_bad; } if (!(_lc->async_resp = launch_data_alloc(LAUNCH_DATA_ARRAY))) { #ifdef _LAUNCHD_ - printf("launch_data_alloc() failed in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"launch_data_alloc() failed in liblaunch.c:%d\n", __LINE__); #endif goto out_bad; } @@ -211,7 +214,8 @@ out_bad: #ifdef _LAUNCHD_ - printf("Executed a \"goto out_bad\", running out_bad in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"Executed a \"goto out_bad\", running out_bad in liblaunch.c:%d\n", + __LINE__); #endif if (_lc->l != NULL) launchd_close(_lc->l); @@ -219,7 +223,9 @@ free(_lc); _lc = NULL; #ifdef _LAUNCHD_ - printf("Finished executing \'out_bad\', setting _lc to NULL in liblaunch.c:%d\n", __LINE__); + fprintf(stderr, + "Finished executing \'out_bad\', setting _lc to NULL in liblaunch.c:%d\n", + __LINE__); #endif } @@ -696,10 +702,19 @@ return 0; } -//! This function is never called, therefore is empty +//! This function is not called yet by anything +/*! + * According to zarzycki@: + * + * Eventually the launch_msg() interface will be used for asynchronous callbacks, + * thus the need to find out when messages are pending, and that brings us back to + * launch_get_fd(). + * + * launch_get_fd() and launch_msg() are the only two interfaces into the library, + * and we use pthread_once() from both to properly setup the library, no matter + * which is called first. + */ int launch_get_fd(void) { -// XXX: This function is *never* called....why does it exist? -/* pthread_once(&_lc_once, launch_client_init); if (_lc == NULL) { @@ -708,8 +723,6 @@ } return _lc->l->fd; -*/ - return 0; } static void launch_msg_getmsgs(launch_data_t m, void *context) @@ -728,7 +741,7 @@ launch_data_t resp = NULL; #ifdef _LAUNCHD_ - printf("Starting launch_msg() in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"Starting launch_msg() in liblaunch.c:%d\n", __LINE__); #endif // XXX: this call doesn't put something at &_lc @@ -737,14 +750,14 @@ // XXX: we keep evaluating for true here, and error out if (_lc == NULL) { #ifdef _LAUNCHD_ - printf("_lc sucks, returning liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"_lc sucks, returning liblaunch.c:%d\n", __LINE__); #endif errno = ENOTCONN; return NULL; } #ifdef _LAUNCHD_ - printf("Executing pthread_mutex_lock() in liblaunch.c:%d\n", __LINE__); + fprintf(stderr,"Executing pthread_mutex_lock() in liblaunch.c:%d\n", __LINE__); #endif pthread_mutex_lock(&_lc->mtx);