[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Please unblock mod-wsgi 2.3-1



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Release Team,

as the changes since mod-wsgi 2.1 were bugfixes only (with an exception
of a few new lines which are limited by ifdefs to BSD) I'd like to ask
for a freeze exception. The detailed changelog is pasted below, and a
full debdiff attached.

Thanks,

Bernd


Changes:
 mod-wsgi (2.3-1) unstable; urgency=low
 .
   * New upstream release (Closes: #496067). This upload covers the changes of
     mod-wsgi 2.2 and 2.3.
     mod-wsgi 2.2 is mainly bugfix-releases. The only exception is a backport
     of one function from 3.0 which allows the setting of process names on *BSD
     - this does not affect Linux.
     mod-wsgi 2.3 fixes regressions which were introduced in 2.2.
 .
     Here follows a list of the bugfixes in 2.2:
       1. Fix bug whereby if mod_python is loaded at same time as mod_wsgi the
          WSGIImportScript directive can cause Apache child processes to crash.
          For details see: http://code.google.com/p/modwsgi/issues/detail?id=91
 .
       2. Fix bug where mod_wsgi daemon process startup could fail due to old
          stale UNIX listener socket file as described in:
          http://code.google.com/p/modwsgi/issues/detail?id=77
 .
       3. Fix bug where listener socket file descriptors for daemon processes
          were being leaked in Apache parent process on a graceful restart.
          Also fixes problem where UNIX listener socket was left in filesystem
          on both graceful restart and graceful shutdown. For details see:
          http://code.google.com/p/modwsgi/issues/detail?id=95
 .
       4. Fix bug where response was truncated when a null character appeared
          as first character in block of data being returned from
          wsgi.file_wrapper.
          Only occurred when code fell back to using iteration over supplied
          file like object, rather than optimised method such as sendfile().
          http://code.google.com/p/modwsgi/issues/detail?id=100
 .
     The following regressions/bugs of 2.2 were fixed in 2.3:
 .
       1. Fixed problem introduced in version 2.2 of mod_wsgi whereby use of
          daemon mode would cause CGI scripts to fail. It is quite possible
          that the bug could also have caused failures with other Apache
          modules that relied on registering of cleanup functions against
          Apache configuration memory pool.
 .
       2. (does not affect Linux)
          When using setproctitle() on BSD systems, first argument should be
          a printf style format string with values to fill out per format as
          additional arguments. Code was supplying value to be displayed as
          format string which meant that if it contained any printf type format
          sequences, could cause process to crash as corresponding arguments
          wouldn't have ben provided.


- --
 Bernd Zeimetz                           Debian GNU/Linux Developer
 GPG Fingerprint: 06C8 C9A2 EAAD E37E 5B2C BE93 067A AD04 C93B FF79

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkizHM4ACgkQBnqtBMk7/3kSZgCguSVxvOgI3zHjdTe21nuC3fnH
vacAoLueCANsiuYFhl+ZqAfhbRXWZNOJ
=Ezzy
-----END PGP SIGNATURE-----
diff -Nru mod-wsgi-2.1/debian/changelog mod-wsgi-2.3/debian/changelog
--- mod-wsgi-2.1/debian/changelog	2008-08-25 22:48:50.000000000 +0200
+++ mod-wsgi-2.3/debian/changelog	2008-08-25 22:48:51.000000000 +0200
@@ -1,3 +1,52 @@
+mod-wsgi (2.3-1) unstable; urgency=low
+
+  * New upstream release (Closes: #496067). This upload covers the changes of
+    mod-wsgi 2.2 and 2.3.
+    mod-wsgi 2.2 is mainly bugfix-releases. The only exception is a backport
+    of one function from 3.0 which allows the setting of process names on *BSD
+    - this does not affect Linux.
+    mod-wsgi 2.3 fixes regressions which were introduced in 2.2.
+    
+    Here follows a list of the bugfixes in 2.2:
+      1. Fix bug whereby if mod_python is loaded at same time as mod_wsgi the
+         WSGIImportScript directive can cause Apache child processes to crash.
+         For details see: http://code.google.com/p/modwsgi/issues/detail?id=91
+
+      2. Fix bug where mod_wsgi daemon process startup could fail due to old
+         stale UNIX listener socket file as described in:
+         http://code.google.com/p/modwsgi/issues/detail?id=77 
+
+      3. Fix bug where listener socket file descriptors for daemon processes
+         were being leaked in Apache parent process on a graceful restart.
+         Also fixes problem where UNIX listener socket was left in filesystem
+         on both graceful restart and graceful shutdown. For details see:
+         http://code.google.com/p/modwsgi/issues/detail?id=95 
+
+      4. Fix bug where response was truncated when a null character appeared
+         as first character in block of data being returned from
+         wsgi.file_wrapper.
+         Only occurred when code fell back to using iteration over supplied
+         file like object, rather than optimised method such as sendfile().
+         http://code.google.com/p/modwsgi/issues/detail?id=100
+
+    The following regressions/bugs of 2.2 were fixed in 2.3:
+
+      1. Fixed problem introduced in version 2.2 of mod_wsgi whereby use of
+         daemon mode would cause CGI scripts to fail. It is quite possible
+         that the bug could also have caused failures with other Apache
+         modules that relied on registering of cleanup functions against
+         Apache configuration memory pool.
+
+      2. (does not affect Linux)
+         When using setproctitle() on BSD systems, first argument should be
+         a printf style format string with values to fill out per format as
+         additional arguments. Code was supplying value to be displayed as
+         format string which meant that if it contained any printf type format
+         sequences, could cause process to crash as corresponding arguments
+         wouldn't have ben provided.
+
+ -- Bernd Zeimetz <bzed@debian.org>  Sat, 23 Aug 2008 19:27:48 +0200
+
 mod-wsgi (2.1-2) unstable; urgency=medium
 
   * Calling pyversions in postinst requires that 'python' is installed *and*
diff -Nru mod-wsgi-2.1/mod_wsgi.c mod-wsgi-2.3/mod_wsgi.c
--- mod-wsgi-2.1/mod_wsgi.c	2008-06-18 16:35:40.000000000 +0200
+++ mod-wsgi-2.3/mod_wsgi.c	2008-08-23 15:28:00.000000000 +0200
@@ -245,8 +245,8 @@
 /* Version and module information. */
 
 #define MOD_WSGI_MAJORVERSION_NUMBER 2
-#define MOD_WSGI_MINORVERSION_NUMBER 1
-#define MOD_WSGI_VERSION_STRING "2.1-BRANCH"
+#define MOD_WSGI_MINORVERSION_NUMBER 2
+#define MOD_WSGI_VERSION_STRING "2.3"
 
 #if AP_SERVER_MAJORVERSION_NUMBER < 2
 module MODULE_VAR_EXPORT wsgi_module;
@@ -366,8 +366,6 @@
 
 #if defined(MOD_WSGI_WITH_DAEMONS)
     object->socket_prefix = DEFAULT_REL_RUNTIMEDIR "/wsgi";
-    object->socket_prefix = apr_psprintf(p, "%s.%d", object->socket_prefix,
-                                         getpid());
     object->socket_prefix = ap_server_root_relative(p, object->socket_prefix);
 #endif
 
@@ -3335,7 +3333,7 @@
         return 0;
     }
 
-    if (*PyString_AsString(result) == '\0') {
+    if (PyString_Size(result) == 0) {
         PyErr_SetObject(PyExc_StopIteration, Py_None);
         Py_DECREF(args);
         Py_DECREF(result);
@@ -7522,6 +7520,8 @@
     entry->send_buffer_size = send_buffer_size;
     entry->recv_buffer_size = recv_buffer_size;
 
+    entry->listener_fd = -1;
+
     return NULL;
 }
 
@@ -7537,9 +7537,7 @@
 
     sconfig = ap_get_module_config(cmd->server->module_config, &wsgi_module);
 
-    sconfig->socket_prefix = apr_psprintf(cmd->pool, "%s.%d", arg, getpid());
-    sconfig->socket_prefix = ap_server_root_relative(cmd->pool,
-                                                     sconfig->socket_prefix);
+    sconfig->socket_prefix = ap_server_root_relative(cmd->pool, arg);
 
     if (!sconfig->socket_prefix) {
         return apr_pstrcat(cmd->pool, "Invalid WSGISocketPrefix '",
@@ -7689,28 +7687,6 @@
 
             apr_proc_other_child_unregister(daemon);
 
-            /*
-             * Remove socket used for communicating with daemon
-             * when the process to be notified is the first in
-             * the process group.
-             */
-
-            if (daemon->instance == 1) {
-                if (close(daemon->group->listener_fd) < 0) {
-                    ap_log_error(APLOG_MARK, WSGI_LOG_ERR(errno),
-                                 wsgi_server, "mod_wsgi (pid=%d): "
-                                 "Couldn't close unix domain socket '%s'.",
-                                 getpid(), daemon->group->socket);
-                }
-
-                if (unlink(daemon->group->socket) < 0 && errno != ENOENT) {
-                    ap_log_error(APLOG_MARK, WSGI_LOG_ERR(errno),
-                                 wsgi_server, "mod_wsgi (pid=%d): "
-                                 "Couldn't unlink unix domain socket '%s'.",
-                                 getpid(), daemon->group->socket);
-                }
-            }
-
             break;
         }
 
@@ -7749,10 +7725,12 @@
 {
     const char *display_name = NULL;
 
+#if !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))
     int slen = 0;
     int dlen = 0;
 
     char *argv0 = NULL;
+#endif
 
     display_name = daemon->group->display_name;
 
@@ -7771,6 +7749,9 @@
      * is restricted, need to truncate display name if too long.
      */
 
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+    setproctitle("%s", display_name);
+#else
     argv0 = (char*)wsgi_server->process->argv[0];
 
     dlen = strlen(argv0);
@@ -7782,6 +7763,7 @@
         memcpy(argv0, display_name, slen);
     else
         memcpy(argv0, display_name, dlen);
+#endif
 }
 
 static void wsgi_setup_access(WSGIDaemonProcess *daemon)
@@ -7916,7 +7898,19 @@
 
     omask = umask(0077);
     rc = bind(sockfd, (struct sockaddr *)&addr, sizeof(addr));
+
+    if (rc < 0 && errno == EADDRINUSE) {
+        ap_log_error(APLOG_MARK, WSGI_LOG_WARNING(errno), wsgi_server,
+                     "mod_wsgi (pid=%d): Removing stale unix domain "
+                     "socket '%s'.", getpid(), process->socket);
+        
+        unlink(process->socket);
+    
+        rc = bind(sockfd, (struct sockaddr *)&addr, sizeof(addr));
+    }                              
+
     umask(omask);
+
     if (rc < 0) {
         ap_log_error(APLOG_MARK, WSGI_LOG_ALERT(errno), wsgi_server,
                      "mod_wsgi (pid=%d): Couldn't bind unix domain "
@@ -8534,6 +8528,34 @@
     }
 }
 
+static apr_status_t wsgi_cleanup_process(void *data)
+{
+    WSGIProcessGroup *group = (WSGIProcessGroup *)data;
+
+    /* Only do cleanup if in Apache parent process. */
+
+    if (wsgi_parent_pid != getpid())
+        return APR_SUCCESS;
+
+    if (group->listener_fd != -1) {
+        if (close(group->listener_fd) < 0) {
+            ap_log_error(APLOG_MARK, WSGI_LOG_ERR(errno),
+                         wsgi_server, "mod_wsgi (pid=%d): "
+                         "Couldn't close unix domain socket '%s'.",
+                         getpid(), group->socket);
+        }
+
+        if (unlink(group->socket) < 0 && errno != ENOENT) {
+            ap_log_error(APLOG_MARK, WSGI_LOG_ERR(errno),
+                         wsgi_server, "mod_wsgi (pid=%d): "
+                         "Couldn't unlink unix domain socket '%s'.",
+                         getpid(), group->socket);
+        }
+    }
+
+    return APR_SUCCESS;
+}
+
 static int wsgi_start_process(apr_pool_t *p, WSGIDaemonProcess *daemon)
 {
     apr_status_t status;
@@ -8659,6 +8681,23 @@
         }
 
         /*
+         * Close listener socket for daemon processes for other
+         * daemon process groups. In other words, close all but
+         * our own.
+         */
+
+        entries = (WSGIProcessGroup *)wsgi_daemon_list->elts;
+
+        for (i = 0; i < wsgi_daemon_list->nelts; ++i) {
+            entry = &entries[i];
+
+            if (entry != daemon->group && entry->listener_fd != -1) {
+                close(entry->listener_fd);
+                entry->listener_fd = -1;
+            }
+        }
+
+        /*
          * Register signal handler to receive shutdown signal
          * from Apache parent process.
          */
@@ -8819,9 +8858,9 @@
          * create the socket.
          */
 
-        entry->socket = apr_psprintf(p, "%s.%d.%d.sock",
+        entry->socket = apr_psprintf(p, "%s.%d.%d.%d.sock",
                                      wsgi_server_config->socket_prefix,
-                                     ap_my_generation, entry->id);
+                                     getpid(), ap_my_generation, entry->id);
 
         apr_hash_set(wsgi_daemon_index, entry->name, APR_HASH_KEY_STRING,
                      entry);
@@ -8832,6 +8871,14 @@
             return DECLINED;
 
         /*
+         * Register cleanup so that listener socket is cleaned
+         * up properly on a restart and on shutdown.
+         */
+
+        apr_pool_cleanup_register(p, entry, wsgi_cleanup_process,
+                                  apr_pool_cleanup_null);
+
+        /*
          * If there is more than one daemon process in the group
          * then need to create an accept mutex for the daemon
          * processes to use so they don't interfere with each
@@ -8839,9 +8886,10 @@
          */
 
         if (entry->processes > 1) {
-            entry->mutex_path = apr_psprintf(p, "%s.%d.%d.lock",
+            entry->mutex_path = apr_psprintf(p, "%s.%d.%d.%d.lock",
                                              wsgi_server_config->socket_prefix,
-                                             ap_my_generation, entry->id);
+                                             getpid(), ap_my_generation,
+                                             entry->id);
 
             status = apr_proc_mutex_create(&entry->mutex, entry->mutex_path,
                                            wsgi_server_config->lock_mechanism,
@@ -9988,6 +10036,26 @@
 
 static void wsgi_hook_child_init(apr_pool_t *p, server_rec *s)
 {
+    WSGIProcessGroup *entries = NULL;
+    WSGIProcessGroup *entry = NULL;
+
+    int i;
+
+    /* Close listener sockets for daemon processes. */
+
+    if (wsgi_daemon_list) {
+        entries = (WSGIProcessGroup *)wsgi_daemon_list->elts;
+
+        for (i = 0; i < wsgi_daemon_list->nelts; ++i) {
+            entry = &entries[i];
+
+            close(entry->listener_fd);
+            entry->listener_fd = -1;
+        }
+    }
+
+    /* Setup Python in Apache worker processes. */
+
     wsgi_python_child_init(p);
 }
 
@@ -11495,15 +11563,10 @@
     static const char * const n5[] = { "mod_authz_host.c", NULL };
 #endif
 
-    /*
-     * Perform initialisation last in the post config phase to
-     * ensure that if mod_python is also being loaded that it
-     * gets to perform interpreter initialisation in preference
-     * to mod_wsgi doing it.
-     */
+    static const char * const p6[] = { "mod_python.c", NULL };
 
-    ap_hook_post_config(wsgi_hook_init, NULL, NULL, APR_HOOK_LAST);
-    ap_hook_child_init(wsgi_hook_child_init, NULL, NULL, APR_HOOK_MIDDLE);
+    ap_hook_post_config(wsgi_hook_init, p6, NULL, APR_HOOK_MIDDLE);
+    ap_hook_child_init(wsgi_hook_child_init, p6, NULL, APR_HOOK_MIDDLE);
 
     ap_hook_translate_name(wsgi_hook_intercept, p1, n1, APR_HOOK_MIDDLE);
     ap_hook_handler(wsgi_hook_handler, NULL, NULL, APR_HOOK_MIDDLE);

Reply to: