apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Spinka, Kristofer" <kspi...@style.net>
Subject RE: Problem with apr_proc_mutex
Date Fri, 28 Mar 2003 01:48:27 GMT
My thoughts,

1. The naming is absolutely necessary if other, non-fork()'d, processes
wish to find and use these resources; easily.

2. Using some sort of namespace identifier, such as your proposed "ApR"
is definitely attractive for diagnostic purposes.
 
3. The whole 14 character b/s with POSIX is quite outmode, and many
platforms do *not* enforce this limit.  Perhaps APR should have a strict
POSIX mode, and a "modern" POSIX mode that can be detected with a
configure-time test.

4. Using a hash will destroy the human readability/associability factor
(during diagnostic time).

5. If APR applications allocate *many* system-globally scoped resources,
it might be better to stuff them into an APR managed shared memory block
(that has its own symbol name lookup table) and only consumes one global
identifier.  Once a foreign process is attached to that globally-named
memory block, it can use some new APR API to search a dictionary
embedded at the head of that block.
 
   /kristofer


-----Original Message-----
From: William A. Rowe, Jr. [mailto:wrowe@rowe-clan.net] 
Sent: Thursday, March 27, 2003 3:15 PM
To: dev@httpd.apache.org; dev@apr.apache.org
Subject: Re: Problem with apr_proc_mutex

Yea - I would appreciate if we supply a platform-agostic mutex name,
such as logs/ssl_mutex, that we end up with the mutex named
/logs/ssl_mutex.  If we believe that posix will trip over logs/ (it
might
just exist already) then perhaps;

1. we fold away non-root slashes if they are prohibited (it seems they
are),
   perhaps to underbars as win32 and os2 do?  

2. we prepend /ApR to every unrooted posix mutex

So logs/ssl_mutex becomes /ApRlogs_ssl_mutex.  This way if we end up
using SSLMutex default:logs/ssl_mutex as the default, we end up with a
usable string.

This still doesn't help mulitple paths to APR, I still kinda like
inventing an md5
hash to name the mutex.  The other option, if posix semaphores are just
too weak, is to consider them unnamed objects as they are today.

Bill   

At 12:31 PM 3/27/2003, you wrote:
>At 11:48 AM -0600 3/27/03, William A. Rowe, Jr. wrote:
>>Moving this discussion over to dev@apr... reply there ;-)
>>
>Comments?? :)
>
>
>Index: locks/unix/proc_mutex.c
>===================================================================
>RCS file: /home/cvs/apr/locks/unix/proc_mutex.c,v
>retrieving revision 1.28
>diff -u -r1.28 proc_mutex.c
>--- locks/unix/proc_mutex.c     23 Feb 2003 16:40:31 -0000      1.28
>+++ locks/unix/proc_mutex.c     27 Mar 2003 17:50:48 -0000
>@@ -91,10 +91,8 @@
> {
>     sem_t *psem;
>     apr_status_t stat;
>+    const char *goodfname = fname;
>     char semname[31];
>-    apr_time_t now;
>-    unsigned long sec;
>-    unsigned long usec;
>    
>     new_mutex->interproc = apr_palloc(new_mutex->pool,
>                                       sizeof(*new_mutex->interproc));
>@@ -105,8 +103,8 @@
>      *   - be at most 14 chars
>      *   - be unique and not match anything on the filesystem
>      *
>-     * Because of this, we ignore fname, and try our
>-     * own naming system. We tuck the name away, since it might
>+     * Because of this, we first try fname and if that fails we try
>+     * our own naming system. We tuck the name away, since it might
>      * be useful for debugging. to  make this as robust as possible,
>      * we initially try something larger (and hopefully more unique)
>      * and gracefully fail down to the LCD above.
>@@ -123,26 +121,34 @@
>      * help here however...
>      *
>      */
>-    now = apr_time_now();
>-    sec = apr_time_sec(now);
>-    usec = apr_time_usec(now);
>-    apr_snprintf(semname, sizeof(semname), "/ApR.%lxZ%lx", sec, usec);
>-    psem = sem_open((const char *) semname, O_CREAT, 0644, 1);
>-    if ((psem == (sem_t *)SEM_FAILED) && (errno == ENAMETOOLONG)) {
>-        /* Oh well, good try */
>-        semname[13] = '\0';
>+    if ( (goodfname == NULL) ||
>+        ((psem = sem_open(goodfname,O_CREAT,0644,1)) == (sem_t
*)SEM_FAILED)) {
>+        apr_time_t now;
>+        unsigned long sec;
>+        unsigned long usec;
>+
>+        now = apr_time_now();
>+        sec = apr_time_sec(now);
>+        usec = apr_time_usec(now);
>+        apr_snprintf(semname, sizeof(semname), "/ApR.%lxZ%lx", sec,
usec);
>         psem = sem_open((const char *) semname, O_CREAT, 0644, 1);
>-    }
>+        if ((psem == (sem_t *)SEM_FAILED) && (errno == ENAMETOOLONG))
{
>+            /* Oh well, good try */
>+            semname[13] = '\0';
>+            psem = sem_open((const char *) semname, O_CREAT, 0644, 1);
>+        }
> 
>-    if (psem == (sem_t *)SEM_FAILED) {
>-        stat = errno;
>-        proc_mutex_posix_cleanup(new_mutex);
>-        return stat;
>+        if (psem == (sem_t *)SEM_FAILED) {
>+            stat = errno;
>+            proc_mutex_posix_cleanup(new_mutex);
>+            return stat;
>+        }
>+        goodfname = semname;
>     }
>     /* Ahhh. The joys of Posix sems. Predelete it... */
>-    sem_unlink((const char *) semname);
>+    sem_unlink((const char *) goodfname);
>     new_mutex->interproc->filedes = (int)psem; /* Ugg */
>-    new_mutex->fname = apr_pstrdup(new_mutex->pool, semname);
>+    new_mutex->fname = apr_pstrdup(new_mutex->pool, goodfname);
>     apr_pool_cleanup_register(new_mutex->pool, (void *)new_mutex,
>                               apr_proc_mutex_cleanup,
>                               apr_pool_cleanup_null);
>
>-- 
>=======================================================================
====
>   Jim Jagielski   [|]   jim@jaguNET.com   [|]
http://www.jaguNET.com/
>      "A society that will trade a little liberty for a little order
>             will lose both and deserve neither" - T.Jefferson




Mime
View raw message