Date: Sat, 20 Aug 2005 21:04:55 GMT From: soc-tyler <soc-tyler@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 82337 for review Message-ID: <200508202104.j7KL4tL2074518@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508202104.j7KL4tL2074518>