apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: Problem with apr_proc_mutex
Date Thu, 27 Mar 2003 20:15:08 GMT
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