]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Save work.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 15 Nov 2012 21:01:21 +0000 (21:01 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 15 Nov 2012 21:01:21 +0000 (21:01 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10700 7a7537e8-13f0-0310-91df-b6672ffda945

backend/ipp.c
cups/cups-private.h
cups/debug.c
cups/globals.c
cups/http.c
test/ippserver.c
test/run-stp-tests.sh

index c71883a640f527ca3b3f05c51390c96b40528849..ad0a1263dfe07873f6052e2e1b3dc10199c5821b 100644 (file)
@@ -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...
index d946d81628cf9154f8cac15b64c8c254fa32b36e..3b0cd68be82555db0f07fde7a22b4f76799971c9 100644 (file)
@@ -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 */
 
index 71b693c70a7b623f75b8d4a5314fbe263453b61d..27ade63ca6ff57d0e902c722d592ca8cbaba793c 100644 (file)
@@ -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 */
 
index f382f393a6845683179947c4fe8e886340b4f033..fec94975e93e82a5f791804b0724ef2a9c7d9129 100644 (file)
  */
 
 
+#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...
   */
index ea1a7d3d0e73d450c5f6e73e20cd01dee7503a03..bcf8b2df625f07d83c5c6a4b0a521a9a819099bf 100644 (file)
@@ -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);
index 4934349637b64bc05b194726a54622c15b75cf3a..dcdb100261c9cb6a9a69155efa0be369eb27752a 100644 (file)
@@ -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);
 }
 
 
index a67d3efa2373648417c7552547b328764365ef2e..d8244c0b0b94c2ea60ad45ed2f41dcf77633a40d 100755 (executable)
@@ -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