From: mike Date: Thu, 15 Nov 2012 21:01:21 +0000 (+0000) Subject: Save work. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef1a6c9d1dfb60c72c33865c53189f124e041e65;p=thirdparty%2Fcups.git Save work. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10700 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/backend/ipp.c b/backend/ipp.c index c71883a640..ad0a1263df 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -1352,7 +1352,8 @@ main(int argc, /* I - Number of command-line args */ monitor.job_name = print_job_name; } - _cupsThreadCreate((_cups_thread_func_t)monitor_printer, &monitor); + if (0) + _cupsThreadCreate((_cups_thread_func_t)monitor_printer, &monitor); /* * Validate access to the printer... diff --git a/cups/cups-private.h b/cups/cups-private.h index d946d81628..3b0cd68be8 100644 --- a/cups/cups-private.h +++ b/cups/cups-private.h @@ -87,6 +87,11 @@ typedef struct _cups_globals_s /**** CUPS global state data ****/ char resolved_uri[1024]; /* Buffer for cupsBackendDeviceURI */ + /* debug.c */ +# ifdef DEBUG + int thread_id; /* Friendly thread ID */ +# endif /* DEBUG */ + /* file.c */ cups_file_t *stdio_files[3];/* stdin, stdout, stderr */ diff --git a/cups/debug.c b/cups/debug.c index 71b693c70a..27ade63ca6 100644 --- a/cups/debug.c +++ b/cups/debug.c @@ -68,8 +68,24 @@ int _cups_debug_level = 1; static regex_t *debug_filter = NULL; /* Filter expression for messages */ static int debug_init = 0; /* Did we initialize debugging? */ -static _cups_mutex_t debug_mutex = _CUPS_MUTEX_INITIALIZER; +static _cups_mutex_t debug_init_mutex = _CUPS_MUTEX_INITIALIZER, /* Mutex to control initialization */ + debug_log_mutex = _CUPS_MUTEX_INITIALIZER; + /* Mutex to serialize log entries */ + + +/* + * 'debug_thread_id()' - Return an integer representing the current thread. + */ + +static int /* O - Local thread ID */ +debug_thread_id(void) +{ + _cups_globals_t *cg = _cupsGlobals(); /* Global data */ + + + return (cg->thread_id); +} /* @@ -433,9 +449,9 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */ { int result; /* Filter result */ - _cupsMutexLock(&debug_mutex); + _cupsMutexLock(&debug_init_mutex); result = regexec(debug_filter, format, 0, NULL, 0); - _cupsMutexUnlock(&debug_mutex); + _cupsMutexUnlock(&debug_init_mutex); if (result) return; @@ -446,13 +462,13 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */ */ gettimeofday(&curtime, NULL); - snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d.%03d ", - (int)((curtime.tv_sec / 3600) % 24), + snprintf(buffer, sizeof(buffer), "T%03d %02d:%02d:%02d.%03d ", + debug_thread_id(), (int)((curtime.tv_sec / 3600) % 24), (int)((curtime.tv_sec / 60) % 60), (int)(curtime.tv_sec % 60), (int)(curtime.tv_usec / 1000)); va_start(ap, format); - bytes = debug_vsnprintf(buffer + 13, sizeof(buffer) - 14, format, ap) + 13; + bytes = debug_vsnprintf(buffer + 19, sizeof(buffer) - 20, format, ap) + 19; va_end(ap); if (bytes >= (sizeof(buffer) - 1)) @@ -470,7 +486,9 @@ _cups_debug_printf(const char *format, /* I - Printf-style format string */ * Write it out... */ + _cupsMutexLock(&debug_log_mutex); write(_cups_debug_fd, buffer, bytes); + _cupsMutexUnlock(&debug_log_mutex); } @@ -514,9 +532,9 @@ _cups_debug_puts(const char *s) /* I - String to output */ { int result; /* Filter result */ - _cupsMutexLock(&debug_mutex); + _cupsMutexLock(&debug_init_mutex); result = regexec(debug_filter, s, 0, NULL, 0); - _cupsMutexUnlock(&debug_mutex); + _cupsMutexUnlock(&debug_init_mutex); if (result) return; @@ -527,8 +545,8 @@ _cups_debug_puts(const char *s) /* I - String to output */ */ gettimeofday(&curtime, NULL); - bytes = snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d.%03d %s", - (int)((curtime.tv_sec / 3600) % 24), + bytes = snprintf(buffer, sizeof(buffer), "T%03d %02d:%02d:%02d.%03d %s", + debug_thread_id(), (int)((curtime.tv_sec / 3600) % 24), (int)((curtime.tv_sec / 60) % 60), (int)(curtime.tv_sec % 60), (int)(curtime.tv_usec / 1000), s); @@ -548,7 +566,9 @@ _cups_debug_puts(const char *s) /* I - String to output */ * Write it out... */ + _cupsMutexLock(&debug_log_mutex); write(_cups_debug_fd, buffer, bytes); + _cupsMutexUnlock(&debug_log_mutex); } @@ -562,7 +582,7 @@ _cups_debug_set(const char *logfile, /* I - Log file or NULL */ const char *filter, /* I - Filter string or NULL */ int force) /* I - Force initialization */ { - _cupsMutexLock(&debug_mutex); + _cupsMutexLock(&debug_init_mutex); if (!debug_init || force) { @@ -624,7 +644,7 @@ _cups_debug_set(const char *logfile, /* I - Log file or NULL */ debug_init = 1; } - _cupsMutexUnlock(&debug_mutex); + _cupsMutexUnlock(&debug_init_mutex); } #endif /* DEBUG */ diff --git a/cups/globals.c b/cups/globals.c index f382f393a6..fec94975e9 100644 --- a/cups/globals.c +++ b/cups/globals.c @@ -38,6 +38,10 @@ */ +#ifdef DEBUG +static int cups_global_index = 0; + /* Next thread number */ +#endif /* DEBUG */ static _cups_threadkey_t cups_globals_key = _CUPS_THREADKEY_INITIALIZER; /* Thread local storage key */ #ifdef HAVE_PTHREAD_H @@ -216,6 +220,14 @@ cups_globals_alloc(void) cg->expired_certs = 1; cg->expired_root = 1; +#ifdef DEBUG + /* + * Friendly thread ID for debugging... + */ + + cg->thread_id = ++ cups_global_index; +#endif /* DEBUG */ + /* * Then set directories as appropriate... */ diff --git a/cups/http.c b/cups/http.c index ea1a7d3d0e..bcf8b2df62 100644 --- a/cups/http.c +++ b/cups/http.c @@ -3242,6 +3242,9 @@ void httpSetLength(http_t *http, /* I - Connection to server */ size_t length) /* I - Length (0 for chunked) */ { + DEBUG_printf(("httpSetLength(http=%p, length=" CUPS_LLFMT ")", http, + CUPS_LLCAST length)); + if (!http) return; @@ -4902,7 +4905,8 @@ http_set_length(http_t *http) /* I - Connection */ { if (http->mode == _HTTP_MODE_SERVER && http->state != HTTP_STATE_GET_SEND && - http->state != HTTP_STATE_POST) + http->state != HTTP_STATE_POST && + http->state != HTTP_STATE_POST_SEND) { DEBUG_puts("1http_set_length: Not setting data_encoding/remaining."); return (remaining); diff --git a/test/ippserver.c b/test/ippserver.c index 4934349637..dcdb100261 100644 --- a/test/ippserver.c +++ b/test/ippserver.c @@ -4712,6 +4712,9 @@ respond_http( if (httpPrintf(client->http, "%s", message) < 0) return (0); + + if (httpWrite2(client->http, "", 0) < 0) + return (0); } else if (client->response) { @@ -4727,11 +4730,7 @@ respond_http( return (0); } - /* - * Flush the data and return... - */ - - return (httpFlushWrite(client->http) >= 0); + return (1); } diff --git a/test/run-stp-tests.sh b/test/run-stp-tests.sh index a67d3efa23..d8244c0b0b 100755 --- a/test/run-stp-tests.sh +++ b/test/run-stp-tests.sh @@ -605,7 +605,7 @@ done # date=`date "+%Y-%m-%d"` -strfile=/tmp/cups-$user/cups-str-1.6-$date-$user.html +strfile=/tmp/cups-$user/cups-str-1.7-$date-$user.html rm -f $strfile cat str-header.html >$strfile