Fix a case where the cleanup for a pollset w/o the thread-safe flag
would try to zap a random/garbage message queue identifier. In httpd,
this could happen with e.g. mod_cgi's short-lived, non-threadsafe
pollset.



git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1750374 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/poll/unix/z_asio.c b/poll/unix/z_asio.c
index 6537d49..6da4ee8 100644
--- a/poll/unix/z_asio.c
+++ b/poll/unix/z_asio.c
@@ -247,9 +247,11 @@
     int rv;
 
     DBG(4, "entered\n");
-    rv = msgctl(pollset->p->msg_q, IPC_RMID, NULL);
+    if (pollset->flags & APR_POLLSET_THREADSAFE) { 
+        rv = msgctl(pollset->p->msg_q, IPC_RMID, NULL);
+        DBG1(4, "asio_pollset_cleanup: msgctl(IPC_RMID) returned %d\n", rv);
+    }
 
-    DBG1(4, "exiting, msgctl(IPC_RMID) returned %d\n", rv);
     return rv;
 }
 
@@ -264,7 +266,7 @@
 
     DBG1(2, "entered, flags: %x\n", flags);
 
-    priv = pollset->p = apr_palloc(p, sizeof(*priv));
+    priv = pollset->p = apr_pcalloc(p, sizeof(*priv));
 
     if (flags & APR_POLLSET_THREADSAFE) {
 #if APR_HAS_THREADS